From a80c64b8d1e8e5ed1d31da96ce174f2f7f8c90e3 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 8 Mar 2024 13:19:28 +0000 Subject: [PATCH] add user/group to documents --- static/js/documentInfoView.amp.js | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/static/js/documentInfoView.amp.js b/static/js/documentInfoView.amp.js index 00d5a7a..4b7951d 100644 --- a/static/js/documentInfoView.amp.js +++ b/static/js/documentInfoView.amp.js @@ -493,6 +493,58 @@ pandora.ui.documentInfoView = function(data, isMixed) { .appendTo($statistics); renderRightsLevel(); + // User and Groups --------------------------------------------------------- + if (!isMultiple) { + + ['user', 'groups'].forEach(function(key) { + var $input; + (canEdit || data[key] && data[key].length) && $('
') + .css({marginBottom: '4px'}) + .append(formatKey(key, 'statistics')) + .append( + $('
') + .css({margin: '2px 0 0 -1px'}) // fixme: weird + .append( + $input = Ox.Editable({ + placeholder: key == 'groups' ? formatLight(Ox._('No Groups')) : '', + editable: key == 'user' && canEdit, + tooltip: canEdit ? pandora.getEditTooltip() : '', + value: key == 'user' ? data[key] : data[key].join(', ') + }) + .bindEvent(Ox.extend({ + submit: function(event) { + editMetadata(key, event.value); + } + }, key == 'groups' ? { + doubleclick: canEdit ? function() { + setTimeout(function() { + if (window.getSelection) { + window.getSelection().removeAllRanges(); + } else if (document.selection) { + document.selection.empty(); + } + }); + pandora.$ui.groupsDialog = pandora.ui.groupsDialog({ + id: data.id, + name: data.title, + type: 'item' + }) + .bindEvent({ + groups: function(data) { + $input.options({ + value: data.groups.join(', ') + }); + } + }) + .open(); + } : function() {} + } : {})) + ) + ) + .appendTo($statistics); + }); + + function editMetadata(key, value) { if (value != data[key]) { var edit = {