fix collection dubplication

This commit is contained in:
j 2020-01-18 00:08:20 +01:00
parent 7fa2a8a338
commit addce75323
3 changed files with 37 additions and 11 deletions

View file

@ -391,7 +391,7 @@ pandora.ui.folderList = function(id, section) {
},
key_control_d: function() {
if (that.options('selected').length) {
pandora.addFolderItem(ui.section, ui._list);
pandora.addFolderItem(ui.section, ui.section == 'documents' ? ui._collection : ui._list);
}
},
key_control_e: function() {

View file

@ -52,13 +52,13 @@ pandora.ui.folders = function(section) {
[Ox._(folderItem)]),
keyboard: 'shift control n',
disabled: ui.section == 'documents'
? ui.collectionSelection == 0
? ui.collectionSelection.length == 0
: ui.listSelection.length == 0
},
{ id: 'newsmartlist', title: Ox._('New Smart {0}', [Ox._(folderItem)]), keyboard: 'alt control n' },
{ id: 'newsmartlistfromresults', title: Ox._('New Smart {0} from Results', [Ox._(folderItem)]), keyboard: 'shift alt control n' },
{},
{ id: 'duplicatelist', title: Ox._('Duplicate Selected {0}', [Ox._(folderItem)]), keyboard: 'control d', disabled: !ui._list },
{ id: 'duplicatelist', title: Ox._('Duplicate Selected {0}', [Ox._(folderItem)]), keyboard: 'control d', disabled: ui.section == 'documents' ? !ui._collection : !ui._list },
{ id: 'editlist', title: Ox._('Edit Selected {0}...', [Ox._(folderItem)]), keyboard: 'control e', disabled: !editable },
{ id: 'deletelist', title: Ox._('Delete Selected {0}...', [Ox._(folderItem)]), keyboard: 'delete', disabled: !editable }
],
@ -75,13 +75,18 @@ pandora.ui.folders = function(section) {
], data.id)) {
pandora.addList(data.id.indexOf('smart') > -1, data.id.indexOf('from') > -1);
} else if (data.id == 'duplicatelist') {
pandora.addList(ui._list);
pandora.addList(ui.section == 'documents' ? ui._collection : ui._list);
} else if (data.id == 'editlist') {
pandora.ui.listDialog().open();
} else if (data.id == 'deletelist') {
pandora.ui.deleteListDialog().open();
}
},
pandora_collectionselection: function(data) {
pandora.$ui.personalListsMenu[
data.value.length ? 'enableItem' : 'disableItem'
]('newlistfromselection');
},
pandora_find: function() {
// fixme: duplicated
var action = ui._list
@ -96,6 +101,20 @@ pandora.ui.folders = function(section) {
ui.listSelection.length ? 'enableItem' : 'disableItem'
]('newlistfromselection');
},
pandora_finddocuments: function() {
// fixme: duplicated
var action = ui._collection
&& pandora.getListData(ui._collection).user == pandora.user.username
? 'enableItem' : 'disableItem'
pandora.$ui.personalListsMenu[
ui._collection ? 'enableItem' : 'disableItem'
]('duplicatelist');
pandora.$ui.personalListsMenu[action]('editlist');
pandora.$ui.personalListsMenu[action]('deletelist');
pandora.$ui.personalListsMenu[
ui.collectionSelection.length ? 'enableItem' : 'disableItem'
]('newlistfromselection');
},
pandora_listselection: function(data) {
pandora.$ui.personalListsMenu[
data.value.length ? 'enableItem' : 'disableItem'

View file

@ -81,18 +81,28 @@ pandora.addFolderItem = function(section) {
data.description = result.data.items[0].description;
if (data.type == 'static') {
var query;
if (isItems) {
if (Ox.contains(['items', 'documents'], section)) {
query = {
conditions: [{
key: 'list',
key: {
items: 'list',
documents: 'collection'
}[section],
operator: '==',
value: list
}],
operator: '&'
};
pandora.api.find({query: query}, function(result) {
pandora.api[{
items: 'find',
documents: 'findDocuments'
}[section]]({query: query}, function(result) {
if (result.data.items) {
pandora.api.find({
pandora.api[{
items: 'find',
documents: 'findDocuments'
}[section]]({
query: query,
keys: ['id'],
sort: [{key: 'id', operator: ''}],
@ -107,9 +117,6 @@ pandora.addFolderItem = function(section) {
addList();
}
});
} else if(section == 'documents') {
//fixme
addList();
} else {
pandora.api.getEdit({
id: list,