diff --git a/data.json b/data.json index fd09e90..8932851 100644 --- a/data.json +++ b/data.json @@ -1 +1 @@ -{"personRegexpString":"\\[{2}People\\/(.*?)\\]{2}","projectRegexpString":"\\[{2}Projects\\/(.*?)\\]{2}","locationRegexpString":"\\[{2}Locations\\/(.*?)\\]{2}","miscRegexpString":"","dateRegexpString":"#(\\d{4})\\/(\\d{2})\\/(\\d{2})","discussWithRegexpString":"#(discussWith)","waitingForRegexpString":"#(waitingFor)","promisedToRegexpString":"#(promisedTo)","somedayMaybeRegexpString":"#(someday)","excludeTagRegexpString":"#(exclude)","excludePath":"Templates/","excludeFilenameFragment":"checklist","isInboxVisible":true,"isAgingVisible":true,"isTodayVisible":true,"isScheduledVisible":true,"isStakeholderVisible":true,"isSomedayVisible":true,"inboxTooltip":"Inbox: Unclassified TODOs, i.e. without a date; without an Action Tag and a Context; without someday/maybe tag.","agingTooltip":"Overdue: Past the TODO's date.","todayTooltip":"Today: Scheduled for Today","scheduledTooltip":"Scheduled: Scheduled for a future date","stakeholderTooltip":"Context Actions: Only TODOs that have a valid Context (Person, Project, Location) and a valid Action Tag appear here.","somedayTooltip":"Someday / Maybe"} \ No newline at end of file +{"personRegexpString":"\\[{2}People\\/(.*?)\\]{2}","projectRegexpString":"\\[{2}Projects\\/(.*?)\\]{2}","locationRegexpString":"\\[{2}Locations\\/(.*?)\\]{2}","miscRegexpString":"","dateRegexpString":"#(\\d{4})\\/(\\d{2})\\/(\\d{2})","actionTagOneRegexpString":"#(discussWith)","actionTagTwoRegexpString":"#(waitingFor)","actionTagThreeRegexpString":"#(promisedTo)","somedayMaybeRegexpString":"#(someday)","excludeTagRegexpString":"#(exclude)","excludePath":"Templates/","excludeFilenameFragment":"checklist","isInboxVisible":true,"isOverdueVisible":true,"isTodayVisible":true,"isScheduledVisible":true,"isStakeholderVisible":true,"isSomedayVisible":true,"inboxTooltip":"Inbox: Unclassified TODOs, i.e. without a date; without an Action Tag and a Context; without someday/maybe tag.","overdueTooltip":"Overdue: Past the TODO's date.","todayTooltip":"Today: Scheduled for Today","scheduledTooltip":"Scheduled: Scheduled for a future date","stakeholderTooltip":"Context Actions: Only TODOs that have a valid Context (Person, Project, Location) and a valid Action Tag appear here.","somedayTooltip":"Someday / Maybe","discussWithRegexpString":"#(discussWith)","waitingForRegexpString":"#(waitingFor)","promisedToRegexpString":"#(promisedTo)","isAgingVisible":true,"agingTooltip":"Overdue: Past the TODO's date."} \ No newline at end of file diff --git a/package.json b/package.json index 1699b47..a9d96b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "obsidian-gtd-plugin", "version": "0.9.7", - "description": "GTD action tracker", + "description": "Obsidian GTD action tracker", "main": "main.js", "scripts": { "build": "rollup --config rollup.config.js --environment BUILD:production", diff --git a/rollup.config.js b/rollup.config.js index 2652bd9..500fe7e 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -16,21 +16,21 @@ https://github.com/zsviczian/obsidian-stakeholder-actions `; export default { - input: 'src/main.ts', + input: './src/main.ts', output: { dir: isProd ? './dist' : '.', sourcemap: 'inline', - sourcemapExcludeSources: isProd, +// sourcemapExcludeSources: isProd, format: 'cjs', exports: 'default', - banner + banner, }, external: ['obsidian'], - plugins: [typescript(), + plugins: [copyAndWatch('src/styles.css','styles.css',true), + copyAndWatch('src/manifest.json','manifest.json',true), + typescript({inlineSources: !isProd}), nodeResolve({ browser: true }), - commonjs(), - copyAndWatch('src/styles.css','styles.css',true), - copyAndWatch('src/manifest.json','manifest.json',true)], + commonjs()], }; function copyAndWatch(fileIn, fileOut, isProd) { diff --git a/src/main.ts b/src/main.ts index 1d997c8..7b0adc8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,10 @@ -import { App, Plugin, PluginManifest, TFile, WorkspaceLeaf, } from 'obsidian'; +import { App, Plugin, PluginManifest, TFile, WorkspaceLeaf} from 'obsidian'; import { VIEW_TYPE_TODO } from './constants'; import { TodoItemView, TodoItemViewProps, TodoItemViewPane } from './ui/TodoItemView'; import { TodoItem, TodoItemStatus } from './model/TodoItem'; import { TodoIndex,TodoItemIndexProps } from './model/TodoIndex'; import {DEFAULT_SETTINGS, ActionTrackerSettings, ActionTrackerSettingTab} from './settings'; -import { stringify } from 'querystring'; +//import { stringify } from 'querystring'; export default class ActionTrackerPlugin extends Plugin { @@ -35,7 +35,6 @@ export default class ActionTrackerPlugin extends Plugin { async onload(): Promise { console.log('loading plugin'); - await this.loadSettings(); this.todoIndex = new TodoIndex(this.app.vault, this.tick.bind(this),this.getTodoItemIndexProps()); @@ -52,16 +51,16 @@ export default class ActionTrackerPlugin extends Plugin { this.todoIndex.setStatus(todo, newStatus); }, isInboxVisible: this.getSettingValue('isInboxVisible'), - isOverdueVisible: this.getSettingValue('isOverdueVisible'), + isOverdueVisible: this.getSettingValue('isOverdueVisible'), isTodayVisible: this.getSettingValue('isTodayVisible'), isScheduledVisible: this.getSettingValue('isScheduledVisible'), - isStakeholderVisible: this.getSettingValue('isStakeholderVisible'), + isContextActionVisible: this.getSettingValue('isContextActionVisible'), isSomedayVisible: this.getSettingValue('isSomedayVisible'), inboxTooltip: this.getSettingValue('inboxTooltip'), - overdueTooltip: this.getSettingValue('overdueTooltip'), + overdueTooltip: this.getSettingValue('overdueTooltip'), todayTooltip: this.getSettingValue('todayTooltip'), scheduledTooltip: this.getSettingValue('scheduledTooltip'), - stakeholderTooltip: this.getSettingValue('stakeholderTooltip'), + contextActionTooltip: this.getSettingValue('contextActionTooltip'), somedayTooltip: this.getSettingValue('somedayTooltip'), }; this.view = new TodoItemView(leaf, props); @@ -73,37 +72,79 @@ export default class ActionTrackerPlugin extends Plugin { this.addCommand({ id: "show-inbox-view", name: "Inbox View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Inbox}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isInboxVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.Inbox}); + return true; + } + }, }); this.addCommand({ id: "show-overdue-view", name: "Overdue View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Overdue}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isOverdueVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.Overdue}); + return true; + } + }, }); - + this.addCommand({ id: "show-today-view", name: "Today View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Today}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isTodayVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.Today}); + return true; + } + }, }); this.addCommand({ id: "show-scheduled-view", name: "Scheduled View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Scheduled}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isScheduledVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.Scheduled}); + return true; + } + }, }); this.addCommand({ id: "show-context-actions-view", name: "Context Actions View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Stakeholder}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isContextActionVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.ContextAction}); + return true; + } + }, }); this.addCommand({ id: "show-someday-view", name: "Someday/Maybe View", - callback: () => this.view.setViewState({activePane: TodoItemViewPane.Someday}), + checkCallback: (checking: boolean) => { + if (checking) { + return this.getSettingValue('isSomedayVisible'); + } else { + this.view.setViewState({activePane: TodoItemViewPane.Someday}); + return true; + } + }, }); if (this.app.workspace.layoutReady) { @@ -160,13 +201,13 @@ export default class ActionTrackerPlugin extends Plugin { isOverdueVisible: this.getSettingValue('isOverdueVisible'), isTodayVisible: this.getSettingValue('isTodayVisible'), isScheduledVisible: this.getSettingValue('isScheduledVisible'), - isStakeholderVisible: this.getSettingValue('isStakeholderVisible'), + isContextActionVisible: this.getSettingValue('isContextActionVisible'), isSomedayVisible: this.getSettingValue('isSomedayVisible'), inboxTooltip: this.getSettingValue('inboxTooltip'), overdueTooltip: this.getSettingValue('overdueTooltip'), todayTooltip: this.getSettingValue('todayTooltip'), scheduledTooltip: this.getSettingValue('scheduledTooltip'), - stakeholderTooltip: this.getSettingValue('stakeholderTooltip'), + contextActionTooltip: this.getSettingValue('contextActionTooltip'), somedayTooltip: this.getSettingValue('somedayTooltip'), }); } diff --git a/src/settings.ts b/src/settings.ts index 3a413ec..9fe9dc9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -18,13 +18,13 @@ export interface ActionTrackerSettings { isOverdueVisible: boolean, isTodayVisible: boolean, isScheduledVisible: boolean, - isStakeholderVisible: boolean, + isContextActionVisible: boolean, isSomedayVisible: boolean, inboxTooltip: string, overdueTooltip: string, todayTooltip: string, scheduledTooltip: string, - stakeholderTooltip: string, + contextActionTooltip: string, somedayTooltip: string, } @@ -45,13 +45,13 @@ export const DEFAULT_SETTINGS: ActionTrackerSettings = { isOverdueVisible: true, isTodayVisible: true, isScheduledVisible: true, - isStakeholderVisible: true, + isContextActionVisible: true, isSomedayVisible: true, inboxTooltip: 'Inbox: Unclassified TODOs, i.e. without a date; without an Action Tag and a Context; without someday/maybe tag.', overdueTooltip: 'Overdue: Past the TODO\'s date.', todayTooltip: 'Today: Scheduled for Today', scheduledTooltip: 'Scheduled: Scheduled for a future date', - stakeholderTooltip: 'Context Actions: Only TODOs that have a valid Context (Person, Project, Location) and a valid Action Tag appear here.', + contextActionTooltip: 'Context Actions: Only TODOs that have a valid Context (Person, Project, Location) and a valid Action Tag appear here.', somedayTooltip: 'Someday / Maybe', } @@ -339,18 +339,18 @@ export class ActionTrackerSettingTab extends PluginSettingTab { new Setting(containerEl) .setName('Show/hide Context Actions') .addToggle(value => value - .setValue(this.plugin.settings.isStakeholderVisible) + .setValue(this.plugin.settings.isContextActionVisible) .onChange(async (value) => { - this.plugin.settings.isStakeholderVisible = value; + this.plugin.settings.isContextActionVisible = value; await this.plugin.saveViewDisplaySettings(); })); new Setting(containerEl) .setName('Context Actions tooltip') .addTextArea(text => { - let t = text.setPlaceholder(DEFAULT_SETTINGS.stakeholderTooltip) - .setValue(this.plugin.settings.stakeholderTooltip) + let t = text.setPlaceholder(DEFAULT_SETTINGS.contextActionTooltip) + .setValue(this.plugin.settings.contextActionTooltip) .onChange(async (value) => { - this.plugin.settings.stakeholderTooltip = value == '' ? DEFAULT_SETTINGS.stakeholderTooltip : value; + this.plugin.settings.contextActionTooltip = value == '' ? DEFAULT_SETTINGS.contextActionTooltip : value; await this.plugin.saveViewDisplaySettings(); }); t.inputEl.setAttr("rows", 4); diff --git a/src/ui/TodoItemView.ts b/src/ui/TodoItemView.ts index 124ee10..615096f 100644 --- a/src/ui/TodoItemView.ts +++ b/src/ui/TodoItemView.ts @@ -9,15 +9,15 @@ export enum TodoItemViewPane { Scheduled, Inbox, Someday, - Stakeholder, + ContextAction, } enum TodoSortStates { None, DateAsc, DateDesc, - StakeholderAsc, - StakeholderDesc, + ContextActionAsc, + ContextActionDesc, ProjectAsc, ProjectDesc, MiscAsc, @@ -27,21 +27,21 @@ enum TodoSortStates { } export interface TodoItemViewProps { - todos: TodoItem[]; - openFile: (filePath: string) => void; - toggleTodo: (todo: TodoItem, newStatus: TodoItemStatus) => void; - isInboxVisible: boolean; - isOverdueVisible: boolean; - isTodayVisible: boolean; - isScheduledVisible: boolean; - isStakeholderVisible: boolean; - isSomedayVisible: boolean; - inboxTooltip: string; - overdueTooltip: string; - todayTooltip: string; - scheduledTooltip: string; - stakeholderTooltip: string; - somedayTooltip: string; + todos: TodoItem[]; + openFile: (filePath: string) => void; + toggleTodo: (todo: TodoItem, newStatus: TodoItemStatus) => void; + isInboxVisible: boolean; + isOverdueVisible: boolean; + isTodayVisible: boolean; + isScheduledVisible: boolean; + isContextActionVisible: boolean; + isSomedayVisible: boolean; + inboxTooltip: string; + overdueTooltip: string; + todayTooltip: string; + scheduledTooltip: string; + contextActionTooltip: string; + somedayTooltip: string; } interface TodoItemViewState { @@ -61,7 +61,6 @@ export class TodoItemView extends ItemView { private sortStateCount; constructor(leaf: WorkspaceLeaf, props: TodoItemViewProps) { - //debugger; super(leaf); this.props = props; this.state = { @@ -95,13 +94,13 @@ export class TodoItemView extends ItemView { this.props.isOverdueVisible = props.isOverdueVisible; this.props.isTodayVisible = props.isTodayVisible; this.props.isScheduledVisible = props.isScheduledVisible; - this.props.isStakeholderVisible = props.isStakeholderVisible; + this.props.isContextActionVisible = props.isContextActionVisible; this.props.isSomedayVisible = props.isSomedayVisible; this.props.inboxTooltip = props.inboxTooltip; this.props.overdueTooltip = props.overdueTooltip; this.props.todayTooltip = props.todayTooltip; this.props.scheduledTooltip = props.scheduledTooltip; - this.props.stakeholderTooltip = props.stakeholderTooltip; + this.props.contextActionTooltip = props.contextActionTooltip; this.props.somedayTooltip = props.somedayTooltip; this.render(); } @@ -115,8 +114,8 @@ export class TodoItemView extends ItemView { this.state = newState; if(newState.activePane == TodoItemViewPane.Overdue || newState.activePane == TodoItemViewPane.Scheduled || newState.activePane == TodoItemViewPane.Today) this.sortState = {state: TodoSortStates.DateAsc}; - else if (newState.activePane == TodoItemViewPane.Stakeholder) - this.sortState = {state: TodoSortStates.StakeholderAsc}; + else if (newState.activePane == TodoItemViewPane.ContextAction) + this.sortState = {state: TodoSortStates.ContextActionAsc}; else this.sortState = {state: TodoSortStates.FullTextAsc}; this.render(); @@ -173,9 +172,9 @@ export class TodoItemView extends ItemView { return 'Sort by: Action Date Descending'; case TodoSortStates.DateAsc: return 'Sort by: Action Date Ascending'; - case TodoSortStates.StakeholderDesc: + case TodoSortStates.ContextActionDesc: return 'Sort by: Person Descending'; - case TodoSortStates.StakeholderAsc: + case TodoSortStates.ContextActionAsc: return 'Sort by: Person Ascending'; case TodoSortStates.ProjectDesc: return 'Sort by: Project Descending'; @@ -246,10 +245,10 @@ export class TodoItemView extends ItemView { el.onClickEvent(() => setActivePane(TodoItemViewPane.Scheduled)); }); - if (this.props.isStakeholderVisible) - container.createDiv(`todo-item-view-toolbar-item${activeClass(TodoItemViewPane.Stakeholder)}`, (el) => { - el.appendChild(RenderIcon(Icon.Stakeholder, this.props.stakeholderTooltip)); - el.onClickEvent(() => setActivePane(TodoItemViewPane.Stakeholder)); + if (this.props.isContextActionVisible) + container.createDiv(`todo-item-view-toolbar-item${activeClass(TodoItemViewPane.ContextAction)}`, (el) => { + el.appendChild(RenderIcon(Icon.ContextAction, this.props.contextActionTooltip)); + el.onClickEvent(() => setActivePane(TodoItemViewPane.ContextAction)); }); if (this.props.isSomedayVisible) @@ -310,9 +309,9 @@ export class TodoItemView extends ItemView { sortResult = a.actionDate < b.actionDate ? -1 : a.actionDate > b.actionDate ? 1 : 0;break; case TodoSortStates.DateDesc: sortResult = a.actionDate > b.actionDate ? -1 : a.actionDate < b.actionDate ? 1 : 0;break; - case TodoSortStates.StakeholderAsc: + case TodoSortStates.ContextActionAsc: sortResult = a.person < b.person ? -1 : a.person > b.person ? 1 : 0;break; - case TodoSortStates.StakeholderDesc: + case TodoSortStates.ContextActionDesc: sortResult = a.person > b.person ? -1 : a.person < b.person ? 1 : 0;break; case TodoSortStates.ProjectAsc: sortResult = a.project < b.project ? -1 : a.project > b.project ? 1 : 0;break; @@ -328,7 +327,7 @@ export class TodoItemView extends ItemView { sortResult = a.description.toLowerCase() > b.description.toLowerCase() ? -1 : a.description.toLowerCase() < b.description.toLowerCase() ? 1 : 0;break; } - if (this.state.activePane == TodoItemViewPane.Stakeholder) { + if (this.state.activePane == TodoItemViewPane.ContextAction) { if (a.isDiscussWithNote && !b.isDiscussWithNote) { return -1; } @@ -391,7 +390,7 @@ export class TodoItemView extends ItemView { return isTodayNote; case TodoItemViewPane.Overdue: return isOverdueNote; - case TodoItemViewPane.Stakeholder: + case TodoItemViewPane.ContextAction: return hasContext && isPeopleActionNote ; } } else return false; diff --git a/src/ui/icons.ts b/src/ui/icons.ts index ebae7c8..2e6a76e 100644 --- a/src/ui/icons.ts +++ b/src/ui/icons.ts @@ -4,7 +4,7 @@ export enum Icon { Scheduled, Someday, Today, - Stakeholder, + ContextAction, Overdue, Sort, } @@ -28,8 +28,8 @@ const svgForIcon = (icon: Icon): ((arg0: string, arg1: string) => string) => { return somedayIcon; case Icon.Today: return todayIcon; - case Icon.Stakeholder: - return stakeholderIcon; + case Icon.ContextAction: + return contextActionIcon; case Icon.Overdue: return overdueIcon; case Icon.Sort: @@ -85,7 +85,7 @@ const todayIcon = (title: string, description: string): string => ` `; -const stakeholderIcon = (title: string, description: string): string => ` +const contextActionIcon = (title: string, description: string): string => ` ${title} ${description}