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

Commit 9f75b6c

Browse files
committed
Merge branch 'feature/date_improvements'
2 parents f145290 + 4438d22 commit 9f75b6c

20 files changed

+1101
-1030
lines changed

package-lock.json

Lines changed: 980 additions & 964 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,46 @@
2828
"@rollup/plugin-terser": "0.4.0",
2929
"@testing-library/jest-dom": "5.16.5",
3030
"@testing-library/react": "14.0.0",
31-
"@types/jest": "29.4.0",
31+
"@types/jest": "29.5.0",
3232
"@types/luxon": "3.2.0",
33-
"@types/node": "18.14.1",
33+
"@types/node": "18.15.3",
3434
"@types/react": "18.0.28",
35-
"@types/react-datepicker": "4.8.0",
35+
"@types/react-datepicker": "4.10.0",
3636
"@types/react-dom": "18.0.11",
3737
"@types/react-window": "1.8.5",
3838
"@types/papaparse": "5.3.7",
39-
"@typescript-eslint/eslint-plugin": "5.53.0",
40-
"@typescript-eslint/parser": "5.53.0",
41-
"eslint": "8.34.0",
42-
"jest": "29.4.3",
43-
"jest-mock-extended": "3.0.2",
44-
"jest-environment-jsdom": "29.4.3",
39+
"@typescript-eslint/eslint-plugin": "5.56.0",
40+
"@typescript-eslint/parser": "5.56.0",
41+
"eslint": "8.36.0",
42+
"jest": "29.5.0",
43+
"jest-mock-extended": "3.0.3",
44+
"jest-environment-jsdom": "29.5.0",
4545
"obsidian": "1.1.1",
46-
"rollup": "3.17.3",
46+
"rollup": "3.20.0",
4747
"rollup-plugin-typescript2": "0.34.1",
4848
"ts-jest": "29.0.5",
4949
"tslib": "2.5.0",
5050
"typescript": "4.9.5"
5151
},
5252
"dependencies": {
5353
"@emotion/styled": "11.10.6",
54-
"@mui/icons-material": "5.11.9",
55-
"@mui/material": "5.11.10",
54+
"@mui/icons-material": "5.11.11",
55+
"@mui/material": "5.11.13",
5656
"@popperjs/core": "2.11.6",
5757
"@tanstack/match-sorter-utils": "8.7.6",
5858
"@tanstack/react-table": "8.7.9",
5959
"eventemitter3": "5.0.0",
6060
"fuse.js": "6.6.2",
61-
"luxon": "3.2.1",
61+
"luxon": "3.3.0",
6262
"monkey-around": "2.3.0",
6363
"obsidian-dataview": "0.5.55",
6464
"obsidian-projects-types": "0.7.1",
6565
"react": "18.2.0",
66-
"papaparse": "5.3.2",
66+
"papaparse": "5.4.0",
6767
"react-datepicker": "4.10.0",
6868
"react-dom": "18.2.0",
69-
"react-select": "5.7.0",
69+
"react-select": "5.7.1",
7070
"react-window": "1.8.8",
71-
"zustand": "4.3.3"
71+
"zustand": "4.3.6"
7272
}
7373
}

src/IO/md/handlers/marshall/MarshallFiltersHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DatabaseYaml } from 'cdm/DatabaseModel';
22
import { YamlHandlerResponse } from 'cdm/MashallModel';
33
import { AtomicFilter, FilterGroup, FilterGroupCondition } from 'cdm/SettingsModel';
4+
import { InputType } from 'helpers/Constants';
45
import { AbstractYamlHandler } from 'IO/md/handlers/marshall/AbstractYamlPropertyHandler';
56
import { DataviewService } from 'services/DataviewService';
67

@@ -59,6 +60,10 @@ export class MarshallFiltersHandler extends AbstractYamlHandler {
5960
this.addError(`There was not operator key in filter: ${JSON.stringify(filter)}`);
6061
return false;
6162
}
63+
// Type of filter: Optional (if not present, it will be set to TEXT)
64+
if (!DataviewService.isTruthy((filter as AtomicFilter).type)) {
65+
(filter as AtomicFilter).type = InputType.TEXT;
66+
}
6267
}
6368
return true;
6469
}

src/IO/md/handlers/unmarshall/UnmarshallFiltersHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class UnmarshallFiltersHandler extends AbstractDiskHandler {
5353
this.localDisk.push(`${YAML_INDENT.repeat(indentLevel)}- field: ${(filter as AtomicFilter).field}`);
5454
this.localDisk.push(`${YAML_INDENT.repeat(indentLevel)} operator: ${(filter as AtomicFilter).operator}`);
5555
this.localDisk.push(`${YAML_INDENT.repeat(indentLevel)} value: "${(filter as AtomicFilter).value ?? ''}"`);
56+
this.localDisk.push(`${YAML_INDENT.repeat(indentLevel)} type: ${(filter as AtomicFilter).type}`);
5657
}
5758
}
5859
}

src/cdm/ComponentsModel.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CellContext, Table } from "@tanstack/react-table";
22
import { RowDataType } from "cdm/FolderModel";
33
import { Link, Literal } from "obsidian-dataview/lib/data-model/value";
4-
import { AtomicFilter } from "cdm/SettingsModel";
4+
import { AtomicFilter, FilterGroup } from "cdm/SettingsModel";
55

66
export type ColumnOption = {
77
value: string;
@@ -37,5 +37,19 @@ export type AtomicFilterComponentProps = {
3737
recursiveIndex: number[];
3838
level: number;
3939
atomicFilter: AtomicFilter;
40-
possibleColumns: string[];
41-
} & DataviewFiltersProps;
40+
possibleColumns: ColumnFilterOption[];
41+
} & DataviewFiltersProps;
42+
43+
export type ColumnFilterOption = {
44+
key: string;
45+
enabled: boolean;
46+
type: string;
47+
}
48+
49+
export type GroupFilterComponentProps = {
50+
group: FilterGroup;
51+
recursiveIndex: number[];
52+
level: number;
53+
table: Table<RowDataType>;
54+
possibleColumns: ColumnFilterOption[];
55+
};

src/cdm/SettingsModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type FilterGroupCondition = {
1717
export type AtomicFilter = {
1818
field: string;
1919
operator: string;
20+
type: string;
2021
value?: string;
2122
}
2223
/**

src/components/cellTypes/TaskCell.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ const TaskCell = (taskProps: CellComponentProps) => {
1414
const { defaultCell } = taskProps;
1515
const { cell, column, table, row } = defaultCell;
1616
const { view } = table.options.meta;
17+
const tableColumn = column.columnDef as TableColumn;
1718
useEffect(() => {
1819
let taskValue = cell.getValue();
1920
// Check if there are tasks in the cell
2021
if (taskValue) {
2122
taskRef.current.innerHTML = "";
2223
if (
23-
(column.columnDef as TableColumn).config.task_hide_completed &&
24-
DataviewService.getDataviewAPI().isDataArray(taskValue)
24+
tableColumn.config.task_hide_completed &&
25+
DataviewService.isDataArray(taskValue)
2526
) {
2627
taskValue = taskValue
2728
.where((t: STask) => !t.completed)

src/components/modals/filters/handlers/AddNewFilterHandler.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "cdm/ModalsModel";
66
import {
77
ConditionFiltersOptions,
8+
InputType,
89
OperatorFilter,
910
StyleVariables,
1011
} from "helpers/Constants";
@@ -50,6 +51,7 @@ const NewFiltersForm = (props: FiltersModalProps) => {
5051
field: possibleColumns[0],
5152
operator: OperatorFilter.CONTAINS[0],
5253
value: "",
54+
type: InputType.TEXT,
5355
});
5456
configActions.alterFilters(alteredFilterState);
5557
};
@@ -67,6 +69,7 @@ const NewFiltersForm = (props: FiltersModalProps) => {
6769
field: possibleColumns[0],
6870
operator: OperatorFilter.CONTAINS[0],
6971
value: "",
72+
type: InputType.TEXT,
7073
};
7174

7275
alteredFilterState.conditions.push({

src/components/modals/filters/handlers/AtomicFilterComponent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import IconButton from "@mui/material/IconButton";
1515
const AtomicFilterComponent = (props: AtomicFilterComponentProps) => {
1616
const { table, recursiveIndex, level, atomicFilter, possibleColumns } = props;
1717
const { tableState } = table.options.meta;
18-
const { field, operator, value } = atomicFilter;
18+
const { field, operator, value, type } = atomicFilter;
1919
const configActions = tableState.configState((state) => state.actions);
2020
const configInfo = tableState.configState((state) => state.info);
2121
const columnsInfo = tableState.columns((state) => state.info);
@@ -118,6 +118,7 @@ const AtomicFilterComponent = (props: AtomicFilterComponentProps) => {
118118
>
119119
<ValueFilterComponent
120120
value={value}
121+
type={type}
121122
handler={onChangeFilterValueHandler(recursiveIndex, level)}
122123
/>
123124
</Grid>

src/components/modals/filters/handlers/DataviewFiltersComponent.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { DataviewFiltersProps } from "cdm/ComponentsModel";
1+
import { ColumnFilterOption, DataviewFiltersProps } from "cdm/ComponentsModel";
22
import { obtainColumnsFromRows } from "components/Columns";
33
import React, { useEffect, useState } from "react";
44
import { FilterGroupCondition } from "cdm/SettingsModel";
55
import GroupFilterComponent from "components/modals/filters/handlers/GroupFilterComponent";
66
import DnDComponent from "components/behavior/DnDComponent";
7+
import { InputType } from "helpers/Constants";
78

89
const DataviewFiltersComponent = (props: DataviewFiltersProps) => {
910
const { table } = props;
@@ -13,8 +14,10 @@ const DataviewFiltersComponent = (props: DataviewFiltersProps) => {
1314
const filters = tableState.configState((state) => state.filters);
1415
const columnsInfo = tableState.columns((state) => state.info);
1516

16-
const [possibleColumns, setPossibleColumns] = useState([] as string[]);
17-
17+
const [possibleColumns, setPossibleColumns] = useState(
18+
[] as ColumnFilterOption[]
19+
);
20+
const DbColumns = columnsInfo.getAllColumns();
1821
useEffect(() => {
1922
new Promise<string[]>((resolve) => {
2023
// Empty conditions to refresh the dataview
@@ -25,11 +28,25 @@ const DataviewFiltersComponent = (props: DataviewFiltersProps) => {
2528
view.file.parent.path,
2629
configInfo.getLocalSettings(),
2730
emptyFilterConditions,
28-
columnsInfo.getAllColumns()
31+
DbColumns
2932
)
3033
);
3134
}).then((columns) => {
32-
setPossibleColumns(columns.sort((a, b) => a.localeCompare(b)));
35+
const columnOptions: ColumnFilterOption[] = [];
36+
columns.forEach((column) => {
37+
const possibleColumn = DbColumns.find(
38+
(dbColumn) => dbColumn.key === column
39+
);
40+
const isColumnExistent = possibleColumn !== undefined;
41+
columnOptions.push({
42+
enabled: isColumnExistent,
43+
key: column,
44+
type: isColumnExistent ? possibleColumn.input : InputType.TEXT,
45+
});
46+
});
47+
setPossibleColumns(
48+
columnOptions.sort((a, b) => a.key.localeCompare(b.key))
49+
);
3350
});
3451
}, []);
3552

0 commit comments

Comments
 (0)