From: Lebbeous Fogle-Weekley Date: Tue, 11 Sep 2012 22:34:02 +0000 (-0400) Subject: Change order: filter set loading works. still need saving. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4fcdba76c9d4da7746af6df7f49d88c72423aca7;p=evergreen%2Fequinox.git Change order: filter set loading works. still need saving. Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/templates/url_verify/select_urls.tt2 b/Open-ILS/src/templates/url_verify/select_urls.tt2 index 95c91a1e04..2751e7e3e1 100644 --- a/Open-ILS/src/templates/url_verify/select_urls.tt2 +++ b/Open-ILS/src/templates/url_verify/select_urls.tt2 @@ -37,6 +37,7 @@ autoCoreFields="true" autoCoreFieldsFilter="true" autoCoreFieldsUnsorted="true" + savedFiltersInterface="'url_verify'" fetchLock="true" mapExtras="{session_id: {path: 'session.id', filter: true}}" showLoadFilter="true" diff --git a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js index e97a918dc9..a0756d9ddc 100644 --- a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js @@ -29,6 +29,7 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) { "filterWidgetBuilders": null, "filterSemaphore": null, "filterSemaphoreCallback": null, + "savedFiltersInterface": null, /* These potential constructor arguments may be useful to * FlattenerGrid in their own right, and are passed to @@ -510,10 +511,10 @@ if (!dojo._hasResource["openils.widget.FlattenerGrid"]) { "fmClass": this.fmClass, "mapTerminii": this.mapTerminii, "useDiv": this.filterAlwaysInDiv, - "compact": true, "initializers": this.filterInitializers, "widgetBuilders": this.filterWidgetBuilders, - "suppressFilterFields": this.suppressFilterFields + "suppressFilterFields": this.suppressFilterFields, + "savedFiltersInterface": this.savedFiltersInterface }); this.filterUi.onApply = dojo.hitch( diff --git a/Open-ILS/web/js/dojo/openils/widget/PCrudFilterPane.js b/Open-ILS/web/js/dojo/openils/widget/PCrudFilterPane.js index 205deb4374..08a26413eb 100644 --- a/Open-ILS/web/js/dojo/openils/widget/PCrudFilterPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/PCrudFilterPane.js @@ -35,6 +35,8 @@ if (!dojo._hasResource['openils.widget.PCrudFilterPane']) { dojo.require('openils.widget.AutoFieldWidget'); dojo.require('dijit.form.FilteringSelect'); dojo.require('dijit.form.Button'); + dojo.require('dijit.form.DropDownButton'); + dojo.require('dijit.TooltipDialog'); dojo.require('dojo.data.ItemFileReadStore'); dojo.require('openils.Util'); @@ -570,6 +572,7 @@ if (!dojo._hasResource['openils.widget.PCrudFilterPane']) { }; this.initialize = function(initializer) { + console.log("initializer is " + dojo.toJson(initializer)); this.field_selector.attr("value", initializer.field); this.operator_selector.attr("value", initializer.operator); @@ -593,15 +596,16 @@ if (!dojo._hasResource['openils.widget.PCrudFilterPane']) { { "useDiv": null, /* should always be null for subclass dialogs */ "initializers": null, - "compact": false, "widgetBuilders": null, "suppressFilterFields": null, + "savedFiltersInterface": null, "constructor": function(args) { for(var k in args) this[k] = args[k]; this.widgetIndex = 0; this.widgetCache = {}; + this.compact = Boolean(this.useDiv); /* Meaningless in a pane, but better here than in * PCrudFilterDialog so that we don't need to load i18n @@ -609,6 +613,120 @@ if (!dojo._hasResource['openils.widget.PCrudFilterPane']) { this.title = this.title || pcFilterLocaleStrings.DEFAULT_DIALOG_TITLE; }, + "_buildSavedFilterControlsIfPerms": function(holder) { + (new openils.User()).getPermOrgList( + "SAVED_FILTER_DIALOG_FILTERS", + dojo.hitch(this, function(id_list) { + this._buildSavedFilterControls(id_list, holder); + }), + true, true + ); + }, + + "_buildSavedFilterControls": function(id_list, holder) { + if (!id_list || !id_list.length) { + console.info("Not showing saved filter controls; no perm"); + return; + } + + var fs_list = (new openils.PermaCrud()).search( + "cfdfs", { + "owning_lib": id_list, + "interface": this.savedFiltersInterface + }, { + "order_by": [ + {"class": "cfdfs", "field": "owning_lib"}, + {"class": "cfdfs", "field": "name"} + ], + "async": true, + "oncomplete": dojo.hitch(this, function(r) { + if (r = openils.Util.readResponse(r)) { + this._buildSavedFilterLoader(r, holder); + } + }) + } + ); + + this._buildSavedFilterSaver(holder); + }, + + "_buildSavedFilterLoader": function(fs_list, holder) { + var self = this; + var load_content = dojo.create( + "div", { + "innerHTML": pcFilterLocaleStrings.CHOOSE_FILTER_TO_LOAD + } + ); + + var selector = dojo.create( + "select", { + "multiple": "multiple", + "size": 4, + "style": { + "verticalAlign": "middle", "margin": "0 0.75em" + } + }, load_content, "last" + ); + + dojo.forEach( + fs_list, function(fs) { + dojo.create( + "option", { + "innerHTML": fs.name(), + "value": dojo.toJson([fs.id(), + dojo.fromJson(fs.filters())]) + }, selector + ); + } + ); + + var applicator = dojo.create( + "a", { + "href": "javascript:void(0);", + "onclick": function() { + dojo.filter( + selector.options, + function(o){return o.selected;} + ).map( + function(o){return dojo.fromJson(o.value)[1];} + ).forEach( + function(o){ + o.forEach( + function(p) { + self.filter_row_manager.add_row(p); + } + ); + } + ); + dijit.popup.close(self.filter_set_loader.dropDown); + }, + "innerHTML": pcFilterLocaleStrings.APPLY + }, load_content, "last" + ); + + this.filter_set_loader = new dijit.form.DropDownButton({ + "dropDown": new dijit.TooltipDialog({ + "content": load_content + }), + "label": pcFilterLocaleStrings.LOAD_FILTERS + }, dojo.create("span", {}, holder)); + }, + + "_buildSavedFilterSaver": function(holder) { + + var save = new dijit.TooltipDialog({ + "content": pcFilterLocaleStrings.NAME_SAVED_FILTER_SET + + " " + }); + new dijit.form.DropDownButton( + { + "dropDown": save, + "label": pcFilterLocaleStrings.SAVE_FILTERS + }, dojo.create("button", {}, holder) + ); + + }, + "_buildButtons": function() { var self = this; @@ -649,6 +767,9 @@ if (!dojo._hasResource['openils.widget.PCrudFilterPane']) { }, dojo.create("span", {}, button_holder) ); } + + if (this.savedFiltersInterface) + this._buildSavedFilterControlsIfPerms(button_holder); }, "_buildFieldStore": function() { diff --git a/Open-ILS/web/js/dojo/openils/widget/nls/PCrudFilterPane.js b/Open-ILS/web/js/dojo/openils/widget/nls/PCrudFilterPane.js index 8e76dd59de..7e7128df8d 100644 --- a/Open-ILS/web/js/dojo/openils/widget/nls/PCrudFilterPane.js +++ b/Open-ILS/web/js/dojo/openils/widget/nls/PCrudFilterPane.js @@ -16,5 +16,9 @@ "DEFAULT_DIALOG_TITLE": "Filter Results", "ADD_ROW": "Add Row", "APPLY": "Apply", - "CANCEL": "Cancel" + "CANCEL": "Cancel", + "LOAD_FILTERS": "Load Filters", + "SAVE_FILTERS": "Save Filters", + "CHOOSE_FILTER_TO_LOAD": "Choose filter sets to load", + "NAME_SAVED_FILTER_SET": "Enter a name for your saved filter set:" }