Fix tests to work with new css/layout.
[arvados.git] / apps / workbench / app / assets / javascripts / editable.js
index e37b9444c1615bfd10ce760fa3934f0ab7e76c0d..24da2866d7118852bb34fe68d8eed87f5e740dff 100644 (file)
@@ -1,4 +1,4 @@
-$.fn.editable.defaults.ajaxOptions = {type: 'put', dataType: 'json'};
+$.fn.editable.defaults.ajaxOptions = {type: 'post', dataType: 'json'};
 $.fn.editable.defaults.send = 'always';
 
 // Default for editing is popup.  I experimented with inline which is a little
@@ -13,8 +13,13 @@ $.fn.editable.defaults.params = function (params) {
     var a = {};
     var key = params.pk.key;
     a.id = params.pk.id;
-    a[key] = {};
+    a[key] = params.pk.defaults || {};
     a[key][params.name] = params.value;
+    if (params.pk._method) {
+        a['_method'] = params.pk._method;
+    } else {
+        a['_method'] = 'put';
+    }
     return a;
 };
 
@@ -23,3 +28,19 @@ $.fn.editable.defaults.validate = function (value) {
         return "Invalid selection";
     }
 }
+
+$(document).
+    on('ready ajax:complete', function() {
+        $('#editable-submit').click(function() {
+            console.log($(this));
+        });
+    });
+
+$.fn.editabletypes.text.defaults.tpl = '<input type="text" name="editable-text">'
+
+$.fn.editableform.buttons = '\
+<button type="submit" class="btn btn-primary btn-sm editable-submit" \
+  id="editable-submit"><i class="glyphicon glyphicon-ok"></i></button>\
+<button type="button" class="btn btn-default btn-sm editable-cancel" \
+  id="editable-cancel"><i class="glyphicon glyphicon-remove"></i></button>\
+'