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

Commit b7a6071

Browse files
committed
Merge branch '39-fr-select-a-file-as-template-and-create-the-columns-based-on-the-fields'
2 parents ed2e535 + 920127b commit b7a6071

12 files changed

+288
-103
lines changed

docs/docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## 1.7.1
22
### Improved
33
- Now select source tags will be ordered alphabetically and the number of tags will be shown. [ISSUE#76](https://github.com/RafaelGB/obsidian-db-folder/issues/76)
4+
## Visual
5+
- Tag options supports dark mode [PR](https://github.com/RafaelGB/obsidian-db-folder/pull/133)[ISSUE#124](https://github.com/RafaelGB/obsidian-db-folder/issues/124) [artisticat1](https://github.com/artisticat1)
6+
- Freeze column gap fixed [ISSUE#120](https://github.com/RafaelGB/obsidian-db-folder/issues/120) [artisticat1](https://github.com/artisticat1)
7+
- Improvements of compact row mode [artisticat1](https://github.com/artisticat1)
48
### No longer broken
59
- More that one filter can be applied again to the same source. [ISSUE#113](https://github.com/RafaelGB/obsidian-db-folder/issues/113)
610
- You can not order by tags because was not prepared to do it yet (crashed). [ISSUE#119](https://github.com/RafaelGB/obsidian-db-folder/issues/119)

src/cdm/HeaderActionModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type HeaderActionResponse = {
1212
columnWidthState: ColumnWidthState,
1313
setKeyState: (a: string) => void,
1414
keyState: string,
15+
[key: string]: any | ((a: any) => void)
1516
}
1617
}
1718

src/components/HeaderMenu.tsx

Lines changed: 18 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import {
55
StyleVariables,
66
} from "helpers/Constants";
77
import { dbTrim, c, getLabelHeader } from "helpers/StylesHelper";
8-
import TrashIcon from "components/img/Trash";
9-
import TextIcon from "components/img/Text";
10-
import MultiIcon from "components/img/Multi";
118
import HashIcon from "components/img/Hash";
12-
import TaskIcon from "components/img/TaskIcon";
13-
import TagsIcon from "components/img/TagsIcon";
149
import CalendarTimeIcon from "components/img/CalendarTime";
1510
import CalendarIcon from "components/img/CalendarIcon";
1611
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
@@ -21,8 +16,9 @@ import { HeaderContext } from "components/contexts/HeaderContext";
2116
import { getColumnWidthStyle } from "components/styles/ColumnWidthStyle";
2217
import { ColumnModal } from "./modals/ColumnModal";
2318
import { HeaderMenuProps } from "cdm/HeaderModel";
24-
import header_action_button_section from "components/headerActions/HeaderActionSections";
19+
import header_action_button_section from "components/headerActions/HeaderActionButtonSection";
2520
import { HeaderActionResponse } from "cdm/HeaderActionModel";
21+
import header_action_types_section from "components/headerActions/HeaderActiontypesSection";
2622

2723
const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
2824
/** state of width columns */
@@ -80,9 +76,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
8076
/**
8177
* Array of action buttons asociated to the header
8278
*/
83-
const initButtons: any[] = [];
8479
let headerActionResponse: HeaderActionResponse = {
85-
buttons: initButtons,
80+
buttons: [],
8681
headerMenuProps: headerMenuProps,
8782
hooks: {
8883
setSortBy: setSortBy,
@@ -93,105 +88,25 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
9388
setKeyState: setkeyState,
9489
},
9590
};
96-
headerActionResponse = header_action_button_section.run(headerActionResponse);
91+
const headerButtons =
92+
header_action_button_section.run(headerActionResponse).buttons;
9793

9894
/**
9995
* Array of type headers available to change the data type of the column
10096
*/
101-
const types = [
102-
{
103-
onClick: (e: any) => {
104-
dispatch({
105-
type: ActionTypes.UPDATE_COLUMN_TYPE,
106-
columnId: column.id,
107-
dataType: DataTypes.SELECT,
108-
});
109-
setShowType(false);
110-
setExpanded(false);
111-
},
112-
icon: <MultiIcon />,
113-
label: DataTypes.SELECT,
114-
},
115-
{
116-
onClick: (e: any) => {
117-
dispatch({
118-
type: ActionTypes.UPDATE_COLUMN_TYPE,
119-
columnId: column.id,
120-
dataType: DataTypes.TAGS,
121-
});
122-
setShowType(false);
123-
setExpanded(false);
124-
},
125-
icon: <TagsIcon />,
126-
label: DataTypes.TAGS,
127-
},
128-
{
129-
onClick: (e: any) => {
130-
dispatch({
131-
type: ActionTypes.UPDATE_COLUMN_TYPE,
132-
columnId: column.id,
133-
dataType: DataTypes.TEXT,
134-
});
135-
setShowType(false);
136-
setExpanded(false);
137-
},
138-
icon: <TextIcon />,
139-
label: DataTypes.TEXT,
140-
},
141-
{
142-
onClick: (e: any) => {
143-
dispatch({
144-
type: ActionTypes.UPDATE_COLUMN_TYPE,
145-
columnId: column.id,
146-
dataType: DataTypes.NUMBER,
147-
});
148-
setShowType(false);
149-
setExpanded(false);
150-
},
151-
icon: <HashIcon />,
152-
label: DataTypes.NUMBER,
153-
},
154-
{
155-
onClick: (e: any) => {
156-
dispatch({
157-
type: ActionTypes.UPDATE_COLUMN_TYPE,
158-
columnId: column.id,
159-
dataType: DataTypes.CALENDAR,
160-
});
161-
setShowType(false);
162-
setExpanded(false);
163-
},
164-
icon: <CalendarIcon />,
165-
label: MetadataLabels.CALENDAR,
166-
},
167-
{
168-
onClick: (e: any) => {
169-
dispatch({
170-
type: ActionTypes.UPDATE_COLUMN_TYPE,
171-
columnId: column.id,
172-
dataType: DataTypes.CALENDAR_TIME,
173-
});
174-
setShowType(false);
175-
setExpanded(false);
176-
},
177-
icon: <CalendarTimeIcon />,
178-
label: MetadataLabels.CALENDAR_TIME,
179-
},
180-
,
181-
{
182-
onClick: (e: any) => {
183-
dispatch({
184-
type: ActionTypes.UPDATE_COLUMN_TYPE,
185-
columnId: column.id,
186-
dataType: DataTypes.CHECKBOX,
187-
});
188-
setShowType(false);
189-
setExpanded(false);
190-
},
191-
icon: <TaskIcon />,
192-
label: DataTypes.CHECKBOX,
97+
headerActionResponse = {
98+
buttons: [],
99+
headerMenuProps: headerMenuProps,
100+
hooks: {
101+
setSortBy: setSortBy,
102+
setExpanded: setExpanded,
103+
setColumnWidthState: setColumnWidthState,
104+
columnWidthState: columnWidthState,
105+
keyState: keyState,
106+
setKeyState: setkeyState,
193107
},
194-
];
108+
};
109+
const types = header_action_types_section.run(headerActionResponse).buttons;
195110

196111
const typePopper = usePopper(typeReferenceElement, typePopperElement, {
197112
placement: "right",
@@ -382,7 +297,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
382297
padding: "4px 0px",
383298
}}
384299
>
385-
{headerActionResponse.buttons.map((button) => (
300+
{headerButtons.map((button) => (
386301
<div
387302
key={button.label}
388303
className="menu-item sort-button"

src/components/headerActions/HeaderActionSections.ts renamed to src/components/headerActions/HeaderActionButtonSection.ts

File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractChain, AbstractHandler } from "patterns/AbstractFactoryChain";
3+
import CheckboxTypeHandlerAction from "components/headerActions/handlers/types/CheckboxTypeHeaderAction";
4+
import TextTypeHeaderAction from "components/headerActions/handlers/types/TextTypeHeaderAction";
5+
import SelectTypeHeaderAction from "components/headerActions/handlers/types/SelectTypeHeaderAction";
6+
import TagsTypeHeaderAction from "components/headerActions/handlers/types/TagsTypeHeaderAction";
7+
import NumberTypeHeaderAction from "components/headerActions/handlers/types/NumberTypeHeaderAction";
8+
import DateTypeHeaderAction from "components/headerActions/handlers/types/DateTypeHeaderAction";
9+
import DatetimeTypeHeaderAction from "components/headerActions/handlers/types/DatetimeTypeHeaderAction";
10+
class HeaderActionTypesSection extends AbstractChain<HeaderActionResponse> {
11+
protected customHandle(abstractResponse: HeaderActionResponse): HeaderActionResponse {
12+
return abstractResponse;
13+
}
14+
15+
protected getHandlers(): AbstractHandler<HeaderActionResponse>[] {
16+
return [
17+
new TextTypeHeaderAction(),
18+
new NumberTypeHeaderAction(),
19+
new SelectTypeHeaderAction(),
20+
new TagsTypeHeaderAction(),
21+
new CheckboxTypeHandlerAction(),
22+
new DateTypeHeaderAction(),
23+
new DatetimeTypeHeaderAction(),
24+
];
25+
}
26+
}
27+
28+
const header_action_types_section = new HeaderActionTypesSection();
29+
export default header_action_types_section;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { generateSortedColumns } from "components/behavior/SortingColumns";
3+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
4+
import CrossIcon from "components/img/CrossIcon";
5+
import ArrowUpIcon from "components/img/ArrowUp";
6+
import ArrowDownIcon from "components/img/ArrowDown";
7+
import React from "react";
8+
import { ActionTypes, DataTypes } from "helpers/Constants";
9+
import TaskIcon from "components/img/TaskIcon";
10+
11+
export default class CheckboxTypeHandlerAction extends AbstractHeaderAction {
12+
globalHeaderActionResponse: HeaderActionResponse;
13+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
14+
this.globalHeaderActionResponse = headerActionResponse;
15+
this.addCheckboxType();
16+
return this.goNext(this.globalHeaderActionResponse);
17+
}
18+
private addCheckboxType() {
19+
const { hooks } = this.globalHeaderActionResponse;
20+
const { initialState, column } =
21+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
22+
const checkBoxType = {
23+
onClick: (e: any) => {
24+
initialState.dispatch({
25+
type: ActionTypes.UPDATE_COLUMN_TYPE,
26+
columnId: column.id,
27+
dataType: DataTypes.CHECKBOX,
28+
});
29+
hooks.setShowType(false);
30+
hooks.setExpanded(false);
31+
},
32+
icon: <TaskIcon />,
33+
label: DataTypes.CHECKBOX,
34+
};
35+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
36+
}
37+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import CalendarIcon from "components/img/CalendarIcon";
4+
import React from "react";
5+
import { ActionTypes, DataTypes, MetadataLabels } from "helpers/Constants";
6+
7+
export default class DateTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addDateType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addDateType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const checkBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.CALENDAR,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <CalendarIcon />,
29+
label: MetadataLabels.CALENDAR,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
32+
}
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import React from "react";
4+
import { ActionTypes, DataTypes, MetadataLabels } from "helpers/Constants";
5+
import TaskIcon from "components/img/TaskIcon";
6+
import CalendarTimeIcon from "components/img/CalendarTime";
7+
8+
export default class DatetimeTypeHeaderAction extends AbstractHeaderAction {
9+
globalHeaderActionResponse: HeaderActionResponse;
10+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
11+
this.globalHeaderActionResponse = headerActionResponse;
12+
this.addDatetimeType();
13+
return this.goNext(this.globalHeaderActionResponse);
14+
}
15+
private addDatetimeType() {
16+
const { hooks } = this.globalHeaderActionResponse;
17+
const { initialState, column } =
18+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
19+
const checkBoxType = {
20+
onClick: (e: any) => {
21+
initialState.dispatch({
22+
type: ActionTypes.UPDATE_COLUMN_TYPE,
23+
columnId: column.id,
24+
dataType: DataTypes.CALENDAR_TIME,
25+
});
26+
hooks.setShowType(false);
27+
hooks.setExpanded(false);
28+
},
29+
icon: <CalendarTimeIcon />,
30+
label: MetadataLabels.CALENDAR_TIME,
31+
};
32+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import HashIcon from "components/img/Hash";
4+
import React from "react";
5+
import { ActionTypes, DataTypes } from "helpers/Constants";
6+
7+
export default class NumberTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addNumberType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addNumberType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const checkBoxType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.NUMBER,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <HashIcon />,
29+
label: DataTypes.NUMBER,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(checkBoxType);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HeaderActionResponse } from "cdm/HeaderActionModel";
2+
import { AbstractHeaderAction } from "components/headerActions/handlers/AbstractHeaderAction";
3+
import MultiIcon from "components/img/Multi";
4+
import React from "react";
5+
import { ActionTypes, DataTypes } from "helpers/Constants";
6+
7+
export default class SelectTypeHeaderAction extends AbstractHeaderAction {
8+
globalHeaderActionResponse: HeaderActionResponse;
9+
handle(headerActionResponse: HeaderActionResponse): HeaderActionResponse {
10+
this.globalHeaderActionResponse = headerActionResponse;
11+
this.addSelectType();
12+
return this.goNext(this.globalHeaderActionResponse);
13+
}
14+
private addSelectType() {
15+
const { hooks } = this.globalHeaderActionResponse;
16+
const { initialState, column } =
17+
this.globalHeaderActionResponse.headerMenuProps.headerProps;
18+
const selectType = {
19+
onClick: (e: any) => {
20+
initialState.dispatch({
21+
type: ActionTypes.UPDATE_COLUMN_TYPE,
22+
columnId: column.id,
23+
dataType: DataTypes.SELECT,
24+
});
25+
hooks.setShowType(false);
26+
hooks.setExpanded(false);
27+
},
28+
icon: <MultiIcon />,
29+
label: DataTypes.SELECT,
30+
};
31+
this.globalHeaderActionResponse.buttons.push(selectType);
32+
}
33+
}

0 commit comments

Comments
 (0)