chore: remove default statuses

This commit is contained in:
Aleix Soler 2025-04-19 21:13:28 +02:00
parent 17293b7773
commit 1f044c8f4a
4 changed files with 22 additions and 66 deletions

View file

@ -14,13 +14,7 @@ export const DEFAULT_SETTINGS: NoteStatusSettings = {
},
showStatusBar: true,
autoHideStatusBar: false,
customStatuses: [
{ name: 'active', icon: '▶️', description: 'Currently working on this note' },
{ name: 'onHold', icon: '⏸️', description: 'Temporarily paused work' },
{ name: 'completed', icon: '✅', description: 'Finished work on this note' },
{ name: 'dropped', icon: '❌', description: 'No longer working on this' },
{ name: 'unknown', icon: '❓', description: 'Status not set' }
],
customStatuses: [],
showStatusIconsInExplorer: true,
hideUnknownStatusInExplorer: false, // Default to show unknown status
collapsedStatuses: {},

39
main.ts
View file

@ -540,45 +540,6 @@ export default class NoteStatus extends Plugin {
}
}
/**
* Reset default colors
*/
async resetDefaultColors(): Promise<void> {
try {
// Reset colors for default statuses
const defaultStatuses = ['active', 'onHold', 'completed', 'dropped', 'unknown'];
for (const status of defaultStatuses) {
if (this.settings.customStatuses.some(s => s.name === status)) {
this.settings.statusColors[status] = DEFAULT_COLORS[status];
}
}
// Handle template status colors
this.resetTemplateColors();
await this.saveSettings();
new Notice('Default colors have been restored');
} catch (error) {
console.error('Error resetting default colors:', error);
new Notice('Error resetting default colors. Check console for details.');
}
}
/**
* Reset colors for template statuses
*/
private resetTemplateColors(): void {
if (!this.settings.useCustomStatusesOnly) {
const templateStatuses = this.statusService.getTemplateStatuses();
for (const status of templateStatuses) {
if (status.color) {
this.settings.statusColors[status.name] = status.color;
}
}
}
}
/**
* Load settings with error handling
*/

View file

@ -148,11 +148,23 @@ export class NoteStatusSettingTab extends PluginSettingTab {
.setName(status.name)
.setClass('status-item');
// Name field
setting.addText(text => {
// ... existing name field code
return text;
});
// Name field - now properly implemented
setting.addText(text => text
.setPlaceholder('Name')
.setValue(status.name)
.onChange(async (value) => {
const oldName = status.name;
status.name = value || 'unnamed';
// Update color mapping when name changes
if (oldName !== status.name) {
this.plugin.settings.statusColors[status.name] =
this.plugin.settings.statusColors[oldName];
delete this.plugin.settings.statusColors[oldName];
}
await this.plugin.saveSettings();
}));
// Icon field
setting.addText(text => text
@ -171,7 +183,7 @@ export class NoteStatusSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
}));
// Description field (new)
// Description field
setting.addText(text => text
.setPlaceholder('Description')
.setValue(status.description || '')
@ -215,19 +227,6 @@ export class NoteStatusSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
renderStatuses();
}));
// Reset colors
new Setting(containerEl)
.setName('Reset default status colors')
.setDesc('Restore the default colors for predefined statuses')
.addButton(button => button
.setButtonText('Reset Colors')
.setWarning()
.onClick(async () => {
await this.plugin.resetDefaultColors();
renderStatuses();
new Notice('Default status colors restored');
}));
}
/**

View file

@ -163,7 +163,9 @@ export class StatusDropdown {
private addDefaultStatusIcon(container: HTMLElement): void {
const iconSpan = document.createElement('span');
iconSpan.addClass('note-status-toolbar-icon', 'status-unknown');
iconSpan.textContent = '📌'; // Default tag icon
// Use the statusService to get the proper icon for 'unknown' status
iconSpan.textContent = this.statusService.getStatusIcon('unknown');
container.appendChild(iconSpan);
}