Improved device tagging on mobile site.

Ylian Saint-Hilaire committed Aug 9, 2021 at 20:35 UTC 58bf8100fa8b702c8bd90af83521ffe6732b87a7
1 file changed +18
views/default-mobile.handlebars
+18
@@ -3857,6 +3857,16 @@
3857 function showEditNodeValueDialog(mode) {
3858 if (xxdialogMode) return;
3859 var x = addHtmlValue(showEditNodeValueDialog_modes[mode], '<input id=dp10devicevalue style=width:170px maxlength=64 placeholder="' + showEditNodeValueDialog_modes3[mode] + '" onchange=p10editdevicevalueValidate(' + mode + ',event) onkeyup=p10editdevicevalueValidate(' + mode + ',event) />');
3860 + if (mode == 3) {
3861 + // Get a list of all possible device tags
3862 + var allTags = [], y = '';
3863 + 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]); } } } }
3864 + if (allTags.length > 0) {
3865 + allTags.sort();
3866 + for (var i in allTags) { y += '<span style=padding:4px;background-color:#BBB;border-radius:3px;margin:3px;cursor:pointer onclick=showEditNodeValueDialogAddTag("' + encodeURIComponentEx(allTags[i]) + '")>' + EscapeHtml(allTags[i]) + '</span>'; }
3867 + x += '<div style=height:8px></div>' + y;
3868 + }
3869 + }
3870 setDialogMode(2, "Edit Device", 3, showEditNodeValueDialogEx, x, mode);
3871 var v = currentNode[showEditNodeValueDialog_modes2[mode]];
3872 if (v == null) v = '';
@@ -3866,6 +3876,14 @@
3876 Q('dp10devicevalue').focus();
3877 }
3878
3879 + function showEditNodeValueDialogAddTag(t) {
3880 + var tt = Q('dp10devicevalue').value.split(','), t2 = [];
3881 + for (var i in tt) { t2.push(tt[i].trim()); }
3882 + if (t2.indexOf(t) >= 0) return;
3883 + Q('dp10devicevalue').value += ((Q('dp10devicevalue').value.length == 0) ? '' : ', ') + decodeURIComponent(t);
3884 + p10editdevicevalueValidate();
3885 + }
3886 +
3887 function showEditNodeValueDialogEx(button, mode) {
3888 var x = { action: 'changedevice', nodeid: currentNode._id };
3889 x[showEditNodeValueDialog_modes2[mode]] = Q('dp10devicevalue').value;