CAT-188 catalog fixes search templates
authorKatlyn Beck <kbeck@catalyte.io>
Wed, 24 Oct 2018 21:23:17 +0000 (21:23 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
- Added template name input, save button, and delete button
- Adjusted getSearchStash() to parse JSON
- Added templateActionSave function to call create_template using browser specific variables
- Added templateActionDelete function to mirror desktop functionality
- Added functions to save to localStorage in place of file storage

Signed-off-by: Katlyn Beck <kbeck@catalyte.io>
 Changes to be committed:
modified:   KCLS/openils/var/templates_kcls/opac/parts/advanced/search.tt2
modified:   Open-ILS/web/js/ui/kcls/conify/global/config/search_templates.js

KCLS/openils/var/templates_kcls/opac/parts/advanced/search.tt2
Open-ILS/web/js/ui/kcls/conify/global/config/search_templates.js

index 9133c82..4d01c1c 100644 (file)
                     <strong>[% l('Template Name') %]</strong>
                     <br>
                     <input id="nameInput" type="text">
-                    <button style="padding-left:5px;" onClick="templateActionSave();">[% l('Save Template') %]</button>
+                    <button type="button" style="padding-left:5px;" onClick="templateActionSave();">[% l('Save Template') %]</button>
                     <br><br>
-                    <button onClick="templateActionDelete();">[% l('Delete Template') %]</button>
+                    <button type="button" onClick="templateActionDelete();">[% l('Delete Template') %]</button>
                 </td>
                 <td valign="top" class="hide_me">
                     <select id="resultViewSel" name="detail_record_view" >
index 0208227..99e1a23 100644 (file)
@@ -48,6 +48,7 @@ function templateActionSave() {
     create_template(nameInput);
 }
 
+// Removes template from templateList and localStorage if it exists and if user wants it deleted
 function templateActionDelete() {
     var nameInput = document.getElementById('nameInput').value;
     var templateList = getSearchStash();
@@ -55,6 +56,7 @@ function templateActionDelete() {
     if (tempTemplate) {
         if (confirm("Are you sure you want to delete Template '" + nameInput + "'?")) {
             deleteTemplatefromTemplateList(nameInput, templateList);
+            populateTemplateOptions(templateList);
         }
     } else {
         alert("Template '" + nameInput + "' does not exist.");
@@ -257,6 +259,12 @@ function getFilterValues()   {
     return filters;
 }
 
+// Takes name of selected template and adds to Template Name input field
+function populateTemplateNameValue(tName) {
+    var target = document.getElementById('nameInput');
+    target.value = tName;
+}
+
 //Select the apropriate search options given a search template
 function populateSearchOptions(template) {
     setFilterValues(template);
@@ -311,6 +319,7 @@ function selectSearchTemplateOrClear(tName) {
 //Populates options, or not, accordingly. Then clears search text fields
 function selectSearchTemplateOrClearAll(tName)  {
     selectSearchTemplateOrClear(tName);
+    populateTemplateNameValue(tName);
     clearGlobalRowInputs();
     clearPubDateInputs();
 }