Skip to content

Commit

Permalink
location context and exclude added everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Apr 16, 2021
1 parent 2cc6092 commit 8f57423
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"personRegexpString":"\\[{2}People\\/(.*?)\\]{2}","projectRegexpString":"\\[{2}Projects\\/(.*?)\\]{2}","miscRegexpString":"","dateRegexpString":"#(\\d{4})\\/(\\d{2})\\/(\\d{2})","discussWithRegexpString":"#(discussWith)","waitingForRegexpString":"#(waitingFor)","promisedToRegexpString":"#(promisedTo)","somedayMaybeRegexpString":"#(someday)","excludePath":"Templates/","excludeFilenameFragment":"checklist","isInboxVisible":true,"isAgingVisible":true,"isTodayVisible":true,"isScheduledVisible":true,"isStakeholderVisible":true,"isSomedayVisible":true,"inboxTooltip":"Inbox: No date set, no stakeholder action set, not a someday / maybe item.","agingTooltip":"Aging...","todayTooltip":"Scheduled for Today","scheduledTooltip":"Scheduled for a future date","stakeholderTooltip":"Stakeholder and Project actions: discussWith, promisedTo, waitingFor. Only items that have a valid project or person will show up here. Stakeholder actions without project or person are in the Inbox.","somedayTooltip":"Tagged as Someday / Maybe"}
{"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"}
20 changes: 11 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ export default class ActionTrackerPlugin extends Plugin {

private getTodoItemIndexProps() : TodoItemIndexProps {
return {
personRegexp: new RegExp (this.getSettingValue('personRegexpString')),
projectRegexp: new RegExp (this.getSettingValue('projectRegexpString')),
miscRegexp: new RegExp (this.getSettingValue('miscRegexpString')),
dateRegexp: new RegExp (this.getSettingValue('dateRegexpString')),
discussWithRegexp: new RegExp (this.getSettingValue('discussWithRegexpString')),
waitingForRegexp: new RegExp (this.getSettingValue('waitingForRegexpString')),
promisedToRegexp: new RegExp (this.getSettingValue('promisedToRegexpString')),
somedayMaybeRegexp: new RegExp (this.getSettingValue('somedayMaybeRegexpString')),
excludePath: this.getSettingValue('excludePath'),
personRegexp: new RegExp (this.getSettingValue('personRegexpString')),
projectRegexp: new RegExp (this.getSettingValue('projectRegexpString')),
locationRegexp: new RegExp (this.getSettingValue('locationRegexpString')),
miscRegexp: new RegExp (this.getSettingValue('miscRegexpString')),
dateRegexp: new RegExp (this.getSettingValue('dateRegexpString')),
discussWithRegexp: new RegExp (this.getSettingValue('discussWithRegexpString')),
waitingForRegexp: new RegExp (this.getSettingValue('waitingForRegexpString')),
promisedToRegexp: new RegExp (this.getSettingValue('promisedToRegexpString')),
somedayMaybeRegexp: new RegExp (this.getSettingValue('somedayMaybeRegexpString')),
excludeTagRegexp: new RegExp (this.getSettingValue('excludeTagRegexpString')),
excludePath: this.getSettingValue('excludePath'),
excludeFilenameFragment: this.getSettingValue('excludeFilenameFragment').toLowerCase(),
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/model/TodoIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { TodoParser } from '../model/TodoParser';
export interface TodoItemIndexProps {
personRegexp: RegExp;
projectRegexp: RegExp;
locationRegexp: RegExp;
miscRegexp: RegExp;
dateRegexp: RegExp;
discussWithRegexp: RegExp;
waitingForRegexp: RegExp;
promisedToRegexp: RegExp;
somedayMaybeRegexp: RegExp;
excludeTagRegexp: RegExp;
excludePath: string;
excludeFilenameFragment: string;
}
Expand Down
3 changes: 3 additions & 0 deletions src/model/TodoItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class TodoItem {
public description: string;
public person: string;
public project: string;
public location: string;
public misc: string;
public actionDate?: Date;
public isSomedayMaybeNote: boolean;
Expand All @@ -35,6 +36,7 @@ export class TodoItem {
description: string,
person: string,
project: string,
location: string,
misc: string,
isSomedayMaybeNote: boolean,
isDiscussWithNote: boolean,
Expand All @@ -49,6 +51,7 @@ export class TodoItem {
this.description = description;
this.person = person;
this.project = project;
this.location = location;
this.misc = misc;
this.actionDate = actionDate;
this.isSomedayMaybeNote = isSomedayMaybeNote;
Expand Down
4 changes: 3 additions & 1 deletion src/model/TodoParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { TodoItemIndexProps} from '../model/TodoIndex'
const props = {
personRegexp: new RegExp('\\[{2}(People\\/*.)\\]{2}'),
projectRegexp: new RegExp('\\[{2}(Projects\\/*.)\\]{2}'),
locationRegexp: new RegExp('\\[{2}(Locations\\/*.)\\]{2}'),
miscRegexp: new RegExp('(.*)'),
dateRegexp: new RegExp('#(\\d{4}\\/\\d{2}\\/\\d{2})'),
discussWithRegexp: new RegExp('#(discussWith)'),
waitingForRegexp: new RegExp('#(waitingFor)'),
promisedToRegexp: new RegExp('#(promisedTo)'),
somedayMaybeRegexp: new RegExp('#(someday)'),
excludePath: '',
excludePath: '',
excludeFilenameFragment: '',
excludeTagRegexp: new RegExp(''),
}
const todoParser = new TodoParser(props);

Expand Down
9 changes: 8 additions & 1 deletion src/model/TodoParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ export class TodoParser {
const projectMatches = description.match(this.props.projectRegexp);
const project = projectMatches != null ? projectMatches[1] : "";

const locationMatches = description.match(this.props.locationRegexp);
const location = locationMatches != null ? locationMatches[1] : "";

const miscMatches = description.match(this.props.miscRegexp);
const misc = miscMatches != null ? miscMatches.length == 2 ? miscMatches[1] : "" : "";

const excludeMatches = description.match(this.props.excludeTagRegexp);
const exclude = excludeMatches != null ? excludeMatches.length == 2 ? true : false : false;

return new TodoItem(
status,
exclude ? TodoItemStatus.Done : status, //items that include the excludeTag are treated as completed TODOs
description,
person.toLowerCase(),
project.toLowerCase(),
location.toLowerCase(),
misc.toLowerCase(),
description.match(this.props.somedayMaybeRegexp) != null,
description.match(this.props.discussWithRegexp) != null,
Expand Down
14 changes: 7 additions & 7 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type ActionTrackerPlugin from "./main";
export interface ActionTrackerSettings {
personRegexpString: string,
projectRegexpString: string,
locationRegexpString: string,
locationRegexpString: string,
miscRegexpString: string,
dateRegexpString: string,
discussWithRegexpString: string,
Expand Down Expand Up @@ -262,7 +262,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.inboxTooltip)
.setValue(this.plugin.settings.inboxTooltip)
.onChange(async (value) => {
this.plugin.settings.inboxTooltip = value;
this.plugin.settings.inboxTooltip = value == '' ? DEFAULT_SETTINGS.inboxTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand All @@ -284,7 +284,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.agingTooltip)
.setValue(this.plugin.settings.agingTooltip)
.onChange(async (value) => {
this.plugin.settings.agingTooltip = value;
this.plugin.settings.agingTooltip = value == '' ? DEFAULT_SETTINGS.agingTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand All @@ -306,7 +306,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.todayTooltip)
.setValue(this.plugin.settings.todayTooltip)
.onChange(async (value) => {
this.plugin.settings.todayTooltip = value;
this.plugin.settings.todayTooltip = value == '' ? DEFAULT_SETTINGS.todayTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand All @@ -328,7 +328,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.scheduledTooltip)
.setValue(this.plugin.settings.scheduledTooltip)
.onChange(async (value) => {
this.plugin.settings.scheduledTooltip = value;
this.plugin.settings.scheduledTooltip = value == '' ? DEFAULT_SETTINGS.scheduledTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand All @@ -350,7 +350,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.stakeholderTooltip)
.setValue(this.plugin.settings.stakeholderTooltip)
.onChange(async (value) => {
this.plugin.settings.stakeholderTooltip = value;
this.plugin.settings.stakeholderTooltip = value == '' ? DEFAULT_SETTINGS.stakeholderTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand All @@ -372,7 +372,7 @@ export class ActionTrackerSettingTab extends PluginSettingTab {
let t = text.setPlaceholder(DEFAULT_SETTINGS.somedayTooltip)
.setValue(this.plugin.settings.somedayTooltip)
.onChange(async (value) => {
this.plugin.settings.somedayTooltip = value;
this.plugin.settings.somedayTooltip = value == '' ? DEFAULT_SETTINGS.somedayTooltip : value;
await this.plugin.saveViewDisplaySettings();
});
t.inputEl.setAttr("rows", 4);
Expand Down
9 changes: 5 additions & 4 deletions src/ui/TodoItemView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,12 @@ export class TodoItemView extends ItemView {
private filterForState(value: TodoItem, _index: number, _array: TodoItem[]): boolean {
const isPersonMatch = value.person.match(this.filterRegexp) != null;
const isProjectMatch = value.project.match(this.filterRegexp) != null;
const isLocationMatch = value.location.match(this.filterRegexp) != null;
const isMiscMatch = value.misc.match(this.filterRegexp) != null;
const isFilterSet = this.filter!="";
const hasPersonOrProject = value.person!='' || value.project!='';
const hasContext = value.person!='' || value.project!='' || value.location!='';
const isPeopleActionNote = value.isDiscussWithNote || value.isWaitingForNote || value.isPromisedToNote;
if (!isFilterSet || isPersonMatch || isProjectMatch || isMiscMatch) {
if (!isFilterSet || isPersonMatch || isProjectMatch || isMiscMatch || isLocationMatch) {
const isToday = (date: Date) => {
let today = new Date();
return (
Expand All @@ -382,7 +383,7 @@ export class TodoItemView extends ItemView {

switch (this.state.activePane) {
case TodoItemViewPane.Inbox:
return !value.isSomedayMaybeNote && !isTodayNote && !isScheduledNote && !isAgingNote && !(isPeopleActionNote && hasPersonOrProject);
return !value.isSomedayMaybeNote && !isTodayNote && !isScheduledNote && !isAgingNote && !(isPeopleActionNote && hasContext) ;
case TodoItemViewPane.Scheduled:
return isScheduledNote;
case TodoItemViewPane.Someday:
Expand All @@ -392,7 +393,7 @@ export class TodoItemView extends ItemView {
case TodoItemViewPane.Aging:
return isAgingNote;
case TodoItemViewPane.Stakeholder:
return hasPersonOrProject && isPeopleActionNote;
return hasContext && isPeopleActionNote ;
}
} else return false;
}
Expand Down

0 comments on commit 8f57423

Please sign in to comment.