Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can now select for the global filter to land at the end of a task #462

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "8.2.1",
"@tsconfig/svelte": "^1.0.10",
"@types/jest": "^26.0.22",
"@types/jest": "^27.0.0",
"@types/node": "^14.14.31",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
Expand Down
2 changes: 2 additions & 0 deletions src/Settings.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export interface Settings {
globalFilter: string;
removeGlobalFilter: boolean;
appendGlobalFilter: boolean;
}

const defaultSettings: Settings = {
globalFilter: '',
removeGlobalFilter: false,
appendGlobalFilter: false,
};

let settings: Settings = { ...defaultSettings };
Expand Down
17 changes: 17 additions & 0 deletions src/SettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ export class SettingsTab extends PluginSettingTab {
.onChange(async (value) => {
updateSettings({ removeGlobalFilter: value });

await this.plugin.saveSettings();
});
});

new Setting(containerEl)
.setName('Create task with global filter at end')
.setDesc(
'Enabling this places the global filter at the end of the task description. Some plugins, such as Day Planner, might require this, or you might prefer how it looks.',
)
.addToggle((toggle) => {
const settings = getSettings();

toggle
.setValue(settings.appendGlobalFilter)
.onChange(async (value) => {
updateSettings({ appendGlobalFilter: value });

await this.plugin.saveSettings();
});
});
Expand Down
6 changes: 4 additions & 2 deletions src/ui/EditTask.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@
});

const _onSubmit = () => {
const { globalFilter } = getSettings();
const { globalFilter, appendGlobalFilter } = getSettings();
let description = editableTask.description.trim();
if (!description.includes(globalFilter)) {
description = globalFilter + ' ' + description;
description = appendGlobalFilter ?
`${description} ${globalFilter}` : // Append if chosen,
`${globalFilter} ${description}`; // prepend otherwise.
}

let startDate: moment.Moment | null = null;
Expand Down
Loading