mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-22 03:20:54 -03:00
feat(ui): add group-by-model toggle to global context menu
Adds a 'Group by Model' toggle entry to the right-click global context menu for quick access, complementing the existing setting in Settings → Layout Settings. The menu item shows a checkmark indicator reflecting the current state and immediately reloads the view on toggle. Also fixes he.json translation that was mojibake (garbled characters). Includes: - Context menu HTML item with check-indicator - JS toggle logic via settingsManager - i18n for all 10 locales - Hebrew translation fix
This commit is contained in:
@@ -24,6 +24,14 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
const cleanupExamplesItem = this.menu.querySelector('[data-action="cleanup-example-images-folders"]');
|
||||
const excludedModelsItem = this.menu.querySelector('[data-action="manage-excluded-models"]');
|
||||
const repairRecipesItem = this.menu.querySelector('[data-action="repair-recipes"]');
|
||||
const groupByModelItem = this.menu.querySelector('[data-action="toggle-group-by-model"]');
|
||||
const groupByModelCheck = groupByModelItem?.querySelector('.check-indicator');
|
||||
|
||||
// Update check indicator for group-by-model
|
||||
if (groupByModelCheck) {
|
||||
const isEnabled = !!state.global.settings.group_by_model;
|
||||
groupByModelCheck.style.display = isEnabled ? 'block' : 'none';
|
||||
}
|
||||
|
||||
if (isRecipesPage) {
|
||||
modelUpdateItem?.classList.add('hidden');
|
||||
@@ -31,6 +39,7 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
downloadExamplesItem?.classList.add('hidden');
|
||||
cleanupExamplesItem?.classList.add('hidden');
|
||||
excludedModelsItem?.classList.add('hidden');
|
||||
groupByModelItem?.classList.add('hidden');
|
||||
repairRecipesItem?.classList.remove('hidden');
|
||||
} else {
|
||||
modelUpdateItem?.classList.remove('hidden');
|
||||
@@ -38,6 +47,7 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
downloadExamplesItem?.classList.remove('hidden');
|
||||
cleanupExamplesItem?.classList.remove('hidden');
|
||||
excludedModelsItem?.classList.remove('hidden');
|
||||
groupByModelItem?.classList.remove('hidden');
|
||||
repairRecipesItem?.classList.add('hidden');
|
||||
}
|
||||
|
||||
@@ -74,6 +84,9 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
case 'manage-excluded-models':
|
||||
this.manageExcludedModels();
|
||||
break;
|
||||
case 'toggle-group-by-model':
|
||||
this.toggleGroupByModel();
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unhandled global context menu action: ${action}`);
|
||||
break;
|
||||
@@ -86,6 +99,25 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
});
|
||||
}
|
||||
|
||||
toggleGroupByModel() {
|
||||
const sm = window.settingsManager;
|
||||
if (!sm) {
|
||||
console.error('settingsManager not available on window');
|
||||
return;
|
||||
}
|
||||
const newValue = !state.global.settings.group_by_model;
|
||||
state.global.settings.group_by_model = newValue;
|
||||
|
||||
sm.saveSetting('group_by_model', newValue).catch((error) => {
|
||||
console.error('Failed to save group_by_model setting:', error);
|
||||
// Revert state on failure
|
||||
state.global.settings.group_by_model = !newValue;
|
||||
});
|
||||
|
||||
sm.applyFrontendSettings();
|
||||
sm.reloadContent();
|
||||
}
|
||||
|
||||
async downloadExampleImages(menuItem) {
|
||||
const downloadPath = state?.global?.settings?.example_images_path;
|
||||
if (!downloadPath) {
|
||||
|
||||
Reference in New Issue
Block a user