Skip to content

Commit d33953d

Browse files
committed
refactor: add normal and reverse task grouping functions
1 parent 2628ed3 commit d33953d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Query/Filter/Field.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,24 @@ export abstract class Field {
364364

365365
return new RegExp(`^group by ${this.fieldNameSingularEscaped()}( reverse)?$`);
366366
}
367+
368+
/**
369+
* Create a {@link Grouper} object for grouping tasks by this field's value,
370+
* in the standard/normal group order for this field.
371+
*
372+
* @see {@link createReverseGrouper}
373+
*/
374+
public createNormalGrouper(): Grouper {
375+
return this.createGrouper(false);
376+
}
377+
378+
/**
379+
* Create a {@link Grouper} object for grouping tasks by this field's value,
380+
* in the reverse of the standard/normal group order for this field.
381+
*
382+
* @see {@link createNormalGrouper}
383+
*/
384+
public createReverseGrouper(): Grouper {
385+
return this.createGrouper(true);
386+
}
367387
}

tests/TaskGroups.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ describe('Grouping tasks', () => {
246246
});
247247
const tasks = [t1, t2, t3];
248248

249-
const grouping: Grouper[] = [new FolderField().createGrouper(true), new FilenameField().createGrouper()];
249+
const grouping: Grouper[] = [
250+
new FolderField().createReverseGrouper(),
251+
new FilenameField().createNormalGrouper(),
252+
];
250253

251254
// Act
252255
const groups = new TaskGroups(grouping, tasks);

0 commit comments

Comments
 (0)