From: Justin Douma Date: Thu, 17 Jan 2013 00:16:58 +0000 (-0800) Subject: Search Templates: Allows staff to create and save default searches X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c0c0a3d5334de64be59af4f0532fc55415fb13c7;p=working%2FEvergreen.git Search Templates: Allows staff to create and save default searches Allows staff to create templates for advanced search page. Templates can save any option available on the Advanced Search page but will not save text inputs. Templates are saved to the users workstation. Templates can be created and saved, or deleted, at Admin->Workstation Administration-> Search Templates. Signed-off-by: Justin Douma --- diff --git a/Open-ILS/src/templates/conify/global/config/search_templates.tt2 b/Open-ILS/src/templates/conify/global/config/search_templates.tt2 new file mode 100644 index 0000000000..017fe6a533 --- /dev/null +++ b/Open-ILS/src/templates/conify/global/config/search_templates.tt2 @@ -0,0 +1,286 @@ +[% WRAPPER base.tt2 %] +[% INCLUDE 'opac/parts/js.tt2' %] +[% + PROCESS "opac/parts/config.tt2"; +%] + + + + + + + + +
+

[% l('Search Settings') %]

+
+ +
+

[% l('Current Template') %]

+ +
+
+
+
+ + [% l('Template Name') %] +
+ + + + + + + + +
+ + + +
+ +
+
+
+ + + + [% INCLUDE "opac/parts/advanced/global_row.tt2" %] + + +
+ +
+ + +[% + in_row = 0; + FOR adv_chunk IN search.adv_config; + NEXT IF adv_chunk.adv_hide; + IF in_row == 0; + in_row = 1; %] + +[% + END; %] + [% IF adv_chunk.adv_attr.size || adv_chunk.adv_filter.size; %] + + [% END; %] + [% IF adv_chunk.adv_break; + in_row = 0; %] + + [% END; %] + [% END; %] + + + + + + + + + + + + + +
+ [% adv_chunk.adv_label %] +
+ +
+ [% l('Search Library') %] +
+ +
+ [% l('Publication Date') %] +
+ +
+ [% l('Search Results') %] +
+ +
+ [% l('Result View') %] +
+ +
+ + [% l('Limit to Available') %] +
+ +
+ +
+ +
+ + + + + +[% END %] diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 index e90b6d3c1e..aaec5d394b 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 @@ -32,7 +32,7 @@
[% l('Search Filters') %]
- +
[% in_row = 0; FOR adv_chunk IN search.adv_config; @@ -49,7 +49,7 @@ SWITCH adv_chunk.adv_special; CASE "lib_selector"; PROCESS "opac/parts/org_selector.tt2"; - INCLUDE build_org_selector show_loc_groups=1; %] + INCLUDE build_org_selector show_loc_groups=1 id='org_selector'; %]
[% CASE "pub_year"; %] - + - [% l("and") %] + [% l("and") %]
[% CASE "sort_selector"; INCLUDE "opac/parts/filtersort.tt2" - value=CGI.param('sort') class='results_header_sel'; + value=CGI.param('sort') class='results_header_sel' id='opac.result.sort'; END; ELSIF adv_chunk.adv_attr; INCLUDE "opac/parts/coded_value_selector.tt2" @@ -101,6 +101,22 @@ END; %]
+ [% IF ctx.is_staff && search.allow_templates == 'true' %] + +
[% l('Search Templates') %]
+
+ [% l('Select Template') %] +
+ + + + + + [% END %] @@ -110,6 +126,38 @@ +[% IF ctx.is_staff && search.allow_templates == 'true' %] +[% l('Clear Form') %] + +[% IF ctx.is_staff && search.allow_templates == 'true' %] + + + + + + + +[% END %] diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2 index b0fee8f9a3..78d73cf6ec 100644 --- a/Open-ILS/src/templates/opac/parts/config.tt2 +++ b/Open-ILS/src/templates/opac/parts/config.tt2 @@ -127,5 +127,13 @@ search.basic_config = { group => ['mattype','item_type'], none_label => l("All Formats"), }; +############################################################################## +# This will allow the display and use of a Search Template dropdown that +# staff may use to select often used searches. Upon selection of a Template, the +# Advanced Search page's Global Rows and Search Filters will populate according +# to the Template. Templates are configurable at +# Admin->WorkStation Administraion->Search Templates + +search.allow_templates = 'true'; %] diff --git a/Open-ILS/web/js/ui/default/conify/global/config/search_templates.js b/Open-ILS/web/js/ui/default/conify/global/config/search_templates.js new file mode 100644 index 0000000000..fee3a64fbf --- /dev/null +++ b/Open-ILS/web/js/ui/default/conify/global/config/search_templates.js @@ -0,0 +1,426 @@ + + + var g = {}; + var templateList; + var template; + var DEFAULT = "--Default--" + +function getSearchStash() { + try + { + if (typeof JSAN == 'undefined') + { + throw( document.getElementById("commonStrings").getString('common.jsan.missing') ); + } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); + g.error = new util.error(); + g.error.sdump('D_TRACE','getSearchStash() from search_settings.tt2 or search.tt2'); + + JSAN.use('OpenILS.data'); + g.data = new OpenILS.data(); + g.data.stash_retrieve(); + + //populate templateList, or not. + if (g.data.search_templates) + { + templateList = g.data.search_templates; + + //check for current template + if (g.data.current_search_template) + { + template = g.data.current_search_template; + } + } + else + { + templateList = new Array(); + } + } catch(E) { + try { g.error.standard_unexpected_error_alert('search_settings.tt2',E); } catch(F) { alert(E); } + return 0; + } +} + +//Creates, or edits, a search template based off the currently selected values +function create_template(tName) { + var template; + if (!tName || tName == DEFAULT) + { + alert("That is not a valid name."); + return; + } + template = getTemplateByName(tName, templateList); + + if (template == null) + { + var isNew = 1; + template = new Object(); + populateTemplate(template); + this.template = template; + templateList.push(template); + templateList.sort(compareTemplateNames) + } + else + { + if (confirm("Do you want to overwrite " + template.name + " template?")) + { + populateTemplate(template); + this.template = template; + } + else + { return;} + } + saveCurrentTemplate( template ); + saveTemplateList(templateList); + + //Add to templateSel and select if new template + if(isNew) + { + populateTemplateOptions(templateList); + selectOptionValue(templateSel, template.name); + } +} + +//Returns the selected values of of a given element +function getSelectedValues(elmnt) { +elmntVals = []; + var x = 0; + for (x=0;x templateB.name) + { return 1; } + else + { return 0; } +} + +//removes a template from the templateList object +function deleteTemplatefromTemplateList(tName, templateList) { + var index = getTemplateIndex(tName, templateList); + templateList.splice(index,1); + saveTemplateList(templateList); + return templateList; +} + +//Removes template from templateList and saved file if it exists and user wants it deleted +function removeTemplate(templateList, currentTemplate) { + var tempTemplate = getTemplateByName(textIn.value, templateList); + if (tempTemplate) + { + if(confirm("Are you sure you want to delete Template '" + tempTemplate.name + "'?")) + { + deleteTemplatefromTemplateList(tempTemplate.name, templateList); + populateTemplateOptions(templateList); + + //deleted template is the current template in use + if (currentTemplate.name == tempTemplate.name) + { + saveCurrentTemplate(null); + clearOptions(); + templateSel.selectedIndex = 0; + } + else + { + selectOptionValue(templateSel, currentTemplate.name); + } + textIn.value = ""; + } + else { + return; + } + } + else { + alert("Template '" + textIn.value + "' does not exist."); + } +} +//caches templateList and saves to file for posterity +function saveTemplateList(templateList) { + g.data.search_templates = templateList; + g.data.stash('search_templates'); + saveTemplateListToFile(templateList); +} + +//caches template currently in use and saves it to file +function saveCurrentTemplate(template) { + g.data.current_search_template = template; + g.data.stash('current_search_template'); + saveCurrentTemplateToFile(template) +} + +//clears all global row input fields +function clearGlobalRowInputs() { + var tBody = document.getElementById("adv_global_tbody"); + if(tBody) + { + var rows = tBody.getElementsByTagName("tr"); + if(rows.length > 0) + for (var i=0; i 0) { + inputs[0].value = ''; + } + } + } +} +//clears input fields associated with the pubdate +function clearPubDateInputs() + { + document.getElementById("adv_global_pub_date_1_input").value = ''; + document.getElementById("adv_global_pub_date_2_input").value = ''; + } diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 70063d8ae5..78990687de 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -2086,6 +2086,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index fc17229959..b7fe0b4fc2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -515,6 +515,35 @@ OpenILS.data.prototype = { } file.close(); + JSAN.use('util.file'); var file = new util.file('yesterdays_search_template'); + if (file._file.exists()) { + try { + var x = file.get_content(); + if (x && x != "null") { + obj.current_search_template = JSON.parse(x); + obj.stash('current_search_template'); + obj.data_progress('Saved current search template retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); + + JSAN.use('util.file'); var file = new util.file('search_templates'); + if (file._file.exists()) { + try { + var x = file.get_content(); + if (x) { + obj.search_templates = JSON.parse(x); + obj.stash('search_templates'); + obj.data_progress('Saved search templates retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); obj.print_list_defaults(); obj.data_progress('Default print templates set. '); obj.load_saved_print_templates(); diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index f94e9ed435..68ad136b42 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -703,6 +703,12 @@ main.menu.prototype = { ['oncommand'], function(event) { open_admin_page('font_settings.xul', 'menu.cmd_local_admin_fonts_and_sounds.tab', false, event); } ], + 'cmd_local_admin_search_templates' : [ + ['oncommand'], + function(event) { + open_eg_web_page('conify/global/config/search_templates', 'menu.cmd_local_admin_search_templates.tab', event); + } + ], 'cmd_local_admin_printer' : [ ['oncommand'], function(event) { open_admin_page('printer_settings.xul', 'menu.cmd_local_admin_printer.tab', false, event); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 2e984d7102..c31a23085d 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -118,6 +118,7 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 2405b95450..7ed5be7fcf 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -229,6 +229,7 @@ list.dump_extended_format.record_separator==-=-= list.line_number=# menu.cmd_survey_wizard.inadequate_perm=You are lacking the CREATE_SURVEY permission and/or working locations. menu.cmd_local_admin_fonts_and_sounds.tab=Global Font and Sound Settings +menu.cmd_local_admin_search_templates.tab=Search Templates menu.cmd_local_admin_printer.tab=Printer Settings Editor menu.cmd_local_admin_do_not_auto_attempt_print_setting.tab='Do Not Attempt Auto-Print' Setting menu.cmd_local_admin_closed_dates.tab=Closed Dates Editor diff --git a/docs/RELEASE_NOTES_NEXT/search_templates.txt b/docs/RELEASE_NOTES_NEXT/search_templates.txt new file mode 100644 index 0000000000..f762db52a4 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/search_templates.txt @@ -0,0 +1,33 @@ +New Feature: Search Templates +=============================== + +Allows staff to create 'Search Templates' which will save commonly used +search combinations for tpac Advanced Search page. All selectable +options available on the Advanced Search page, as well as whether +results display in 'Detail View', can be saved. Search terms will not +be savable. + +Search Templates Creation page + +A Search Templates Creation page will be created that mocks the +Advanced Search page in the opac/tpac. Also available on this page would +be a dropdown list of saved Search Templates, a textbox for entering +template names, a 'Save Template' button, and a 'Delete Template' +button. Staff will be able to select commonly used search option +pairings and save them to a template on their workstation. Search +Templates would be saved to file as a JSON object. Staff would be able +to delete unused templates. A new menu option would be created in Admin +-> WorkStation Administration called 'Search Templates'. This will take +you to the Search Templates creation page. TPAC Advanced Search page. + +A Search Templates dropdown will be available to staff, but not patrons, +from which they can select from their saved Search Templates. + +When selected, a Search Template will populate the search options +according to the options saved to that template. + +The selected template will be remembered and will populate the search +options upon returning to the Advanced Search page. + +A 'Default' template will also be available that 'turns off' Search +Templates and reverts to Default Evergreen functionality.