From be27aa820870e47d0d59549d56af0318af1a6dfe Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 18 Jan 2014 00:43:50 +0000 Subject: [PATCH] documents panel: make title editable --- static/js/documentsPanel.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index 86a0825a..9d8e87f1 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -474,7 +474,7 @@ pandora.ui.documentsPanel = function(options) { } function renderData() { - var $title, $description, + var $name, $description, item = $list.value($list.options('selected')[0]), editable = item.user == pandora.user.username || pandora.site.capabilities.canEditDocuments[pandora.user.level], @@ -482,28 +482,36 @@ pandora.ui.documentsPanel = function(options) { width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE; return isItemView ? Ox.Element() + .css({textAlign: 'center'}) .append( - Ox.$('
').css({height: '16px'}) + Ox.$('
').css({height: '8px'}) ) .append( - $title = Ox.EditableContent({ - editable: false, + $name = Ox.EditableContent({ + editable: editable, value: item.name, width: width }) .css({ - margin: '0 4px', textAlign: 'center', fontWeight: 'bold' }) .bindEvent({ edit: function() { - $title.options({ + $name.options({ width: that.width() }); }, - submit: function() { - // ... + submit: function(data) { + pandora.api.editDocument({ + name: data.value, + id: item.id, + item: ui.item, + }, function(result) { + $name.options({value: result.data.name}); + Ox.Request.clearCache('findDocuments'); + $list.reloadList(); + }); } }) ) @@ -512,6 +520,7 @@ pandora.ui.documentsPanel = function(options) { ) .append( $description = Ox.EditableContent({ + editable: editable, format: function(value) { return '
' + value + '
'; @@ -523,7 +532,7 @@ pandora.ui.documentsPanel = function(options) { width: width }) .css({ - marginLeft: '8px', + margin: '0 8px', textAlign: 'center' }) .bindEvent({