From 087006a7a58b9d699f942305656c18b1ecbf72e5 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Fri, 15 Apr 2022 21:14:42 +0200 Subject: [PATCH] =?UTF-8?q?bugfixes=20issues=20Zust=C3=A4ndigkeiten=20GUI:?= =?UTF-8?q?=20-=20all=20needed=20oe=20kurzbz=20are=20shown=20at=20any=20ti?= =?UTF-8?q?me=20for=20assignment=20-=20only=20functions=20not=20already=20?= =?UTF-8?q?assigned=20are=20shown=20-=20funktion=20can=20only=20be=20enter?= =?UTF-8?q?ed=20after=20oe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/Fehlerzustaendigkeiten_model.php | 28 ++------ .../views/system/issues/issuesData.php | 2 +- public/js/issues/issuesZustaendigkeiten.js | 70 ++++++++++++++----- 3 files changed, 60 insertions(+), 40 deletions(-) diff --git a/application/models/system/Fehlerzustaendigkeiten_model.php b/application/models/system/Fehlerzustaendigkeiten_model.php index 75eb810ea..9277f3609 100644 --- a/application/models/system/Fehlerzustaendigkeiten_model.php +++ b/application/models/system/Fehlerzustaendigkeiten_model.php @@ -35,31 +35,12 @@ class Fehlerzustaendigkeiten_model extends DB_Model } /** - * Gets Organisationseinheiten not assigned to a Fehler. + * Gets Funktionen not assigned to a Fehler (over an organisational unit). * @param $fehlercode + * @param $oe_kurzbz * @return object */ - public function getNonAssignedOes($fehlercode) - { - $query = "SELECT oe_kurzbz, bezeichnung, organisationseinheittyp_kurzbz - FROM public.tbl_organisationseinheit oe - WHERE aktiv - AND NOT EXISTS ( - SELECT 1 FROM system.tbl_fehler_zustaendigkeiten - WHERE oe_kurzbz = oe.oe_kurzbz - AND fehlercode = ? - ) - ORDER BY organisationseinheittyp_kurzbz, bezeichnung"; - - return $this->execReadOnlyQuery($query, array($fehlercode)); - } - - /** - * Gets Funktionen not assigned to a Fehler. - * @param $fehlercode - * @return object - */ - public function getNonAssignedFunktionen($fehlercode) + public function getNonAssignedFunktionen($fehlercode, $oe_kurzbz) { $query = "SELECT funktion_kurzbz, beschreibung FROM public.tbl_funktion funk @@ -68,9 +49,10 @@ class Fehlerzustaendigkeiten_model extends DB_Model SELECT 1 FROM system.tbl_fehler_zustaendigkeiten WHERE funktion_kurzbz = funk.funktion_kurzbz AND fehlercode = ? + AND oe_kurzbz = ? ) ORDER BY beschreibung"; - return $this->execReadOnlyQuery($query, array($fehlercode)); + return $this->execReadOnlyQuery($query, array($fehlercode, $oe_kurzbz)); } } diff --git a/application/views/system/issues/issuesData.php b/application/views/system/issues/issuesData.php index f45bab091..a3b011531 100644 --- a/application/views/system/issues/issuesData.php +++ b/application/views/system/issues/issuesData.php @@ -128,7 +128,7 @@ $filterWidgetArray = array( 'datasetName' => 'issues', 'filter_id' => $this->input->get('filter_id'), 'tableUniqueId' => 'issues', - 'requiredPermissions' => 'admin', + 'requiredPermissions' => 'system/issues_verwalten', 'datasetRepresentation' => 'tablesorter', 'checkboxes' => 'issue_id', 'columnsAliases' => array( diff --git a/public/js/issues/issuesZustaendigkeiten.js b/public/js/issues/issuesZustaendigkeiten.js index 17d1ab101..eec2f75cd 100644 --- a/public/js/issues/issuesZustaendigkeiten.js +++ b/public/js/issues/issuesZustaendigkeiten.js @@ -12,6 +12,7 @@ const FUNKTION_DROPDOWN_ID = "funktionSelect"; var IssuesZustaendigkeiten = { fehlercodesArr: [], // for saving received fehlercodes + oefunktionen: [], // for saving assigned oes and their funktionen getApps: function() { @@ -106,12 +107,14 @@ var IssuesZustaendigkeiten = { { // save loaded data let zustaendigkeitenData = FHC_AjaxClient.getData(data); + // save in object to display correct funktionen when oe is changed + IssuesZustaendigkeiten.oe_funktionen = zustaendigkeitenData.oe_funktionen; let zustaendigkeiten = []; - for (let i = 0; i < zustaendigkeitenData.oe.length; i++) + for (let i = 0; i < zustaendigkeitenData.oe_funktionen.length; i++) { - let zustaendigkeit = zustaendigkeitenData.oe[i]; + let zustaendigkeit = zustaendigkeitenData.oe_funktionen[i]; zustaendigkeiten.push( { @@ -131,13 +134,7 @@ var IssuesZustaendigkeiten = { ); // fill funktion dropdown with data - IssuesZustaendigkeiten._fillDropdown( - "funktionSelect", - "funktion_kurzbz", - zustaendigkeitenData.funktion, - "beschreibung", - true - ); + IssuesZustaendigkeiten._fillFunktionDropdown(); // save Mitarbeiter data for autocomplete field in array let autocompleteMitarbeiterArr = []; @@ -177,7 +174,7 @@ var IssuesZustaendigkeiten = { sourceCallback ); - // set events to delete buttons + // set events on delete buttons $(".deleteBtn").click( function() { @@ -248,6 +245,31 @@ var IssuesZustaendigkeiten = { } ); }, + _fillFunktionDropdown: function() + { + let funktionen = []; + let oe_kurzbz = $("#"+ORGANISATIONSEINHEIT_DROPDOWN_ID).val(); + + // get funktionen for selected oe (saved in js object) + for (let i = 0; i < IssuesZustaendigkeiten.oe_funktionen.length; i++) + { + let oe_funktion = IssuesZustaendigkeiten.oe_funktionen[i]; + + if (oe_funktion.oe_kurzbz === oe_kurzbz) + { + funktionen = oe_funktion.funktionen + break; + } + } + + IssuesZustaendigkeiten._fillDropdown( + "funktionSelect", + "funktion_kurzbz", + funktionen, + "beschreibung", + true + ); + }, _fillDropdown: function(dropdownId, valueName, data, textName, includeNoSelectionOption, defaultValue) { // by default, displayed text in dropdown is the value @@ -296,6 +318,7 @@ var IssuesZustaendigkeiten = { let oeDropdownEl = $("#"+ORGANISATIONSEINHEIT_DROPDOWN_ID); let funktionDropdownEl = $("#"+FUNKTION_DROPDOWN_ID); let maAutocompleteEl = $("#"+MITARBEITER_AUTOCOMPLETE_ID); + let maHiddenEl = $("#"+MITARBEITER_HIDDENFIELD_ID); // if Mitarbeiter is entered if (maAutocompleteEl.val().length > 0) @@ -307,22 +330,29 @@ var IssuesZustaendigkeiten = { } else { - // enable oe and funktion input if Mitarbeiter input empty + // otherwise enable oe and funktion input if Mitarbeiter input empty oeDropdownEl.prop('disabled', false); - funktionDropdownEl.prop('disabled', false); } // if oe or funktion is entered - if (oeDropdownEl.val().length > 0 || funktionDropdownEl.val().length > 0) + if (oeDropdownEl.val().length > 0) { // disable Mitarbeiter input maAutocompleteEl.prop('disabled', true); maAutocompleteEl.val(''); + maHiddenEl.val(''); + + // enable funktion input + funktionDropdownEl.prop('disabled', false); + IssuesZustaendigkeiten._fillFunktionDropdown(); } else { - // enable mitarbeiter input + // otherwise enable mitarbeiter input maAutocompleteEl.prop('disabled', false); + + // disable funktion input + funktionDropdownEl.prop('disabled', true); } }, _emptyInputFields: function() @@ -347,13 +377,21 @@ $(document).ready(function() { $("#"+FEHLERAPP_DROPDOWN_ID).change( function() { - IssuesZustaendigkeiten.getFehlercodes($("#"+FEHLERAPP_DROPDOWN_ID).val()); + IssuesZustaendigkeiten.getFehlercodes($(this).val()); + } + ); + + // get new zustaendigkeiten every time Fehlercode is changed + $("#"+FEHLERCODE_DROPDOWN_ID).change( + function() + { + IssuesZustaendigkeiten.getNonAssignedZustaendigkeiten($(this).val()); } ); // set events for disabling input fields $("#"+MITARBEITER_AUTOCOMPLETE_ID).keyup(IssuesZustaendigkeiten._toggleFieldDisability); - $("#"+ORGANISATIONSEINHEIT_DROPDOWN_ID+", #"+FUNKTION_DROPDOWN_ID).change(IssuesZustaendigkeiten._toggleFieldDisability); + $("#"+ORGANISATIONSEINHEIT_DROPDOWN_ID).change(IssuesZustaendigkeiten._toggleFieldDisability); // set event for adding a new Zuständigkeit $("#assignZustaendigkeit").click(