Skip to content

Commit

Permalink
Added a setting for a default review date.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan J.A. Murphy committed Nov 16, 2020
1 parent 9a46a6e commit c522695
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
27 changes: 25 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default class Review extends Plugin {
return;
}

if (someDate === "") {
someDate = this.settings.defaultReviewDate;
}
// Use the Natural Language Dates plugin's processDate method to convert the input date into a daily note title.
let parsedResult = naturalLanguageDates.parseDate(someDate);
let inputDate = parsedResult.formattedString;
Expand Down Expand Up @@ -122,6 +125,7 @@ class ReviewSettings {
dailyNotesFolder = "";
reviewSectionHeading = "## Review";
linePrefix = "- ";
defaultReviewDate = "";
}

class ReviewModal extends Modal {
Expand Down Expand Up @@ -172,7 +176,7 @@ class ReviewSettingTab extends PluginSettingTab {
.setDesc('Set the path to your daily notes. Use the format "folder/subfolder". Do not use leading or trailing slashes "/".')
.addText((text) =>
text
.setPlaceholder('')
.setPlaceholder('')
.setValue(plugin.settings.dailyNotesFolder)
.onChange((value) => {
console.log("The new daily notes folder:" + value);
Expand Down Expand Up @@ -208,5 +212,24 @@ class ReviewSettingTab extends PluginSettingTab {
plugin.saveData(plugin.settings);
})
);
}
new Setting(containerEl)
.setName('Default review date')
.setDesc('Set a default date to be used when no date is entered. Use natural language: "Next Monday", "November 5th", and "tomorrow" all work.')
.addText((text) =>
text
.setPlaceholder('')
.setValue(plugin.settings.defaultReviewDate)
.onChange((value) => {
plugin.settings.defaultReviewDate = value;
plugin.saveData(plugin.settings);
})
);

// containerEl.createEl('h3', { text: 'Preset review schedules' });

/*
TKTKTK: Figure out how to add a function to a button inside the setting element. Currently `doSomething`, below, throws errors.
containerEl.createEl('button', { text: "Add a new review schedule preset", attr: { onclick: "doSomething({ console.log('button clicked') });"}});
*/
}
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "review-obsidian",
"name": "Review",
"version": "1.3.0",
"version": "1.4.0",
"description": "Add a link to the current note to a daily note on a future date (or a past date, you time traveller).",
"author": "ryanjamurphy",
"authorUrl": "https://axle.design",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "review-obsidian",
"version": "1.3.0",
"version": "1.4.0",
"description": "Add a link to the current note to a daily note on a future date (or a past date, you time traveller).",
"main": "main.js",
"repository": "ryanjamurphy/review-obsidian",
Expand Down

0 comments on commit c522695

Please sign in to comment.