add ui for lists/edits/collections groups

This commit is contained in:
j 2018-03-06 15:11:05 +05:30
parent 5201341085
commit 859a820c90
5 changed files with 106 additions and 25 deletions

View file

@ -350,7 +350,6 @@ class Edit(models.Model):
'description', 'description',
'duration', 'duration',
'editable', 'editable',
'editable',
'groups', 'groups',
'id', 'id',
'items', 'items',

View file

@ -15,7 +15,7 @@ pandora.ui.folderList = function(id, section) {
columns = [ columns = [
{ {
clickable: function(data) { clickable: function(data) {
return data.user == pandora.user.username return data.editable
|| (id == 'featured' && canEditFeatured); || (id == 'featured' && canEditFeatured);
}, },
format: function(value, data) { format: function(value, data) {
@ -31,7 +31,7 @@ pandora.ui.folderList = function(id, section) {
id: 'user', id: 'user',
operator: '+', operator: '+',
tooltip: function(data) { tooltip: function(data) {
return data.user == pandora.user.username return data.editable
|| (id == 'featured' && canEditFeatured) || (id == 'featured' && canEditFeatured)
? Ox._('Edit Icon') ? Ox._('Edit Icon')
: ''; : '';
@ -52,7 +52,7 @@ pandora.ui.folderList = function(id, section) {
}, },
{ {
editable: function(data) { editable: function(data) {
return data.user == pandora.user.username; return data.editable;
}, },
format: function(value) { format: function(value) {
return Ox.encodeHTMLEntities(value); return Ox.encodeHTMLEntities(value);
@ -81,7 +81,7 @@ pandora.ui.folderList = function(id, section) {
{ {
clickable: function(data) { clickable: function(data) {
return section != 'texts' && ( return section != 'texts' && (
data.type == 'smart' || data.user == pandora.user.username data.type == 'smart' || data.editable
); );
}, },
format: function(value, data) { format: function(value, data) {
@ -98,16 +98,16 @@ pandora.ui.folderList = function(id, section) {
width: '10px', width: '10px',
height: '10px', height: '10px',
padding: '3px', padding: '3px',
opacity: section == 'texts' || data.user == pandora.user.username ? 1 : 0.25 opacity: section == 'texts' || data.editable ? 1 : 0.25
}); });
}, },
id: 'type', id: 'type',
operator: '+', operator: '+',
tooltip: function(data) { tooltip: function(data) {
return data.type == 'static' return data.type == 'static'
? (data.user == pandora.user.username ? Ox._('Edit {0}', [Ox._(folderItem)]) : '') ? (data.editable ? Ox._('Edit {0}', [Ox._(folderItem)]) : '')
: data.type == 'smart' : data.type == 'smart'
? (data.user == pandora.user.username ? Ox._('Edit Query') : Ox._('Show Query')) ? (data.editable ? Ox._('Edit Query') : Ox._('Show Query'))
: data.type.toUpperCase(); : data.type.toUpperCase();
}, },
visible: true, visible: true,
@ -264,7 +264,7 @@ pandora.ui.folderList = function(id, section) {
columns: columns, columns: columns,
droppable: id != 'volumes', droppable: id != 'volumes',
items: items, items: items,
keys: ['modified'].concat(section != 'texts' keys: ['modified', 'editable', 'groups'].concat(section != 'texts'
? ['query', 'name', 'view'] : ['rightslevel']), ? ['query', 'name', 'view'] : ['rightslevel']),
max: 1, max: 1,
min: 0, min: 0,

View file

@ -36,13 +36,18 @@ pandora.ui.groupsDialog = function(options) {
groups, groups,
selectedGroups; selectedGroups;
pandora.api[isItem ? 'get' : 'getUser']({ if (options.groups) {
id: options.id, selectedGroups = options.groups;
keys: ['groups']
}, function(result) {
selectedGroups = result.data.groups;
renderGroups(); renderGroups();
}); } else {
pandora.api[isItem ? 'get' : 'getUser']({
id: options.id,
keys: ['groups']
}, function(result) {
selectedGroups = result.data.groups;
renderGroups();
});
}
function addGroup() { function addGroup() {
// disableElements(); // disableElements();

View file

@ -266,6 +266,67 @@ pandora.ui.listGeneralPanel = function(listData) {
) )
.css({position: 'absolute', left: '160px', top: '64px'}) .css({position: 'absolute', left: '160px', top: '64px'})
.appendTo(that), .appendTo(that),
$groupsInput = Ox.Input({
disabled: false,
label: Ox._('Groups'),
labelWidth: 80,
value: listData.groups.join(', '),
width: 320
})
.bindEvent({
change: editGroups
})
.css({position: 'absolute', left: '160px', top: '88px'})
.appendTo(that),
/*
$groupsLabel,
$groupsInput = Ox.FormElementGroup({
elements: [
Ox.Label({
overlap: 'right',
textAlign: 'right',
title: Ox._('Groups'),
width: 80
}),
Ox.FormElementGroup({
elements: [
$groupsLabel = Ox.Label({
title: listData.groups ? listData.groups.join(', ') : '',
width: 224
}),
Ox.Button({
overlap: 'left',
title: 'edit',
tooltip: Ox._('Edit Groups'),
type: 'image'
})
.bindEvent({
click: function() {
console.log(listData)
pandora.$ui.groupsDialog = pandora.ui.groupsDialog({
id: listData.id,
name: listData.id,
groups: listData.groups,
type: 'list'
})
.bindEvent({
groups: function(data) {
var groups = data.groups.join(', ');
//fixme edit groups
$groupsLabel.options({title: groups});
}
})
.open();
}
})
],
float: 'right'
})
],
float: 'left'
}).css({position: 'absolute', left: '160px', top: '88px'})
.appendTo(that),
*/
$subscribersInput = Ox.Input({ $subscribersInput = Ox.Input({
disabled: true, disabled: true,
label: Ox._('Subscribers'), label: Ox._('Subscribers'),
@ -273,7 +334,7 @@ pandora.ui.listGeneralPanel = function(listData) {
value: subscribers, value: subscribers,
width: 320 width: 320
}) })
.css({position: 'absolute', left: '160px', top: '88px'}) .css({position: 'absolute', left: '160px', top: '112px'})
[getSubscribersAction()]() [getSubscribersAction()]()
.appendTo(that), .appendTo(that),
$descriptionInput = Ox.Input({ $descriptionInput = Ox.Input({
@ -321,6 +382,19 @@ pandora.ui.listGeneralPanel = function(listData) {
}); });
} }
} }
function editGroups(data) {
var groups = data.value.split(', ');
console.log(groups);
pandora.api['edit' + folderItem]({
id: listData.id,
groups: groups
}, function(result) {
listData.groups = result.data.groups;
pandora.$ui.folderList[listData.folder].value(
result.data.id, 'groups', listData.groups
);
});
}
function editStatus(data) { function editStatus(data) {
var status = data.value; var status = data.value;
$statusSelect.value(status == 'private' ? 'public' : 'private'); $statusSelect.value(status == 'private' ? 'public' : 'private');
@ -368,10 +442,10 @@ pandora.ui.listGeneralPanel = function(listData) {
}); });
} }
function getDescriptionHeight() { function getDescriptionHeight() {
return listData.status == 'private' ? 184 : 160; return (listData.status == 'private' ? 184 : 160) - 24;
} }
function getDescriptionTop() { function getDescriptionTop() {
return listData.status == 'private' ? 88 : 112; return (listData.status == 'private' ? 88 : 112) + 24;
} }
function getSubscribersAction() { function getSubscribersAction() {
return listData.status == 'private' ? 'hide' : 'show'; return listData.status == 'private' ? 'hide' : 'show';

View file

@ -714,7 +714,7 @@ pandora.enableDragAndDrop = function($list, canMove, section, getItems) {
data = $list.value(id); data = $list.value(id);
if (drag.targets) { if (drag.targets) {
drag.targets[id] = Ox.extend({ drag.targets[id] = Ox.extend({
editable: data.user == pandora.user.username editable: data.editable
&& data.type == 'static', && data.type == 'static',
selected: $item.is('.OxSelected') selected: $item.is('.OxSelected')
}, data); }, data);
@ -828,8 +828,10 @@ pandora.enableDragAndDrop = function($list, canMove, section, getItems) {
operator: '&' operator: '&'
} }
}, function(result) { }, function(result) {
var folder = drag.target.status != 'featured' var folder = drag.target.status == 'featured' ? 'featured' : (
? 'personal' : 'featured'; drag.target.user == pandora.user.username
? 'personal' : 'favorite'
);
pandora.$ui.folderList[folder].value( pandora.$ui.folderList[folder].value(
drag.target.id, 'items', result.data.items drag.target.id, 'items', result.data.items
); );
@ -938,7 +940,7 @@ pandora.enableDragAndDrop = function($list, canMove, section, getItems) {
); );
} else if ( } else if (
drag.action == 'move' drag.action == 'move'
&& drag.source.user != pandora.user.username && !drag.source.editable
) { ) {
image = 'symbolClose'; image = 'symbolClose';
text = Ox._( text = Ox._(
@ -951,7 +953,7 @@ pandora.enableDragAndDrop = function($list, canMove, section, getItems) {
'You can\'t remove {0}<br>from smart {1}.', 'You can\'t remove {0}<br>from smart {1}.',
[itemName.plural, targetName.plural] [itemName.plural, targetName.plural]
); );
} else if (drag.target && drag.target.user != pandora.user.username) { } else if (drag.target && !drag.target.editable) {
image = 'symbolClose'; image = 'symbolClose';
text = Ox._( text = Ox._(
'You can only {0} {1}<br>to your own {2}', 'You can only {0} {1}<br>to your own {2}',
@ -1726,9 +1728,10 @@ pandora.getListData = function(list) {
if (folder) { if (folder) {
data = pandora.$ui.folderList[folder].value(list); data = pandora.$ui.folderList[folder].value(list);
if (pandora.user.ui.section == 'item') { if (pandora.user.ui.section == 'item') {
data.editable = data.user == pandora.user.username && data.type == 'static'; data.editable = data.editable && data.type == 'static';
} else { } else {
data.editable = data.user == pandora.user.username; data.editable = data.editable || data.user == pandora.user.username;
} }
data.folder = folder; data.folder = folder;
} }