fix adding/deleting edits via UI

This commit is contained in:
j 2013-06-14 16:35:12 +00:00
parent bd4a76e211
commit 0349ee6f8a
3 changed files with 51 additions and 0 deletions

View file

@ -58,6 +58,9 @@ pandora.UI = (function() {
if (args.section == 'texts') { if (args.section == 'texts') {
trigger['section'] = args['section']; trigger['section'] = args['section'];
trigger['text'] = args['text']; trigger['text'] = args['text'];
} else if (args.section == 'edits') {
trigger['section'] = args['section'];
trigger['edit'] = args['edit'];
} else { } else {
if ('find' in args) { if ('find' in args) {
// the challenge here is that find may change list, // the challenge here is that find may change list,

View file

@ -113,6 +113,34 @@ pandora.ui.folders = function() {
]('deletetext'); ]('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 { } else {
extras = []; extras = [];
} }

View file

@ -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() { pandora.addList = function() {
// addList(isSmart, isFrom) or addList(list) [=duplicate] // addList(isSmart, isFrom) or addList(list) [=duplicate]
var $folderList = pandora.$ui.folderList.personal, var $folderList = pandora.$ui.folderList.personal,