From 5168ed4a33b38d5fc1441a02831d870ca8e37ade Mon Sep 17 00:00:00 2001 From: j Date: Mon, 9 Dec 2019 13:12:44 +0000 Subject: [PATCH] define sections in one location --- static/js/mainMenu.js | 10 ++++------ static/js/pandora.js | 5 +++++ static/js/sectionButtons.js | 6 +----- static/js/sectionSelect.js | 6 +----- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index b53bec0b..58282ecf 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -1647,12 +1647,10 @@ pandora.ui.mainMenu = function() { function getViewMenu() { return { id: 'viewMenu', title: Ox._('View'), items: [ { id: 'section', title: Ox._('Section'), items: [ - { group: 'viewsection', min: 1, max: 1, items: Object.keys(pandora.site.sectionFolders).map(function(section) { - return { - id: section, - title: section == 'items' ? Ox._(pandora.site.itemName.plural) : Ox._(Ox.toTitleCase(section)), - checked: ui.section == section - }; + { group: 'viewsection', min: 1, max: 1, items: pandora.site.sections.map(function(section) { + section = Ox.extend({}, section) + section.checked = section.id == ui.section; + return section; }) } ] }, {}, diff --git a/static/js/pandora.js b/static/js/pandora.js index 0c0f76ba..92f34709 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -395,6 +395,11 @@ appPanel }) ? 'manual' : data.site.layers.some(function(layer) { return layer.hasPlaces; }) ? 'auto' : 'none', + sections: [ + {id: 'items', title: Ox._(pandora.site.itemName.plural)}, + {id: 'edits', title: Ox._('Edits')}, + {id: 'documents', title: Ox._('Documents')} + ], sectionFolders: { items: [ {id: 'personal', title: 'Personal Lists'}, diff --git a/static/js/sectionButtons.js b/static/js/sectionButtons.js index cb0f6093..79d1a1fa 100644 --- a/static/js/sectionButtons.js +++ b/static/js/sectionButtons.js @@ -2,11 +2,7 @@ pandora.ui.sectionButtons = function(section) { var that = Ox.ButtonGroup({ - buttons: [ - {id: 'items', title: Ox._(pandora.site.itemName.plural)}, - {id: 'edits', title: Ox._('Edits')}, - {id: 'documents', title: Ox._('Documents')} - ], + buttons: pandora.site.sections, id: 'sectionButtons', selectable: true, value: section || pandora.user.ui.section diff --git a/static/js/sectionSelect.js b/static/js/sectionSelect.js index af05755f..1abdf825 100644 --- a/static/js/sectionSelect.js +++ b/static/js/sectionSelect.js @@ -4,11 +4,7 @@ pandora.ui.sectionSelect = function(section) { // fixme: duplicated var that = Ox.Select({ id: 'sectionSelect', - items: [ - {id: 'items', title: Ox._(pandora.site.itemName.plural)}, - {id: 'edits', title: Ox._('Edits')}, - {id: 'documents', title: Ox._('Documents')} - ], + items: pandora.site.sections, value: section || pandora.user.ui.section }).css({ float: 'left',