From 5f2b02c44150e5330cce3b285db6163240dd2fda Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 6 Jun 2018 15:54:39 +0200 Subject: [PATCH] - persondatasetjs works with ajaxlib - added js object to persondatasetjs - no locking when details accessed from freigegeben - tablesorter filter remains when getting back from details page --- .../system/infocenter/InfoCenter.php | 37 ++- .../system/infocenter/infocenterDetails.php | 15 +- .../infocenter/infocenterFreigegeben.php | 2 +- public/css/sbadmin2/admintemplate.css | 4 +- public/js/FilterWidget.js | 22 +- public/js/infocenter/infocenterDetails.js | 15 +- .../js/infocenter/infocenterPersonDataset.js | 254 ++++++++---------- 7 files changed, 177 insertions(+), 172 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index 25a653eb1..16668f095 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -129,24 +129,31 @@ class InfoCenter extends FHC_Controller $personexists = $this->PersonModel->load($person_id); - if(isError($personexists)) + if (isError($personexists)) show_error($personexists->retval); if (empty($personexists->retval)) show_error('person does not exist!'); - //mark person as locked for editing - $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + $show_lock_link_get = $this->input->get('show_lock_link'); + $show_lock_link = !isset($show_lock_link_get) || $show_lock_link_get === '1'; - if(isError($result)) - show_error($result->retval); + if ($show_lock_link) + { + //mark person as locked for editing + $result = $this->PersonLockModel->lockPerson($person_id, $this->uid, self::APP); + + if (isError($result)) + show_error($result->retval); + } $persondata = $this->_loadPersonData($person_id); $prestudentdata = $this->_loadPrestudentData($person_id); $data = array_merge( $persondata, - $prestudentdata + $prestudentdata, + array('show_lock_link' => $show_lock_link) ); $data['fhc_controller_id'] = $this->fhc_controller_id; @@ -162,7 +169,7 @@ class InfoCenter extends FHC_Controller { $result = $this->PersonLockModel->unlockPerson($person_id, self::APP); - if(isError($result)) + if (isError($result)) show_error($result->retval); redirect(self::URL_PREFIX.'?fhc_controller_id='.$this->fhc_controller_id); @@ -245,9 +252,7 @@ class InfoCenter extends FHC_Controller $data['data'] = $studienordnung->retval[0]->data; } - $this->load->view('system/infocenter/studiengangZgvInfo.php', - $data - ); + $this->load->view('system/infocenter/studiengangZgvInfo.php', $data); } /** @@ -721,6 +726,18 @@ class InfoCenter extends FHC_Controller ); } + /** + * Wrapper for setNavigationMenu, returns JSON message + */ + public function setNavigationMenuArrayJson() + { + $this->setNavigationMenuArray(); + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(success('success'))); + } + private function _fillFilters($filters, &$tofill) { foreach ($filters as $filterId => $description) diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 069cd99c7..7ad0e47a0 100755 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -69,17 +69,16 @@
- p->t('global', 'wirdBearbeitetVon').':' ?> p->t('global', 'wirdBearbeitetVon') . ': '; echo $lockedby; - ?> -    - -   - p->t('ui', 'freigeben')) ?> - + if (!isset($show_lock_link) || $show_lock_link === true): ?> +    + +  p->t('ui', 'freigeben')) ?> + +
diff --git a/application/views/system/infocenter/infocenterFreigegeben.php b/application/views/system/infocenter/infocenterFreigegeben.php index f2c279b0f..998e79fbc 100755 --- a/application/views/system/infocenter/infocenterFreigegeben.php +++ b/application/views/system/infocenter/infocenterFreigegeben.php @@ -172,7 +172,7 @@ 'formatRaw' => function($datasetRaw) { $datasetRaw->{'Details'} = sprintf( - 'Details', + 'Details', site_url('system/infocenter/InfoCenter/showDetails'), $datasetRaw->{'PersonId'}, (isset($_GET['fhc_controller_id'])?$_GET['fhc_controller_id']:'') diff --git a/public/css/sbadmin2/admintemplate.css b/public/css/sbadmin2/admintemplate.css index e47fdd3b2..a0064e5c2 100644 --- a/public/css/sbadmin2/admintemplate.css +++ b/public/css/sbadmin2/admintemplate.css @@ -23,7 +23,7 @@ } /*arrow toggle for panels*/ -.panel-heading .accordion-toggle:before{ +.panel-heading .accordion-toggle.arrowcollapse:before{ /* symbol for "opening" panels */ font-family: 'Glyphicons Halflings'; /* essential for enabling glyphicon */ content: "\e114"; /* adjust as needed, taken from bootstrap.css */ @@ -32,7 +32,7 @@ color: grey; /* adjust as needed */ } -.panel-heading .accordion-toggle.collapsed:before{ +.panel-heading .accordion-toggle.collapsed.arrowcollapse:before{ /* symbol for "collapsed" panels */ content: "\e080"; /* adjust as needed, taken from bootstrap.css */ } diff --git a/public/js/FilterWidget.js b/public/js/FilterWidget.js index 60ca22f2f..191b754ab 100644 --- a/public/js/FilterWidget.js +++ b/public/js/FilterWidget.js @@ -22,7 +22,7 @@ function sideMenuHook() filter_id: $(this).attr('value') }, { - successCallback: refreshSideMenu // NOTE: to be checked + successCallback: InfocenterPersonDataset.refreshSideMenu // NOTE: to be checked } ); }); @@ -390,6 +390,9 @@ var FHC_FilterWidget = { }, { successCallback: function(data, textStatus, jqXHR) { + //tablesorter filter local storage clean + $("#filterTableDataset").trigger("filterResetSaved"); + FHC_FilterWidget._resetSelectedFields(); FHC_FilterWidget.renderSelectedFields(); @@ -442,6 +445,9 @@ var FHC_FilterWidget = { }, { successCallback: function(data, textStatus, jqXHR) { + //tablesorter filter local storage clean + $("#filterTableDataset").trigger("filterResetSaved"); + FHC_FilterWidget._resetSelectedFields(); FHC_FilterWidget.renderSelectedFields(); @@ -671,9 +677,19 @@ var FHC_FilterWidget = { && $('#filterTableDataset').hasClass('table-condensed')) { $("#filterTableDataset").tablesorter({ - widgets: ["zebra", "filter"] + widgets: ["zebra", "filter"], + widgetOptions: { + filter_saveFilters : true + } }); + // reset filter storage if there is a filter id in url TODO: find better solution + var filter_id = FHC_AjaxClient.getUrlParameter("filter_id"); + if (typeof filter_id !== 'undefined') + { + $("#filterTableDataset").trigger("filterResetSaved"); + } + var config = $('#filterTableDataset')[0].config; $.tablesorter.updateAll(config, true, null); } @@ -733,7 +749,7 @@ $(document).ready(function() { filter_page: FHC_FilterWidget._getFilterPage() }, { - successCallback: refreshSideMenu // NOTE: to be checked + successCallback: InfocenterPersonDataset.refreshSideMenu // NOTE: to be checked } ); } diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js index 746b61da2..2fd8585f7 100644 --- a/public/js/infocenter/infocenterDetails.js +++ b/public/js/infocenter/infocenterDetails.js @@ -6,9 +6,8 @@ const CALLED_PATH = FHC_JS_DATA_STORAGE_OBJECT.called_path; /** * javascript file for infocenterDetails page */ -$(document).ready( - function () - { +$(document).ready(function () +{ //initialise table sorter Tablesort.addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]); Tablesort.addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]); @@ -209,8 +208,7 @@ var InfocenterDetails = { { FHC_AjaxClient.ajaxCallGet( CALLED_PATH + "/getLastPrestudentWithZgvJson/" + encodeURIComponent(personid), - { - }, + null, { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) @@ -319,13 +317,11 @@ var InfocenterDetails = { { FHC_AjaxClient.ajaxCallGet( CALLED_PATH + "/getStudienjahrEnd", - { - }, + null, { successCallback: function(data, textStatus, jqXHR) { if (data) { - console.log("studienjahr end executed"); var engdate = $.datepicker.parseDate("yy-mm-dd", data); var gerdate = $.datepicker.formatDate("dd.mm.yy", engdate); $("#parkdate").val(gerdate); @@ -339,8 +335,7 @@ var InfocenterDetails = { { FHC_AjaxClient.ajaxCallGet( CALLED_PATH + "/getParkedDate/"+encodeURIComponent(personid), - { - }, + null, { successCallback: function(data, textStatus, jqXHR) { InfocenterDetails._refreshParking(data); diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index 4146edc9b..eb9f0f9c1 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -3,151 +3,129 @@ */ $(document).ready(function() { - appendTableActionsHtml(); + InfocenterPersonDataset.appendTableActionsHtml(); // setTableActions(); }); -/** - * adds person table additional actions html (above and beneath it) - */ -function appendTableActionsHtml() -{ - var currurl = window.location.href; - var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write"); +var InfocenterPersonDataset = { - var formHtml = '
'; - $("#datasetActionsTop").before(formHtml); - - var selectAllHtml = - '' + - ' Alle  ' + - '' + - ' Keinen    '; - - var actionHtml = 'Mit Ausgewählten:  ' + - '' + - ' Nachricht senden'; - - var legendHtml = ' Gesperrt    ' + - ' Geparkt'; - - var personcount = 0; - - $.ajax({ - url: window.location.pathname.replace('infocenter/InfoCenter', 'Filters/rowNumber'), - method: "GET", - data: { - fhc_controller_id: getUrlParameter("fhc_controller_id"), - filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method - }, - dataType: "json" - }) - .done(function(data, textStatus, jqXHR) { - - if (data != null) - { - if (data.rowNumber != null) - { - personcount = data.rowNumber; - - var persontext = personcount === 1 ? "Person" : "Personen"; - var countHtml = personcount + " " + persontext; - - $("#datasetActionsTop, #datasetActionsBottom").append( - "
"+ - "
" + selectAllHtml + "  " + actionHtml + "
"+ - "
" + legendHtml + "
"+ - "
" + countHtml + "
"+ - "
"+ - "
" - ); - $("#datasetActionsBottom").append("

"); - } - - setTableActions(); - } - - }).fail(function(jqXHR, textStatus, errorThrown) { - alert(textStatus); - }); - -} - -/** - * sets functionality for the actions above and beneath the person table - */ -function setTableActions() -{ - $(".sendMsgsLink").click(function() { - var idsel = $("#filterTableDataset input:checked[name=PersonId\\[\\]]"); - if(idsel.length > 0) - { - var form = $("#sendMsgsForm"); - form.find("input[type=hidden]").remove(); - for (var i = 0; i < idsel.length; i++) - { - var id = $(idsel[i]).val(); - form.append(""); - } - form.submit(); - } - }); - - $(".selectAll").click(function() - { - //select only trs if not filtered by tablesorter - var trs = $("#filterTableDataset tbody tr").not(".filtered"); - trs.find("input[name=PersonId\\[\\]]").prop("checked", true); - } - ); - - $(".unselectAll").click(function() - { - var trs = $("#filterTableDataset tbody tr").not(".filtered"); - trs.find("input[name=PersonId\\[\\]]").prop("checked", false); - } - ); -} - -/** - * - */ -function getUrlParameter(sParam) -{ - var sPageURL = decodeURIComponent(window.location.search.substring(1)), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - - for (i = 0; i < sURLVariables.length; i++) + /** + * adds person table additional actions html (above and beneath it) + /* + */ + appendTableActionsHtml: function() { - sParameterName = sURLVariables[i].split('='); + var currurl = window.location.href; + var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write"); - if (sParameterName[0] === sParam) - { - return sParameterName[1]; - } - } -} + var formHtml = '
'; + $("#datasetActionsTop").before(formHtml); -/** - * Refreshes the side menu - */ -function refreshSideMenu() -{ - $.ajax({ - url: window.location.pathname+"/setNavigationMenuArray", - method: "GET", - data: { - fhc_controller_id: getUrlParameter("fhc_controller_id") - } - }) - .done(function(data, textStatus, jqXHR) { + var selectAllHtml = + '' + + ' Alle  ' + + '' + + ' Keinen    '; - FHC_NavigationWidget.renderSideMenu(); + var actionHtml = 'Mit Ausgewählten:  ' + + '' + + ' Nachricht senden'; - }).fail(function(jqXHR, textStatus, errorThrown) { - alert(textStatus); - }); -} + var legendHtml = ' Gesperrt    ' + + ' Geparkt'; + + var personcount = 0; + + FHC_AjaxClient.ajaxCallGet( + 'system/Filters/rowNumber', + { + filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (data != null) + { + if (data.rowNumber != null) + { + personcount = data.rowNumber; + + var persontext = personcount === 1 ? "Person" : "Personen"; + var countHtml = personcount + " " + persontext; + + $("#datasetActionsTop, #datasetActionsBottom").append( + "
"+ + "
" + selectAllHtml + "  " + actionHtml + "
"+ + "
" + legendHtml + "
"+ + "
" + countHtml + "
"+ + "
"+ + "
" + ); + $("#datasetActionsBottom").append("

"); + } + + InfocenterPersonDataset.setTableActions(); + } + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + alert(textStatus); + } + } + ); + }, + + /** + * sets functionality for the actions above and beneath the person table + */ + setTableActions: function() + { + $(".sendMsgsLink").click(function() { + var idsel = $("#filterTableDataset input:checked[name=PersonId\\[\\]]"); + if(idsel.length > 0) + { + var form = $("#sendMsgsForm"); + form.find("input[type=hidden]").remove(); + for (var i = 0; i < idsel.length; i++) + { + var id = $(idsel[i]).val(); + form.append(""); + } + form.submit(); + } + }); + + $(".selectAll").click(function() + { + //select only trs if not filtered by tablesorter + var trs = $("#filterTableDataset tbody tr").not(".filtered"); + trs.find("input[name=PersonId\\[\\]]").prop("checked", true); + } + ); + + $(".unselectAll").click(function() + { + var trs = $("#filterTableDataset tbody tr").not(".filtered"); + trs.find("input[name=PersonId\\[\\]]").prop("checked", false); + } + ); + }, + + /** + * Refreshes the side menu + */ + refreshSideMenu: function() + { + FHC_AjaxClient.ajaxCallGet( + 'system/infocenter/InfoCenter/setNavigationMenuArrayJson', + null, + { + successCallback: function(data, textStatus, jqXHR) { + FHC_NavigationWidget.renderSideMenu(); + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + alert(textStatus); + } + } + ); + } +};