From a9f95f0da736e7bec635b02fb9018e9ebce8e818 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 9 Aug 2021 20:24:31 -0700 Subject: [PATCH] Improved tagging dialog. --- views/default.handlebars | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/views/default.handlebars b/views/default.handlebars index be44bda3..d62d5c31 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -5152,6 +5152,14 @@ var x = "Perform batch device tag operation" + '

'; x += addHtmlValue("Operation", ''); x += addHtmlValue("Tags", ''); + // Get a list of all possible device tags + var allTags = [], y = ''; + for (var i in nodes) { if (nodes[i].tags) { for (var j in nodes[i].tags) { if (allTags.indexOf(nodes[i].tags[j]) == -1) { allTags.push(nodes[i].tags[j]); } } } } + if (allTags.length > 0) { + allTags.sort(); + for (var i in allTags) { y += '' + EscapeHtml(allTags[i]) + ''; } + x += '
' + addHtmlValue("Existing Tags", y); + } setDialogMode(2, "Edit Device Tags", 3, d2groupActionFunctionTagsExec, x); } else if (op == 108) { // Device notification @@ -7675,6 +7683,16 @@ function showEditNodeValueDialog(mode) { if (xxdialogMode) return; var x = addHtmlValue(showEditNodeValueDialog_modes[mode], ''); + if (mode == 3) { + // Get a list of all possible device tags + var allTags = [], y = ''; + for (var i in nodes) { if (nodes[i].tags) { for (var j in nodes[i].tags) { if (allTags.indexOf(nodes[i].tags[j]) == -1) { allTags.push(nodes[i].tags[j]); } } } } + if (allTags.length > 0) { + allTags.sort(); + for (var i in allTags) { y += '' + EscapeHtml(allTags[i]) + ''; } + x += '
' + addHtmlValue("Existing Tags", y); + } + } setDialogMode(2, "Edit Device", 3, showEditNodeValueDialogEx, x, mode); var v = currentNode[showEditNodeValueDialog_modes2[mode]]; if (v == null) v = ''; @@ -7684,6 +7702,14 @@ Q('dp10devicevalue').focus(); } + function showEditNodeValueDialogAddTag(t) { + var tt = Q('dp10devicevalue').value.split(','), t2 = []; + for (var i in tt) { t2.push(tt[i].trim()); } + if (t2.indexOf(t) >= 0) return; + Q('dp10devicevalue').value += ((Q('dp10devicevalue').value.length == 0)?'':', ') + decodeURIComponent(t); + p10editdevicevalueValidate(); + } + function showEditNodeValueDialogEx(button, mode) { var x = { action: 'changedevice', nodeid: currentNode._id }; x[showEditNodeValueDialog_modes2[mode]] = Q('dp10devicevalue').value;