Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 7c62b3b

Browse files
committed
working
1 parent 2400f7d commit 7c62b3b

File tree

8 files changed

+68
-34
lines changed

8 files changed

+68
-34
lines changed

docs/docs/changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
- New source option: query. Use your own dataview query as source of the database. Start the query with the `FROM` term, since the plugin will autocomplete the beginning with `TABLE` and the column fields[ISSUE#156](https://github.com/RafaelGB/obsidian-db-folder/issues/156)
44
- Templates for new rows added! now you can choose a template folder on settings menu, then you can choose your template file easily near of the add row button[ISSUE#48](https://github.com/RafaelGB/obsidian-db-folder/issues/48)
55
### Improved
6-
- Inline fields now supports render embed images with ![[note]] syntax. [ISSUE#136](https://github.com/RafaelGB/obsidian-db-folder/issues/136)
6+
- Inline fields now supports render embed images with `![[note]]` syntax. [ISSUE#136](https://github.com/RafaelGB/obsidian-db-folder/issues/136)
7+
- Now you can hide completed task on task column type [ISSUE#111](https://github.com/RafaelGB/obsidian-db-folder/issues/111)
78
### No longer broken
89
- If you modify the label of a column, now exist an onMouseLeave event to blur the input and be more frieldly to the user interact with the next action without a double click (once for onBlur label edition and another for your next interaction) [ISSUE#114](https://github.com/RafaelGB/obsidian-db-folder/issues/114)
910
## 1.7.2

src/components/Cell.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export default function DefaultCell(cellProperties: Cell) {
5454
case DataTypes.TASK:
5555
// Check if there are tasks in the cell
5656
if (contextValue.value === "") break;
57+
taskRef.current.innerHTML = "";
58+
if (column.config.task_hide_completed) {
59+
contextValue.value = contextValue.value.where(
60+
(t: any) => !t.completed
61+
);
62+
}
5763
DataviewService.getDataviewAPI().taskList(
5864
contextValue.value,
5965
false,
@@ -244,6 +250,8 @@ export default function DefaultCell(cellProperties: Cell) {
244250
);
245251

246252
case DataTypes.TASK:
253+
if (column.config.task_hide_completed) {
254+
}
247255
return <div ref={taskRef} className="data-input"></div>;
248256

249257
case DataTypes.CHECKBOX:

src/components/Columns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function obtainMetadataColumns(
5151
}
5252

5353
if (localSetting.show_metadata_tasks) {
54-
// If Modified is not already in the table, add it
54+
// If TASKS is not already in the table, add it
5555
yamlColumns[MetadataColumns.TASKS] = {
5656
...MetadataDatabaseColumns.TASKS,
5757
...(yamlColumns[MetadataColumns.TASKS] ?? {}),

src/components/HeaderMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActionTypes, StyleVariables } from "helpers/Constants";
1+
import { ActionTypes, DataTypes, StyleVariables } from "helpers/Constants";
22
import { dbTrim, c, getLabelHeader } from "helpers/StylesHelper";
33
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
44
import React, { useContext, useEffect, useState } from "react";
@@ -278,7 +278,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
278278
</div>
279279
))}
280280
</div>
281-
{!column.isMetadata && (
281+
{(!column.isMetadata || column.dataType === DataTypes.TASK) && (
282282
<div
283283
style={{
284284
borderTop: `1px solid ${StyleVariables.BACKGROUND_DIVIDER}`,

src/components/modals/ColumnSections.ts

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ import { DataTypes } from "helpers/Constants";
1010
import { AbstractChain, AbstractHandler } from "patterns/AbstractFactoryChain";
1111

1212
class BehaviorSetttingsSection extends AbstractChain<ColumnHandlerResponse> {
13+
private dataType: string = DataTypes.TEXT;
14+
protected runBefore(columnHandlerResponse: ColumnHandlerResponse): ColumnHandlerResponse {
15+
this.dataType = columnHandlerResponse.column.dataType;
16+
return columnHandlerResponse;
17+
}
1318
protected customHandle(columnHandlerResponse: ColumnHandlerResponse): ColumnHandlerResponse {
1419
const behavior_section = columnHandlerResponse.containerEl.createDiv("column-section-container-behavior");
1520
add_setting_header(behavior_section, "Behavior", "h3");
1621
columnHandlerResponse.containerEl = behavior_section;
1722
return columnHandlerResponse;
1823
}
1924
protected getHandlers(): AbstractHandler<ColumnHandlerResponse>[] {
20-
return [
21-
new InlineToggleHandler()
22-
]
25+
const particularHandlers: ColumnHandler[] = [];
26+
switch (this.dataType) {
27+
case DataTypes.TASK:
28+
// do nothing
29+
break;
30+
default:
31+
particularHandlers.push(new InlineToggleHandler());
32+
}
33+
return particularHandlers;
2334
}
2435
}
2536
export const behavior_settings_section = new BehaviorSetttingsSection();
@@ -28,36 +39,36 @@ export const behavior_settings_section = new BehaviorSetttingsSection();
2839
* Every column type has a different behavior section
2940
*/
3041
class ParticularSetttingsSection extends AbstractChain<ColumnHandlerResponse> {
42+
private dataType: string = DataTypes.TEXT;
43+
protected runBefore(columnHandlerResponse: ColumnHandlerResponse): ColumnHandlerResponse {
44+
this.dataType = columnHandlerResponse.column.dataType;
45+
return columnHandlerResponse;
46+
}
47+
3148
protected customHandle(columnHandlerResponse: ColumnHandlerResponse): ColumnHandlerResponse {
3249
const particular_section = columnHandlerResponse.containerEl.createDiv("column-section-container-particular");
3350
// title of the section
3451
add_setting_header(particular_section, `Particular properties of "${columnHandlerResponse.column.dataType}" column type`, 'h3');
3552
columnHandlerResponse.containerEl = particular_section;
3653
return columnHandlerResponse;
3754
}
38-
protected getHandlers(option?: string): AbstractHandler<ColumnHandlerResponse>[] {
39-
return [
40-
new InlineToggleHandler()
41-
]
55+
protected getHandlers(): AbstractHandler<ColumnHandlerResponse>[] {
56+
const particularHandlers: ColumnHandler[] = [];
57+
switch (this.dataType) {
58+
case DataTypes.TEXT:
59+
particularHandlers.push(new MediaToggleHandler());
60+
particularHandlers.push(new MediaDimensionsHandler());
61+
break;
62+
case DataTypes.SELECT:
63+
case DataTypes.TAGS:
64+
particularHandlers.push(new SelectedColumnOptionsHandler());
65+
break;
66+
case DataTypes.TASK:
67+
particularHandlers.push(new HideCompletedTaskToggleHandler());
68+
default:
69+
break;
70+
}
71+
return particularHandlers;
4272
}
4373
}
44-
export const particular_settings_section = new ParticularSetttingsSection();
45-
46-
function addParticularInputSettings(dataType: string): ColumnHandler[] {
47-
const particularHandlers: ColumnHandler[] = [];
48-
switch (dataType) {
49-
case DataTypes.TEXT:
50-
particularHandlers.push(new MediaToggleHandler());
51-
particularHandlers.push(new MediaDimensionsHandler());
52-
break;
53-
case DataTypes.SELECT:
54-
case DataTypes.TAGS:
55-
particularHandlers.push(new SelectedColumnOptionsHandler());
56-
break;
57-
case DataTypes.TASK:
58-
particularHandlers.push(new HideCompletedTaskToggleHandler());
59-
default:
60-
break;
61-
}
62-
return particularHandlers;
63-
}
74+
export const particular_settings_section = new ParticularSetttingsSection();

src/helpers/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const MetadataDatabaseColumns: MetadataColumnsModel = Object.freeze({
123123
accessor: MetadataColumns.TASKS,
124124
isMetadata: true,
125125
isDragDisabled: false,
126-
skipPersist: true,
126+
skipPersist: false,
127127
csvCandidate: false,
128128
config: DEFAULT_COLUMN_CONFIG
129129
},

src/parsers/handlers/marshall/MarshallColumnsHandler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class MarshallColumnsHandler extends AbstractYamlHandler {
2626
// Check every column
2727
Object.keys(yaml.columns)
2828
.forEach((key) => {
29+
console.log(key);
2930
let column = yaml.columns[key];
3031
/** BASE COLUMN INFO */
3132
if (!column.input) {
@@ -47,10 +48,13 @@ export class MarshallColumnsHandler extends AbstractYamlHandler {
4748
this.addError(`There was not label in column ${key}`);
4849
column.label = key;
4950
}
51+
if (column.skipPersist === undefined) {
52+
column.skipPersist = false;
53+
}
54+
5055
/** CONFIG COLUMN INFO */
5156
if (!column.config && !(column.config instanceof Object)) {
5257
column.config = DEFAULT_COLUMN_CONFIG;
53-
column = column;
5458
} else {
5559
// General config
5660
if (column.config.isInline === undefined) {
@@ -109,6 +113,6 @@ function marshallParticularConfigInfo(column: DatabaseColumn): DatabaseColumn {
109113
column.config.task_hide_completed = DEFAULT_COLUMN_CONFIG.task_hide_completed;
110114
break;
111115
}
112-
return column;
113116
}
117+
return column;
114118
}

src/patterns/AbstractFactoryChain.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ export interface AbstractHandler<T> {
44
}
55

66
export abstract class AbstractChain<T> {
7+
/**
8+
* Implement this method to customize the chain response before the handlers are run
9+
* @param abstractResponse
10+
* @returns
11+
*/
12+
protected runBefore(abstractResponse: T): T {
13+
return abstractResponse;
14+
}
15+
716
public run(abstractResponse: T): T {
17+
abstractResponse = this.runBefore(abstractResponse);
818
// Obtain the group of handlers
919
const handlers = this.getHandlers();
1020
if (handlers.length > 0) {

0 commit comments

Comments
 (0)