Skip to content

Commit bc2ad50

Browse files
committed
refactor: - inline taskListHiddenClasses() method
1 parent 7b40149 commit bc2ad50

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Layout/TaskLayout.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class QueryLayout {
4444
}
4545
}
4646

47-
protected applyQueryLayoutOptions() {
47+
public applyQueryLayoutOptions() {
4848
const taskListHiddenClasses: string[] = [];
4949
const componentsToGenerateClassesOnly: [boolean, string][] = [
5050
// The following components are handled in QueryRenderer.ts and thus are not part of the same flow that
@@ -83,9 +83,6 @@ function hiddenComponentClassName(component: string) {
8383
* modified by applying {@link TaskLayoutOptions} objects.
8484
*/
8585
export class TaskLayout extends QueryLayout {
86-
public taskListHiddenClasses(): string[] {
87-
return [...this.applyTaskLayoutOptions(), ...this.applyQueryLayoutOptions()];
88-
}
8986
private taskLayoutOptions: TaskLayoutOptions;
9087

9188
constructor(taskLayoutOptions?: TaskLayoutOptions, queryLayoutOptions?: QueryLayoutOptions) {
@@ -97,7 +94,7 @@ export class TaskLayout extends QueryLayout {
9794
this.taskLayoutOptions = new TaskLayoutOptions();
9895
}
9996
}
100-
private applyTaskLayoutOptions() {
97+
public applyTaskLayoutOptions() {
10198
const taskListHiddenClasses: string[] = [];
10299
this.taskLayoutOptions.toggleableComponents.forEach((component) => {
103100
generateHiddenClassForTaskList(

src/Renderer/QueryRenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class QueryRenderChild extends MarkdownRenderChild {
224224
const layout = new TaskLayout(this.query.taskLayoutOptions, this.query.queryLayoutOptions);
225225
const taskList = content.createEl('ul');
226226
taskList.addClasses(['contains-task-list', 'plugin-tasks-query-result']);
227-
taskList.addClasses(layout.taskListHiddenClasses());
227+
taskList.addClasses([...layout.applyTaskLayoutOptions(), ...layout.applyQueryLayoutOptions()]);
228228
const groupingAttribute = this.getGroupingAttribute();
229229
if (groupingAttribute && groupingAttribute.length > 0) taskList.dataset.taskGroupBy = groupingAttribute;
230230

tests/Layout/TaskLayout.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { TaskLayout } from '../../src/Layout/TaskLayout';
99
describe('TaskLayout tests', () => {
1010
it('should generate expected CSS classes for default layout', () => {
1111
const taskLayout = new TaskLayout();
12-
expect(taskLayout.taskListHiddenClasses().join('\n')).toMatchInlineSnapshot('"tasks-layout-hide-urgency"');
12+
expect(
13+
[...taskLayout.applyTaskLayoutOptions(), ...taskLayout.applyQueryLayoutOptions()].join('\n'),
14+
).toMatchInlineSnapshot('"tasks-layout-hide-urgency"');
1315
});
1416

1517
it('should generate expected CSS classes with all default options reversed', () => {
@@ -25,7 +27,8 @@ describe('TaskLayout tests', () => {
2527

2628
const taskLayout = new TaskLayout(taskLayoutOptions, queryLayoutOptions);
2729

28-
expect(taskLayout.taskListHiddenClasses().join('\n')).toMatchInlineSnapshot(`
30+
expect([...taskLayout.applyTaskLayoutOptions(), ...taskLayout.applyQueryLayoutOptions()].join('\n'))
31+
.toMatchInlineSnapshot(`
2932
"tasks-layout-hide-id
3033
tasks-layout-hide-blockedBy
3134
tasks-layout-hide-priority

0 commit comments

Comments
 (0)