fix adding/deleting edits via UI
This commit is contained in:
parent
bd4a76e211
commit
0349ee6f8a
3 changed files with 51 additions and 0 deletions
|
@ -58,6 +58,9 @@ pandora.UI = (function() {
|
|||
if (args.section == 'texts') {
|
||||
trigger['section'] = args['section'];
|
||||
trigger['text'] = args['text'];
|
||||
} else if (args.section == 'edits') {
|
||||
trigger['section'] = args['section'];
|
||||
trigger['edit'] = args['edit'];
|
||||
} else {
|
||||
if ('find' in args) {
|
||||
// the challenge here is that find may change list,
|
||||
|
|
|
@ -113,6 +113,34 @@ pandora.ui.folders = function() {
|
|||
]('deletetext');
|
||||
})
|
||||
];
|
||||
} else if(ui.section == 'edits') {
|
||||
extras = [
|
||||
pandora.$ui.personalListsMenu = Ox.MenuButton({
|
||||
items: [
|
||||
{ id: 'newedit', title: Ox._('New Edit') },
|
||||
{},
|
||||
{ id: 'deleteedit', title: Ox._('Delete Selected Edit...'), disabled: !ui.text }
|
||||
],
|
||||
title: 'edit',
|
||||
tooltip: Ox._('Manage Personal Edits'),
|
||||
type: 'image'
|
||||
})
|
||||
.bindEvent({
|
||||
click: function(data) {
|
||||
var $list = pandora.$ui.folderList[folder.id];
|
||||
if (data.id == 'newedit') {
|
||||
pandora.addEdit();
|
||||
} else if (data.id == 'deleteedit') {
|
||||
pandora.ui.deleteListDialog().open();
|
||||
}
|
||||
}
|
||||
})
|
||||
.bindEvent('pandora_edit', function(data) {
|
||||
pandora.$ui.personalListsMenu[
|
||||
data.value && data.value.length ? 'enableItem' : 'disableItem'
|
||||
]('deleteedit');
|
||||
})
|
||||
];
|
||||
} else {
|
||||
extras = [];
|
||||
}
|
||||
|
|
|
@ -12,6 +12,26 @@ pandora.addItem = function() {
|
|||
});
|
||||
};
|
||||
|
||||
pandora.addEdit = function(options) {
|
||||
var $folderList = pandora.$ui.folderList.personal;
|
||||
options = options || {};
|
||||
pandora.api.addEdit(options, function(result) {
|
||||
reloadFolder(result.data.id);
|
||||
});
|
||||
function reloadFolder(newId) {
|
||||
pandora.$ui.folder[0].options({collapsed: false});
|
||||
Ox.Request.clearCache('findEdits');
|
||||
$folderList.bindEventOnce({
|
||||
load: function(data) {
|
||||
$folderList.gainFocus()
|
||||
.options({selected: [newId]})
|
||||
.editCell(newId, 'name', true);
|
||||
pandora.UI.set(pandora.user.ui.section.slice(0, -1), newId);
|
||||
}
|
||||
}).reloadList();
|
||||
}
|
||||
}
|
||||
|
||||
pandora.addList = function() {
|
||||
// addList(isSmart, isFrom) or addList(list) [=duplicate]
|
||||
var $folderList = pandora.$ui.folderList.personal,
|
||||
|
|
Loading…
Reference in a new issue