From 0349ee6f8a655ab9e561c1923c4928af76f27dd6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 14 Jun 2013 16:35:12 +0000 Subject: [PATCH] fix adding/deleting edits via UI --- static/js/pandora/UI.js | 3 +++ static/js/pandora/folders.js | 28 ++++++++++++++++++++++++++++ static/js/pandora/utils.js | 20 ++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index a2239051..73b7854c 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -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, diff --git a/static/js/pandora/folders.js b/static/js/pandora/folders.js index b224f2b3..bcccf339 100644 --- a/static/js/pandora/folders.js +++ b/static/js/pandora/folders.js @@ -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 = []; } diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index e8cde7ad..cf85e5c6 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -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,