File tree Expand file tree Collapse file tree 7 files changed +51
-7
lines changed Expand file tree Collapse file tree 7 files changed +51
-7
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export interface Settings {
76
76
filenameAsScheduledDateFormat : string ;
77
77
filenameAsDateFolders : string [ ] ;
78
78
recurrenceOnNextLine : boolean ;
79
+ dropScheduledDateOnRecurrence : boolean ;
79
80
80
81
// The custom status states.
81
82
statusSettings : StatusSettings ;
@@ -110,6 +111,7 @@ const defaultSettings: Settings = {
110
111
filenameAsScheduledDateFormat : '' ,
111
112
filenameAsDateFolders : [ ] ,
112
113
recurrenceOnNextLine : false ,
114
+ dropScheduledDateOnRecurrence : false ,
113
115
statusSettings : new StatusSettings ( ) ,
114
116
features : Feature . settingsFlags ,
115
117
generalSettings : {
Original file line number Diff line number Diff line change @@ -376,6 +376,19 @@ export class SettingsTab extends PluginSettingTab {
376
376
} ) ;
377
377
} ) ;
378
378
379
+ new Setting ( containerEl )
380
+ . setName ( i18n . t ( 'settings.recurringTasks.dropScheduledDate.name' ) )
381
+ . setDesc (
382
+ SettingsTab . createFragmentWithHTML ( i18n . t ( 'settings.recurringTasks.dropScheduledDate.description' ) ) ,
383
+ )
384
+ . addToggle ( ( toggle ) => {
385
+ const { dropScheduledDateOnRecurrence } = getSettings ( ) ;
386
+ toggle . setValue ( dropScheduledDateOnRecurrence ) . onChange ( async ( value ) => {
387
+ updateSettings ( { dropScheduledDateOnRecurrence : value } ) ;
388
+ await this . plugin . saveSettings ( ) ;
389
+ } ) ;
390
+ } ) ;
391
+
379
392
// ---------------------------------------------------------------------------
380
393
new Setting ( containerEl ) . setName ( i18n . t ( 'settings.autoSuggest.heading' ) ) . setHeading ( ) ;
381
394
// ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ export class Occurrence {
88
88
*
89
89
* @param nextReferenceDate
90
90
*/
91
- public next ( nextReferenceDate : Date ) : Occurrence {
91
+ public next ( nextReferenceDate : Date , dropScheduledDate : boolean = false ) : Occurrence {
92
92
// Only if a reference date is given. A reference date will exist if at
93
93
// least one of the other dates is set.
94
94
if ( this . referenceDate === null ) {
@@ -99,10 +99,14 @@ export class Occurrence {
99
99
} ) ;
100
100
}
101
101
102
+ const startDate = this . nextOccurrenceDate ( this . startDate , nextReferenceDate ) ;
103
+ const scheduledDate = dropScheduledDate ? null : this . nextOccurrenceDate ( this . scheduledDate , nextReferenceDate ) ;
104
+ const dueDate = this . nextOccurrenceDate ( this . dueDate , nextReferenceDate ) ;
105
+
102
106
return new Occurrence ( {
103
- startDate : this . nextOccurrenceDate ( this . startDate , nextReferenceDate ) ,
104
- scheduledDate : this . nextOccurrenceDate ( this . scheduledDate , nextReferenceDate ) ,
105
- dueDate : this . nextOccurrenceDate ( this . dueDate , nextReferenceDate ) ,
107
+ startDate,
108
+ scheduledDate,
109
+ dueDate,
106
110
} ) ;
107
111
}
108
112
Original file line number Diff line number Diff line change @@ -73,14 +73,14 @@ export class Recurrence {
73
73
*
74
74
* @param today - Optional date representing the completion date. Defaults to today.
75
75
*/
76
- public next ( today = window . moment ( ) ) : Occurrence | null {
76
+ public next ( today = window . moment ( ) , dropScheduledDate : boolean = false ) : Occurrence | null {
77
77
const nextReferenceDate = this . nextReferenceDate ( today ) ;
78
78
79
79
if ( nextReferenceDate === null ) {
80
80
return null ;
81
81
}
82
82
83
- return this . occurrence . next ( nextReferenceDate ) ;
83
+ return this . occurrence . next ( nextReferenceDate , dropScheduledDate ) ;
84
84
}
85
85
86
86
public identicalTo ( other : Recurrence ) {
Original file line number Diff line number Diff line change @@ -377,7 +377,8 @@ export class Task extends ListItem {
377
377
return [ toggledTask ] ;
378
378
}
379
379
380
- const nextOccurrence = this . recurrence . next ( today ) ;
380
+ const { dropScheduledDateOnRecurrence } = getSettings ( ) ;
381
+ const nextOccurrence = this . recurrence . next ( today , dropScheduledDateOnRecurrence ) ;
381
382
if ( nextOccurrence === null ) {
382
383
return [ toggledTask ] ;
383
384
}
Original file line number Diff line number Diff line change 180
180
"nextLine" : {
181
181
"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." ,
182
182
"name" : " Next recurrence appears on the line below"
183
+ },
184
+ "dropScheduledDate" : {
185
+ "description" : " Enabling this will make the next recurrence of a task have no scheduled date." ,
186
+ "name" : " Drop scheduled date on recurrence"
183
187
}
184
188
},
185
189
"seeTheDocumentation" : " See the documentation" ,
Original file line number Diff line number Diff line change @@ -228,3 +228,23 @@ describe('identicalTo', () => {
228
228
expect ( date1Recurrence ?. identicalTo ( date2Recurrence ) ) . toBe ( false ) ;
229
229
} ) ;
230
230
} ) ;
231
+
232
+ describe ( 'Recurrence - with dropScheduledDateOnRecurrence' , ( ) => {
233
+ it ( 'drops the scheduledDate when dropScheduledDate is true' , ( ) => {
234
+ // Arrange
235
+ const recurrence = Recurrence . fromText ( {
236
+ recurrenceRuleText : 'every month' ,
237
+ occurrence : new Occurrence ( {
238
+ startDate : moment ( '2022-01-01' ) . startOf ( 'day' ) ,
239
+ scheduledDate : moment ( '2022-01-04' ) . startOf ( 'day' ) ,
240
+ dueDate : moment ( '2022-01-10' ) . startOf ( 'day' ) ,
241
+ } ) ,
242
+ } ) ;
243
+
244
+ // Act
245
+ const next = recurrence ! . next ( undefined , true ) ;
246
+
247
+ // Assert
248
+ expect ( next ! . scheduledDate ) . toBeNull ( ) ;
249
+ } ) ;
250
+ } ) ;
You can’t perform that action at this time.
0 commit comments