diff --git a/static/js/documentsPanel.js b/static/js/documentsPanel.js index d421010b0..4cc8c8f3f 100644 --- a/static/js/documentsPanel.js +++ b/static/js/documentsPanel.js @@ -310,7 +310,7 @@ pandora.ui.documentsPanel = function(options) { $preview, - $form, + $data, $itemStatusbar = Ox.Bar({size: 16}) .css({textAlign: 'center'}), @@ -492,101 +492,162 @@ pandora.ui.documentsPanel = function(options) { }); } - function renderForm() { - var item = $list.value($list.options('selected')[0]), + function renderData() { + var $title, $description, + item = $list.value($list.options('selected')[0]), editable = item.user == pandora.user.username || pandora.site.capabilities.canEditDocuments[pandora.user.level], - inputWidth = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE, - labelWidth = 80; - return Ox.Form({ - items: [ - Ox.Input({ - disabled: !editable, - id: 'name', - label: Ox._('Name'), - labelWidth: labelWidth, - value: item.name, - width: inputWidth - }), - Ox.Input({ - disabled: true, - id: 'extension', - label: Ox._('Extension'), - labelWidth: labelWidth, - value: item.extension, - width: inputWidth - }), - Ox.Input({ - disabled: true, - id: 'dimensions', - label: Ox._('Dimensions'), - labelWidth: labelWidth, - value: Ox.isArray(item.dimensions) - ? Ox.formatDimensions(item.dimensions, 'px') - : Ox.formatCount(item.dimensions, 'page'), - width: inputWidth - }), - Ox.Input({ - disabled: true, - id: 'size', - label: Ox._('Size'), - labelWidth: labelWidth, - value: Ox.formatValue(item.size, 'B'), - width: inputWidth - }), - Ox.Input({ - disabled: true, - id: 'matches', - label: Ox._('Matches'), - labelWidth: labelWidth, - value: item.matches, - width: inputWidth - }), - Ox.Input({ - disabled: true, - id: 'username', - label: Ox._('Username'), - labelWidth: labelWidth, - value: item.user, - width: inputWidth - }), - Ox.Input({ - disabled: !editable, - id: 'type', - label: Ox._('Type'), - labelWidth: labelWidth, - value: item.type, - width: inputWidth - }), - Ox.Input({ - disabled: !editable, - height: 256, - id: 'description', - placeholder: Ox._('Description'), - type: 'textarea', - value: item.description, - width: inputWidth - }) - ], - width: 240 - }) - .css({margin: '12px 8px 8px 8px'}) - .bindEvent({ - change: function(event) { - var data = Ox.extend({id: item.id}, event.id, event.data.value); - if (isItemView) { - data.item = ui.item; - } - pandora.api.editDocument(data, function(result) { - $list.value(result.data.id, event.id, result.data[event.id]); - if (event.id == 'name') { - $list.value(item.id, 'id', result.data.id); + labelWidth = 80, + width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE; + return isItemView + ? Ox.Element() + .append( + Ox.$('