luci-base: ui.js: mark user-changed widgets
authorJo-Philipp Wich <jo@mein.io>
Thu, 19 Sep 2019 13:39:46 +0000 (15:39 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 19 Sep 2019 13:39:46 +0000 (15:39 +0200)
Set a `data-changed=true` attribute on the widget element when the user
did any change to the default value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/ui.js

index c0b57528fbe6f21fa6629bf9cbe08204e4c17e6a..99e1548a4367c38d9c1dc2d14f011503180c6398 100644 (file)
@@ -70,6 +70,11 @@ var UIElement = L.Class.extend({
        },
 
        setChangeEvents: function(targetNode /*, ... */) {
+               var tag_changed = L.bind(function(ev) { this.setAttribute('data-changed', true) }, this.node);
+
+               for (var i = 1; i < arguments.length; i++)
+                       targetNode.addEventListener(arguments[i], tag_changed);
+
                this.registerEvents(targetNode, 'widget-change', this.varargs(arguments, 1));
        }
 });