mirror of
https://github.com/mryanb/obsidian-asana.git
synced 2026-07-22 05:38:24 +00:00
feat(settings): add option to pin My Tasks in project selector
- Add pinMyTasks setting with default value of true - Add toggle in settings UI to control My Tasks pinning - Update project list creation to respect pinMyTasks setting - Maintain consistent ordering with existing pinned projects
This commit is contained in:
parent
2bbd595640
commit
8ff3a1a9d7
2 changed files with 24 additions and 3 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -200,7 +200,12 @@ export default class AsanaPlugin extends Plugin {
|
|||
const pinnedProjectIds = new Set(this.settings.pinnedProjects);
|
||||
|
||||
// Add "My Tasks" as a special project option
|
||||
const myTasksProject = { name: "My Tasks", gid: userData.gid, isPinned: true, isMyTasks: true };
|
||||
const myTasksProject = {
|
||||
name: "My Tasks",
|
||||
gid: userData.gid,
|
||||
isPinned: this.settings.pinMyTasks,
|
||||
isMyTasks: true
|
||||
};
|
||||
|
||||
// Separate pinned and non-pinned projects
|
||||
const pinnedProjects = projects
|
||||
|
|
@ -211,8 +216,10 @@ export default class AsanaPlugin extends Plugin {
|
|||
.filter((p: any) => !pinnedProjectIds.has(p.gid) && !pinnedProjectIds.has(p.name))
|
||||
.map((p: any) => ({ name: p.name, gid: p.gid, isPinned: false }));
|
||||
|
||||
// Combine My Tasks, pinned projects, and other projects
|
||||
const projectOptions = [myTasksProject, ...pinnedProjects, ...otherProjects];
|
||||
// Combine My Tasks (if pinned), pinned projects, and other projects
|
||||
const projectOptions = this.settings.pinMyTasks
|
||||
? [myTasksProject, ...pinnedProjects, ...otherProjects]
|
||||
: [...pinnedProjects, myTasksProject, ...otherProjects];
|
||||
|
||||
// Prompt for project selection
|
||||
const project = await this.promptForSelection('Select project', projectOptions);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export interface AsanaPluginSettings {
|
|||
pinnedProjects: string[];
|
||||
enableMarkdownLink: boolean;
|
||||
showArchivedProjects: boolean;
|
||||
pinMyTasks: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -21,6 +22,7 @@ export const DEFAULT_SETTINGS: AsanaPluginSettings = {
|
|||
pinnedProjects: [],
|
||||
enableMarkdownLink: true,
|
||||
showArchivedProjects: false,
|
||||
pinMyTasks: true,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -105,6 +107,18 @@ export class AsanaSettingTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
|
||||
// Toggle: Pin My Tasks
|
||||
new Setting(containerEl)
|
||||
.setName('Pin My Tasks')
|
||||
.setDesc('Always show My Tasks at the top of the project selector.')
|
||||
.addToggle((toggle: ToggleComponent) => {
|
||||
toggle.setValue(this.plugin.settings.pinMyTasks)
|
||||
.onChange(async (value: boolean) => {
|
||||
this.plugin.settings.pinMyTasks = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
// Toggle: Show Archived Projects
|
||||
new Setting(containerEl)
|
||||
.setName('Show archived projects')
|
||||
|
|
|
|||
Loading…
Reference in a new issue