From 2e985d173352487f96984577ac512a3639267edf Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 11:34:57 +0300 Subject: move some label helper functions to prefLabelTree --- js/PrefLabelTree.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 7321b80d8..c4c3ea103 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -37,7 +37,60 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f getIconClass: function (item, opened) { return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, - }); + getSelectedLabels: function() { + const tree = dijit.byId("labelTree"); + const items = tree.model.getCheckedItems(); + const rv = []; + + items.each(function(item) { + rv.push(tree.model.store.getValue(item, 'bare_id')); + }); + + return rv; + }, + resetColors: function() { + const labels = this.getSelectedLabels(); + + if (labels.length > 0) { + if (confirm(__("Reset selected labels to default colors?"))) { + + const query = { + op: "pref-labels", method: "colorreset", + ids: labels.toString() + }; + + xhrPost("backend.php", query, () => { + updateLabelList(); + }); + } + + } else { + alert(__("No labels are selected.")); + } + }, + removeSelected: function() { + const sel_rows = this.getSelectedLabels(); + + if (sel_rows.length > 0) { + if (confirm(__("Remove selected labels?"))) { + notify_progress("Removing selected labels..."); + + const query = { + op: "pref-labels", method: "remove", + ids: sel_rows.toString() + }; + + xhrPost("backend.php", query, () => { + updateLabelList(); + }); + } + } else { + alert(__("No labels are selected.")); + } + + return false; + } +}); }); -- cgit v1.2.3 From 60cd4676943169a057518634e3060745e9112511 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 11:50:53 +0300 Subject: embed some pref-feed helper functions into the tree --- js/PrefLabelTree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index c4c3ea103..e5eb595e5 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -38,7 +38,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, getSelectedLabels: function() { - const tree = dijit.byId("labelTree"); + const tree = this; const items = tree.model.getCheckedItems(); const rv = []; -- cgit v1.2.3 From f26d404890a55a34ed5779b6f36e949d38705e8d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 12:03:28 +0300 Subject: prefs: move other tree-related functions to respective trees --- js/PrefLabelTree.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index e5eb595e5..ba052eb07 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -48,6 +48,69 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return rv; }, + editLabel: function(id) { + const query = "backend.php?op=pref-labels&method=edit&id=" + + param_escape(id); + + if (dijit.byId("labelEditDlg")) + dijit.byId("labelEditDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "labelEditDlg", + title: __("Label Editor"), + style: "width: 600px", + setLabelColor: function (id, fg, bg) { + + let kind = ''; + let color = ''; + + if (fg && bg) { + kind = 'both'; + } else if (fg) { + kind = 'fg'; + color = fg; + } else if (bg) { + kind = 'bg'; + color = bg; + } + + const e = $("LICID-" + id); + + if (e) { + if (fg) e.style.color = fg; + if (bg) e.style.backgroundColor = bg; + } + + const query = { + op: "pref-labels", method: "colorset", kind: kind, + ids: id, fg: fg, bg: bg, color: color + }; + + xhrPost("backend.php", query, () => { + updateFilterList(); // maybe there's labels in there + }); + + }, + execute: function () { + if (this.validate()) { + const caption = this.attr('value').caption; + const fg_color = this.attr('value').fg_color; + const bg_color = this.attr('value').bg_color; + + dijit.byId('labelTree').setNameById(id, caption); + this.setLabelColor(id, fg_color, bg_color); + this.hide(); + + xhrPost("backend.php", this.attr('value'), () => { + updateFilterList(); // maybe there's labels in there + }); + } + }, + href: query + }); + + dialog.show(); + }, resetColors: function() { const labels = this.getSelectedLabels(); -- cgit v1.2.3 From 3a6dae92034791c199f9ddb4c60b8298b22c1d47 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 16:29:00 +0300 Subject: prefs: more of the same, really --- js/PrefLabelTree.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index ba052eb07..45edb34a1 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -48,6 +48,12 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return rv; }, + reload: function() { + xhrPost("backend.php", { op: "pref-labels" }, (transport) => { + dijit.byId('labelConfigTab').attr('content', transport.responseText); + notify(""); + }); + }, editLabel: function(id) { const query = "backend.php?op=pref-labels&method=edit&id=" + param_escape(id); @@ -87,7 +93,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateFilterList(); // maybe there's labels in there + dijit.byId("filterTree").reload(); // maybe there's labels in there }); }, @@ -102,7 +108,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f this.hide(); xhrPost("backend.php", this.attr('value'), () => { - updateFilterList(); // maybe there's labels in there + dijit.byId("filterTree").reload(); // maybe there's labels in there }); } }, @@ -123,7 +129,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateLabelList(); + this.reload(); }); } @@ -144,7 +150,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateLabelList(); + this.reload(); }); } } else { -- cgit v1.2.3 From 35ded4bc844d74f120196012c194be9ab5517688 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 16:30:32 +0300 Subject: edit phrasing of some alert()s --- js/PrefLabelTree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 45edb34a1..914df9a19 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -134,7 +134,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f } } else { - alert(__("No labels are selected.")); + alert(__("No labels selected.")); } }, removeSelected: function() { @@ -154,7 +154,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }); } } else { - alert(__("No labels are selected.")); + alert(__("No labels selected.")); } return false; -- cgit v1.2.3 From d9c5c93cef313127b9b5010fbe279fdbddedadec Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 20:07:57 +0300 Subject: move some more stuff out of common.js rework client-side cookie functions a bit limit dojo cachebust based on server scripts modification time remove param_escape() --- js/PrefLabelTree.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 914df9a19..abe79a114 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -56,7 +56,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }, editLabel: function(id) { const query = "backend.php?op=pref-labels&method=edit&id=" + - param_escape(id); + encodeURIComponent(id); if (dijit.byId("labelEditDlg")) dijit.byId("labelEditDlg").destroyRecursive(); -- cgit v1.2.3 From 526389b2d380177490605037fdc3a24ebc688fac Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 20:56:30 +0300 Subject: update notify_* calls to use Notify --- js/PrefLabelTree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/PrefLabelTree.js') diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index abe79a114..f808e987b 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -51,7 +51,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f reload: function() { xhrPost("backend.php", { op: "pref-labels" }, (transport) => { dijit.byId('labelConfigTab').attr('content', transport.responseText); - notify(""); + Notify.close(); }); }, editLabel: function(id) { @@ -142,7 +142,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f if (sel_rows.length > 0) { if (confirm(__("Remove selected labels?"))) { - notify_progress("Removing selected labels..."); + Notify.progress("Removing selected labels..."); const query = { op: "pref-labels", method: "remove", -- cgit v1.2.3