X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c0c0d769cd812e87efa392649380dc5ba8a25cd4..bfd5100c4e0bed1910875099937169f1b0c8ce7b:/apps/workbench/app/assets/javascripts/editable.js diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js index 0514c1e67f..dc54bda7af 100644 --- a/apps/workbench/app/assets/javascripts/editable.js +++ b/apps/workbench/app/assets/javascripts/editable.js @@ -41,10 +41,9 @@ $.fn.editable.defaults.validate = function (value) { $(document). on('ready ajax:complete', function() { - $('#editable-submit').click(function() { - console.log($(this)); - }); $('.editable'). + not('.editable-done-setup'). + addClass('editable-done-setup'). editable({ success: function(response, newValue) { // If we just created a new object, stash its UUID @@ -56,7 +55,25 @@ $(document). if (response.href) { $(this).editable('option', 'url', response.href); } + if ($(this).attr('data-name')) { + var textileAttr = $(this).attr('data-name') + 'Textile'; + if (response[textileAttr]) { + $(this).attr('data-textile', response[textileAttr]); + } + } return; + }, + error: function(response, newValue) { + var errlist = response.responseJSON.errors; + var errmsg; + if (Array.isArray(errlist)) { + errmsg = errlist.join(); + } else { + errmsg = ("The server returned an error when making " + + "this update (status " + response.status + + ": " + errlist + ")."); + } + return errmsg; } }). on('hidden', function(e, reason) { @@ -64,6 +81,10 @@ $(document). // information if it appears elsewhere on the page. if (reason != 'save') return; var html = $(this).html(); + if( $(this).attr('data-textile') ) { + html = $(this).attr('data-textile'); + $(this).html(html); + } var uuid = $(this).attr('data-object-uuid'); var attr = $(this).attr('data-name'); var edited = this; @@ -75,6 +96,15 @@ $(document). }); } }); + }). + on('ready ajax:complete', function() { + $("[data-toggle~='x-editable']"). + not('.editable-done-setup'). + addClass('editable-done-setup'). + click(function(e) { + e.stopPropagation(); + $($(this).attr('data-toggle-selector')).editable('toggle'); + }); }); $.fn.editabletypes.text.defaults.tpl = ''