Skip to content

Commit 0542668

Browse files
authored
Merge pull request #3425 from obsidian-tasks-group/refactor-remove-scheduled-dates
refactor: Small refinements to drop/remove scheduled dates setting
2 parents 696b859 + c681a20 commit 0542668

17 files changed

+76
-31
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ yarn-error.log
4949
# Backup files.
5050
*.bak
5151

52+
# Internationalisation
53+
/src/i18n/locales/*_old.json
54+
5255
# VS code config
5356
.vscode/

docs/Getting Started/Dates.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Scheduled dates use an hourglass emoji: ⏳.
5959
- [ ] take out the trash ⏳ 2021-04-09
6060
```
6161

62-
See [[Use Filename as Default Date]] for how to optionally make Tasks use any dates in file names as the scheduled date for all undated tasks in that file.
62+
See also:
6363

64-
> [!released]
65-
'Use Filename as Default Date' was introduced in Tasks 1.18.0.
64+
- [[Use Filename as Default Date]] for how to optionally make Tasks use any dates in file names as the scheduled date for all undated tasks in that file.
65+
- [[Recurring Tasks#Remove scheduled date on recurrence|Remove scheduled date on recurrence]] for controlling whether new recurring tasks are automatically scheduled.
6666

6767
Related instructions for use in Tasks query blocks:
6868

docs/Getting Started/Recurring Tasks.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Alternatively, if you have enabled addition of [[Dates#Created date|created date
4646
- [x] take out the trash 🔁 every Sunday 📅 2021-04-25 ✅ 2023-03-10
4747
```
4848

49+
## Recurrence Settings
50+
4951
### Order of the new task
5052

5153
Use this setting to control where the recurring task is inserted. The default is to put the new task before the original one.
@@ -55,11 +57,18 @@ Use this setting to control where the recurring task is inserted. The default is
5557
> [!released]
5658
> Control of the location (or order) of the new task was introduced in Tasks 3.8.0
5759
58-
### Drop scheduled dates
60+
### Remove scheduled date on recurrence
61+
62+
Use this setting to control whether the Scheduled date should be removed from the next occurrence. The Scheduled date is only removed the task also has a Start or Due date.
63+
64+
This is useful when you want the Start and Due dates to carry forward to the next recurrence, but you will set the Scheduled date in future, once you know when you intend to work on it.
5965

60-
Use this setting to control whether the scheduled date should be removed from the next occurrence. The scheduled date is only removed the task also has another date.
66+
![Setting for Remove scheduled date on recurrence](../images/settings-recurrence-remove-scheduled-date.png)
67+
68+
> [!released]
69+
> The option to remove the scheduled date on recurrence was introduced in Tasks X.Y.Z.
6170
62-
### Recurring Tasks with Custom Statuses
71+
## Recurring Tasks with Custom Statuses
6372

6473
> [!Warning]
6574
> If you use [[Custom Statuses]], please see [[Recurring Tasks and Custom Statuses]] for important information about how these two facilities interact.

docs/Getting Started/Settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ For convenience, here is a list of all those documentation pages (in the order t
2727
- [[Status Settings#Overview|Status Settings]]
2828
- [[Dates#Date-tracking settings|Dates]]
2929
- [[Use Filename as Default Date#Settings|Use Filename as Default Date]]
30-
- [[Recurring Tasks#Order of the new task|Recurring Tasks]]
30+
- [[Recurring Tasks#Recurrence Settings|Recurring Tasks]]
3131
- [[Auto-Suggest#Settings|Auto-Suggest]]
3232
- [[Create or edit Task#Turning off keyboard shortcuts|Create or edit Task modal]]
Loading

i18next-parser.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
useKeysAsDefaultValue: true, // Use keys for default values if no translation exists
2020
resetDefaultValueLocale: null, // Retain existing default values
2121
sort: true, // Sort keys alphabetically
22-
keepRemoved: true, // Keep keys not found in source files
22+
keepRemoved: false, // Keep keys not found in source files. Removed values are written to *_old.json files
2323
jsonIndent: 2, // Pretty-print JSON
2424
lexers: {
2525
ts: ['JavascriptLexer'], // TypeScript files

src/Config/Settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export interface Settings {
7676
filenameAsScheduledDateFormat: string;
7777
filenameAsDateFolders: string[];
7878
recurrenceOnNextLine: boolean;
79-
dropScheduledDateOnRecurrence: boolean;
79+
removeScheduledDateOnRecurrence: boolean;
8080

8181
// The custom status states.
8282
statusSettings: StatusSettings;
@@ -111,7 +111,7 @@ const defaultSettings: Settings = {
111111
filenameAsScheduledDateFormat: '',
112112
filenameAsDateFolders: [],
113113
recurrenceOnNextLine: false,
114-
dropScheduledDateOnRecurrence: false,
114+
removeScheduledDateOnRecurrence: false,
115115
statusSettings: new StatusSettings(),
116116
features: Feature.settingsFlags,
117117
generalSettings: {

src/Config/SettingsTab.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,20 @@ export class SettingsTab extends PluginSettingTab {
377377
});
378378

379379
new Setting(containerEl)
380-
.setName(i18n.t('settings.recurringTasks.dropScheduledDate.name'))
380+
.setName(i18n.t('settings.recurringTasks.removeScheduledDate.name'))
381381
.setDesc(
382382
SettingsTab.createFragmentWithHTML(
383-
i18n.t('settings.recurringTasks.dropScheduledDate.description') +
383+
i18n.t('settings.recurringTasks.removeScheduledDate.description.line1') +
384+
'</br>' +
385+
i18n.t('settings.recurringTasks.removeScheduledDate.description.line2') +
384386
'</br>' +
385387
this.seeTheDocumentation('https://publish.obsidian.md/tasks/Getting+Started/Recurring+Tasks'),
386388
),
387389
)
388390
.addToggle((toggle) => {
389-
const { dropScheduledDateOnRecurrence } = getSettings();
390-
toggle.setValue(dropScheduledDateOnRecurrence).onChange(async (value) => {
391-
updateSettings({ dropScheduledDateOnRecurrence: value });
391+
const { removeScheduledDateOnRecurrence } = getSettings();
392+
toggle.setValue(removeScheduledDateOnRecurrence).onChange(async (value) => {
393+
updateSettings({ removeScheduledDateOnRecurrence: value });
392394
await this.plugin.saveSettings();
393395
});
394396
});

src/Task/Occurrence.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export class Occurrence {
8787
* If the occurrence has no reference date, an empty {@link Occurrence} will be returned.
8888
*
8989
* @param nextReferenceDate
90-
* @param dropScheduledDate - Optional boolean to drop the scheduled date from the next occurrence so long as a start or due date exists.
90+
* @param removeScheduledDate - Optional boolean to remove the scheduled date from the next occurrence so long as a start or due date exists.
9191
*/
92-
public next(nextReferenceDate: Date, dropScheduledDate: boolean = false): Occurrence {
92+
public next(nextReferenceDate: Date, removeScheduledDate: boolean = false): Occurrence {
9393
// Only if a reference date is given. A reference date will exist if at
9494
// least one of the other dates is set.
9595
if (this.referenceDate === null) {
@@ -102,11 +102,11 @@ export class Occurrence {
102102

103103
const hasStartDate = this.startDate !== null;
104104
const hasDueDate = this.dueDate !== null;
105-
const canDropScheduledDate = hasStartDate || hasDueDate;
106-
const shouldDropScheduledDate = dropScheduledDate && canDropScheduledDate;
105+
const canRemoveScheduledDate = hasStartDate || hasDueDate;
106+
const shouldRemoveScheduledDate = removeScheduledDate && canRemoveScheduledDate;
107107

108108
const startDate = this.nextOccurrenceDate(this.startDate, nextReferenceDate);
109-
const scheduledDate = shouldDropScheduledDate
109+
const scheduledDate = shouldRemoveScheduledDate
110110
? null
111111
: this.nextOccurrenceDate(this.scheduledDate, nextReferenceDate);
112112
const dueDate = this.nextOccurrenceDate(this.dueDate, nextReferenceDate);

src/Task/Recurrence.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ export class Recurrence {
7272
* Returns the dates of the next occurrence or null if there is no next occurrence.
7373
*
7474
* @param today - Optional date representing the completion date. Defaults to today.
75-
* @param dropScheduledDate - Optional boolean to drop the scheduled date from the next occurrence so long as a start or due date exists.
75+
* @param removeScheduledDate - Optional boolean to remove the scheduled date from the next occurrence so long as a start or due date exists.
7676
*/
77-
public next(today = window.moment(), dropScheduledDate: boolean = false): Occurrence | null {
77+
public next(today = window.moment(), removeScheduledDate: boolean = false): Occurrence | null {
7878
const nextReferenceDate = this.nextReferenceDate(today);
7979

8080
if (nextReferenceDate === null) {
8181
return null;
8282
}
8383

84-
return this.occurrence.next(nextReferenceDate, dropScheduledDate);
84+
return this.occurrence.next(nextReferenceDate, removeScheduledDate);
8585
}
8686

8787
public identicalTo(other: Recurrence) {

src/Task/Task.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ export class Task extends ListItem {
377377
return [toggledTask];
378378
}
379379

380-
const { dropScheduledDateOnRecurrence } = getSettings();
381-
const nextOccurrence = this.recurrence.next(today, dropScheduledDateOnRecurrence);
380+
const { removeScheduledDateOnRecurrence } = getSettings();
381+
const nextOccurrence = this.recurrence.next(today, removeScheduledDateOnRecurrence);
382382
if (nextOccurrence === null) {
383383
return [toggledTask];
384384
}

src/i18n/locales/be.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@
180180
"nextLine": {
181181
"description": "Уключэнне гэтага зробіць наступнае паўтарэнне задачы на радку ніжэй за завершаную задачу. У адваротным выпадку наступнае паўтарэнне з'явіцца перад завершанай задачай.",
182182
"name": "Наступнае паўтарэнне з'яўляецца на радку ніжэй"
183+
},
184+
"removeScheduledDate": {
185+
"description": {
186+
"line1": "",
187+
"line2": ""
188+
},
189+
"name": ""
183190
}
184191
},
185192
"seeTheDocumentation": "Глядзіце дакументацыю",

src/i18n/locales/en.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@
181181
"description": "Enabling this will make the next recurrence of a task appear on the line below the completed task. Otherwise the next recurrence will appear before the completed one.",
182182
"name": "Next recurrence appears on the line below"
183183
},
184-
"dropScheduledDate": {
185-
"description": "Enabling this will make the next recurrence of a task have no scheduled date, unless the scheduled date is the only date the task has.",
186-
"name": "Drop scheduled date (only if Start or Due is present)"
184+
"removeScheduledDate": {
185+
"description": {
186+
"line1": "Enabling this will make the next recurrence of a task have no Scheduled (⏳) date, when at least one of Start (🛫) or Due (📅) dates is present.",
187+
"line2": "This is for when you want the Start and Due dates to carry forward to the next recurrence, but you will set the Scheduled date in future, once you plan to work on it."
188+
},
189+
"name": "Remove scheduled date on recurrence"
187190
}
188191
},
189192
"seeTheDocumentation": "See the documentation",

src/i18n/locales/ru.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@
180180
"nextLine": {
181181
"description": "Включение этой опции приведет к тому, что следующее повторение задачи появится на строке ниже завершенной задачи. В противном случае следующее повторение появится перед завершенной.",
182182
"name": "Следующее повторение появляется на строке ниже"
183+
},
184+
"removeScheduledDate": {
185+
"description": {
186+
"line1": "",
187+
"line2": ""
188+
},
189+
"name": ""
183190
}
184191
},
185192
"seeTheDocumentation": "Смотрите документацию",

src/i18n/locales/uk.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@
180180
"nextLine": {
181181
"description": "Увімкнення цього параметра змусить наступне повторення задачі з’являтися на рядку нижче завершеної задачі. Інакше наступне повторення з’явиться перед завершеною.",
182182
"name": "Наступне повторення з’являється на рядку нижче"
183+
},
184+
"removeScheduledDate": {
185+
"description": {
186+
"line1": "",
187+
"line2": ""
188+
},
189+
"name": ""
183190
}
184191
},
185192
"seeTheDocumentation": "Переглянути документацію",

src/i18n/locales/zh_cn.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@
180180
"nextLine": {
181181
"description": "启用此功能后,任务的下一次重复将显示在已完成任务的下一行。若关闭此功能,则下一次重复将出现在已完成任务的上一行。",
182182
"name": "把任务的下一次重复放在下一行"
183+
},
184+
"removeScheduledDate": {
185+
"description": {
186+
"line1": "",
187+
"line2": ""
188+
},
189+
"name": ""
183190
}
184191
},
185192
"seeTheDocumentation": "参阅文档",

tests/Task/Recurrence.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ describe('identicalTo', () => {
229229
});
230230
});
231231

232-
describe('Recurrence - with dropScheduledDateOnRecurrence', () => {
233-
it('drops the scheduledDate when dropScheduledDate is true', () => {
232+
describe('Recurrence - with removeScheduledDateOnRecurrence', () => {
233+
it('should remove the scheduledDate when removeScheduledDate is true', () => {
234234
// Arrange
235235
const recurrence = Recurrence.fromText({
236236
recurrenceRuleText: 'every month',
@@ -250,7 +250,7 @@ describe('Recurrence - with dropScheduledDateOnRecurrence', () => {
250250
expect(next!.dueDate).toEqualMoment(moment('2022-02-10'));
251251
});
252252

253-
it('does not drop the scheduledDate when it is the only date', () => {
253+
it('should not remove the scheduledDate when it is the only date', () => {
254254
// Arrange
255255
const recurrence = Recurrence.fromText({
256256
recurrenceRuleText: 'every month',

0 commit comments

Comments
 (0)