From e1045eed9e761e7bf61e4df93452e51dc2dcccce Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 5 Oct 2018 00:28:38 -0600 Subject: [PATCH] Replace cat and loc search boxes with select dropdowns (#11) --- action.php | 6 ++++- langs/en/categories.json | 3 ++- langs/en/core.json | 4 ++- langs/en/items.json | 1 - langs/en/locations.json | 3 ++- pages/edititem.php | 26 ++++++++++++++++--- static/js/edititem.js | 56 ++-------------------------------------- 7 files changed, 36 insertions(+), 63 deletions(-) diff --git a/action.php b/action.php index 72f6b23..07e31d6 100644 --- a/action.php +++ b/action.php @@ -202,8 +202,12 @@ switch ($VARS['action']) { } returnToSender("invalid_parameters"); case "autocomplete_category": - exit(json_encode($database->select('categories', ['catid (id)', 'catname (name)'], ['catname[~]' => $VARS['q'], 'LIMIT' => 10]))); + header("Content-Type: application/json"); + $q = (empty($VARS['q']) ? "" : $VARS['q']); + exit(json_encode($database->select('categories', ['catid (id)', 'catname (name)'], ['catname[~]' => $q, 'LIMIT' => 10]))); case "autocomplete_location": + header("Content-Type: application/json"); + $q = (empty($VARS['q']) ? "" : $VARS['q']); exit(json_encode($database->select('locations', ['locid (id)', 'locname (name)'], ["OR" => ['locname[~]' => $VARS['q'], 'loccode' => $VARS['q']], 'LIMIT' => 10]))); case "autocomplete_user": header("Content-Type: application/json"); diff --git a/langs/en/categories.json b/langs/en/categories.json index 4c96ea4..1e324a3 100644 --- a/langs/en/categories.json +++ b/langs/en/categories.json @@ -1,5 +1,6 @@ { "New Category": "New Category", "editing category": "Editing {cat}", - "Adding new category": "Adding new category" + "Adding new category": "Adding new category", + "Choose a category": "Choose a category" } diff --git a/langs/en/core.json b/langs/en/core.json index 5e55996..639d829 100644 --- a/langs/en/core.json +++ b/langs/en/core.json @@ -22,5 +22,7 @@ "login server error": "The login server returned an error: {arg}", "login server user data error": "The login server refused to provide account information. Try again or contact technical support.", "captcha error": "There was a problem with the CAPTCHA (robot test). Try again.", - "no access permission": "You do not have permission to access this system." + "no access permission": "You do not have permission to access this system.", + "no permission": "You do not have permission to access this system.", + "no edit permission": "You do not have permission to modify records." } diff --git a/langs/en/items.json b/langs/en/items.json index 0b2ec79..2bfc451 100644 --- a/langs/en/items.json +++ b/langs/en/items.json @@ -7,7 +7,6 @@ "Adding Item": "Adding new item", "editing item": "Editing {item}", "cloning item": "Copying {oitem} {nitem}", - "item saved": "Item Saved", "itemid": "Item ID", "id": "ID" } diff --git a/langs/en/locations.json b/langs/en/locations.json index 14eb88b..9bb705c 100644 --- a/langs/en/locations.json +++ b/langs/en/locations.json @@ -1,5 +1,6 @@ { "new location": "New Location", "Adding new location": "Adding new location", - "editing location": "Editing {loc}" + "editing location": "Editing {loc}", + "Choose a location": "Choose a location" } diff --git a/pages/edititem.php b/pages/edititem.php index 825db81..b388aa8 100644 --- a/pages/edititem.php +++ b/pages/edititem.php @@ -104,15 +104,33 @@ if (!empty($VARS['id'])) {
- " value="" /> - +
- " value="" /> - +
diff --git a/static/js/edititem.js b/static/js/edititem.js index 2eaae9b..fa5d5a2 100644 --- a/static/js/edititem.js +++ b/static/js/edititem.js @@ -2,59 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -$("#cat").easyAutocomplete({ - url: "action.php", - ajaxSettings: { - dataType: "json", - method: "GET", - data: { - action: "autocomplete_category" - } - }, - preparePostData: function (data) { - data.q = $("#cat").val(); - return data; - }, - getValue: function (element) { - return element.name; - }, - list: { - onSelectItemEvent: function () { - var catid = $("#cat").getSelectedItemData().id; - $("#realcat").val(catid).trigger("change"); - }, - match: { - enabled: true - } - } -}); -$("#loc").easyAutocomplete({ - url: "action.php", - ajaxSettings: { - dataType: "json", - method: "GET", - data: { - action: "autocomplete_location" - } - }, - preparePostData: function (data) { - data.q = $("#loc").val(); - return data; - }, - getValue: function (element) { - return element.name; - }, - list: { - onSelectItemEvent: function () { - var locid = $("#loc").getSelectedItemData().id; - $("#realloc").val(locid).trigger("change"); - }, - match: { - enabled: true - } - } -}); - $("#assignedto").easyAutocomplete({ url: "action.php", ajaxSettings: { @@ -81,4 +28,5 @@ $("#assignedto").easyAutocomplete({ $('#name').on('input propertychange paste', function () { $('#name_title').text($('#name').val()); -}); \ No newline at end of file +}); +