mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 12:30:24 +00:00
feat: add quick commands settings
This commit is contained in:
parent
2c811673c3
commit
3ecda83c1a
3 changed files with 70 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ export const DEFAULT_SETTINGS: NoteStatusSettings = {
|
|||
tagPrefix: 'obsidian-note-status',
|
||||
strictStatuses: false, // Default to show all statuses from frontmatter
|
||||
excludeUnknownStatus: true, // Default to exclude unknown status files for better performance
|
||||
quickStatusCommands: ['active', 'completed'], // Add default quick commands
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export class NoteStatusSettingsUI {
|
|||
this.renderUISettings(containerEl, settings);
|
||||
this.renderTagSettings(containerEl, settings);
|
||||
this.renderCustomStatusSettings(containerEl, settings);
|
||||
this.renderQuickCommandsSettings(containerEl, settings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -168,6 +169,73 @@ export class NoteStatusSettingsUI {
|
|||
.addToggle(toggle => toggle
|
||||
.setValue(settings.strictStatuses || false)
|
||||
.onChange(value => this.callbacks.onSettingChange('strictStatuses', value)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the quick commands configuration section
|
||||
*/
|
||||
private renderQuickCommandsSettings(containerEl: HTMLElement, settings: any): void {
|
||||
new Setting(containerEl)
|
||||
.setName('Quick status commands')
|
||||
.setDesc('Select which statuses should have dedicated commands in the command palette. These can be assigned hotkeys for quick access.')
|
||||
.setHeading();
|
||||
|
||||
const quickCommandsContainer = containerEl.createDiv({ cls: 'quick-commands-container' });
|
||||
|
||||
// Get all available statuses from service
|
||||
const allStatuses = this.getAllAvailableStatuses(settings);
|
||||
const currentQuickCommands = settings.quickStatusCommands || [];
|
||||
|
||||
allStatuses.forEach(status => {
|
||||
const setting = new Setting(quickCommandsContainer)
|
||||
.setName(`${status.icon} ${status.name}`)
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(currentQuickCommands.includes(status.name))
|
||||
.onChange(async (value) => {
|
||||
const updatedCommands = value
|
||||
? [...currentQuickCommands.filter((cmd: string) => cmd !== status.name), status.name]
|
||||
: currentQuickCommands.filter((cmd: string) => cmd !== status.name);
|
||||
|
||||
await this.callbacks.onSettingChange('quickStatusCommands', updatedCommands);
|
||||
}));
|
||||
|
||||
if (status.description) {
|
||||
setting.setDesc(status.description);
|
||||
}
|
||||
});
|
||||
|
||||
if (allStatuses.length === 0) {
|
||||
quickCommandsContainer.createDiv({
|
||||
text: 'No statuses available. Enable templates or add custom statuses first.',
|
||||
cls: 'setting-item-description'
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get all available statuses from templates and custom statuses
|
||||
*/
|
||||
private getAllAvailableStatuses(settings: any): Array<{name: string, icon: string, description?: string}> {
|
||||
const statuses: Array<{name: string, icon: string, description?: string}> = [];
|
||||
|
||||
// Add custom statuses
|
||||
statuses.push(...settings.customStatuses);
|
||||
|
||||
// Add template statuses if not using custom only
|
||||
if (!settings.useCustomStatusesOnly) {
|
||||
for (const templateId of settings.enabledTemplates) {
|
||||
const template = PREDEFINED_TEMPLATES.find(t => t.id === templateId);
|
||||
if (template) {
|
||||
for (const status of template.statuses) {
|
||||
if (!statuses.find(s => s.name === status.name)) {
|
||||
statuses.push(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return statuses.filter(s => s.name !== 'unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export interface NoteStatusSettings {
|
|||
tagPrefix: string; // Prefix for the status tag (default: 'status')
|
||||
strictStatuses: boolean; // Whether to only show known statuses
|
||||
excludeUnknownStatus: boolean; // Whether to exclude files with unknown status from the status pane
|
||||
quickStatusCommands: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue