UI for editing component parameters now correctly highlights the background of requir...
[arvados.git] / apps / workbench / app / assets / javascripts / editable.js
index 804eeb2d8fab23006ac9a75159183a90547766cc..9418fb2e0d6dfb3a368a710085b8f2a6816591d6 100644 (file)
@@ -1,5 +1,6 @@
 $.fn.editable.defaults.ajaxOptions = {type: 'put', dataType: 'json'};
 $.fn.editable.defaults.send = 'always';
+//$.fn.editable.defaults.mode = 'inline';
 $.fn.editable.defaults.params = function (params) {
     var a = {};
     var key = params.pk.key;
@@ -7,4 +8,36 @@ $.fn.editable.defaults.params = function (params) {
     a[key] = {};
     a[key][params.name] = params.value;
     return a;
-};
\ No newline at end of file
+};
+
+(function() {
+    $.fn.editable.defaults.success = function (response, newValue) {
+        var tag = $(this);
+        if (tag.hasClass("required")) {
+            if (newValue && newValue.trim() != "") {
+                tag.parent().css("background-color", "");
+                tag.parent().prev().css("background-color", "");
+            }
+            else {
+                tag.parent().css("background-color", "#ffdddd");
+                tag.parent().prev().css("background-color", "#ffdddd");
+            }
+        }
+    }
+
+    $(window).on('load', function() {
+        var a = $('a.editable.required');
+        for (var i = 0; i < a.length; i++) {
+            var tag = $(a[i]);
+            if (tag.hasClass("editable-empty")) {
+                tag.parent().css("background-color", "#ffdddd");
+                tag.parent().prev().css("background-color", "#ffdddd");
+            }
+            else {
+                tag.parent().css("background-color", "");
+                tag.parent().prev().css("background-color", "");
+            }
+        }
+    } );
+
+})();