From ab1578158d220327a96eb045a68dd1a2a759f168 Mon Sep 17 00:00:00 2001 From: rlx Date: Mon, 24 Jun 2019 15:21:59 +0200 Subject: [PATCH] add comments field --- static/js/documentInfoView.savvy.js | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/static/js/documentInfoView.savvy.js b/static/js/documentInfoView.savvy.js index 534156d..373a8a2 100644 --- a/static/js/documentInfoView.savvy.js +++ b/static/js/documentInfoView.savvy.js @@ -368,6 +368,41 @@ pandora.ui.documentInfoView = function(data, isMixed) { .appendTo($statistics); renderRightsLevel(); + // Comments ---------------------------------------------------------------- + + if (canEdit) { + $('
') + .css({marginBottom: '4px'}) + .append( + formatKey('Comments', 'statistics').options({ + tooltip: Ox._('Only {0} can see and edit these comments', [ + Object.keys(pandora.site.capabilities.canEditMetadata).map(function(level, i) { + return ( + i == 0 ? '' + : i < Ox.len(pandora.site.capabilities.canEditMetadata) - 1 ? ', ' + : ' ' + Ox._('and') + ' ' + ) + Ox.toTitleCase(level) + }).join('')]) + }) + ) + .append( + Ox.EditableContent({ + height: 128, + placeholder: formatLight(Ox._(isMixed ? 'Mixed comments' : 'No comments')), + tooltip: pandora.getEditTooltip(), + type: 'textarea', + value: data.comments || '', + width: 128 + }) + .bindEvent({ + submit: function(event) { + editMetadata('comments', event.value); + } + }) + ) + .appendTo($statistics); + } + function editMetadata(key, value) { if (value != data[key]) { var edit = {