Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

category-list: Separate presentation and control #2588

Merged
merged 6 commits into from
Dec 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
category-list: Support downgrade for panel/label IDs
This allows reading new panel and label IDs of the category-list
from the settings. For instance, `pstate` is interpreted as `flabel_cont`.
TrimmingFool committed Nov 26, 2023
commit b017f1017cd787c7b5a6e4f6c54132dbd71ad0cf
28 changes: 24 additions & 4 deletions js/webui.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,17 @@
* Main object.
*
*/
function mapPanelIdtoLegacyPanelId(panelId) {
return {
psearch: 'flabel',
}[panelId] ?? panelId;
}
function mapPanelIdtoLegacyLabelType(panelId) {
return panelId.endsWith('_cont') ? panelId : mapPanelIdtoLegacyPanelId(panelId) + '_cont';
}
function mapLabelIdToLegacyLabelId(labelId) {
return labelId.startsWith("psearch_") ? "teg_" + labelId.slice(8) : labelId;
}

var theWebUI =
{
@@ -525,9 +536,18 @@ var theWebUI =
const actLbls = this.settings['webui.selected_labels.last'];
for(const [labelType, lbls] of Object.entries(actLbls)) {
// consider legacy single-label selection
this.actLbls[labelType] = Array.isArray(lbls) ? lbls : lbls ? [lbls] : [];
const labelIds = Array.isArray(lbls) ? lbls : lbls ? [lbls] : [];
this.actLbls[mapPanelIdtoLegacyLabelType(labelType)] = labelIds.map(mapLabelIdToLegacyLabelId);
}
}
theWebUI.settings["webui.selected_labels.views"] = theWebUI.settings["webui.selected_labels.views"]
.map(view => ({...view, labels: Object.fromEntries(
Object.entries(view.labels)
.map(([panelId, labelIds]) => [
mapPanelIdtoLegacyLabelType(panelId),
labelIds.map(mapLabelIdToLegacyLabelId)
]))}));

this.adjustViewSelectionToActiveLabels();
this.refreshLabelSelection('pview_cont', ...(this.viewPanelLabelTypes));

@@ -2946,16 +2966,16 @@ var theWebUI =
Object.values(catList.children())
.map(e => [e.id, e])
);

const panelIds = theWebUI.settings['webui.category_panels'].map(mapPanelIdtoLegacyPanelId);
catList[0].replaceChildren(...
theWebUI.settings['webui.category_panels']
panelIds
.filter(panelId => panelId in elements)
.flatMap(panelId => [elements[panelId], elements[`${panelId}_cont`]])
);
},

addPanel: function(id, name) {
const panels = theWebUI.settings['webui.category_panels'];
const panels = theWebUI.settings['webui.category_panels'].map(mapPanelIdtoLegacyPanelId);
if (!panels.includes(id)) {
panels.push(id);
}