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

Commit 821441f

Browse files
committed
Merge branch '54-fr-checkbox-type-column'
2 parents 9810e5a + 9c4360d commit 821441f

File tree

17 files changed

+190
-58
lines changed

17 files changed

+190
-58
lines changed

docs/docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 1.4.0
2+
*Published on 2022/05/25*
3+
### Shiny new things
4+
- New metadata column: File tasks! You can see the tasks that are associated with each file and interact with them. Powered with tasklist render of dataview. [ISSUE#54](https://github.com/RafaelGB/obsidian-db-folder/issues/54)
5+
6+
### Improved
7+
- Extra margin added to the botton and top of every cell is removed. Markdown obsidian renderer add html tagging that affected the margin.[ISSUE#71](https://github.com/RafaelGB/obsidian-db-folder/issues/71)
8+
9+
### No longer broken
10+
- Column settings that has a type without behavior section produce a console error no more and section tittle is not shown.
111
## 1.3.2
212
*Published on 2022/05/24*
313
### Improved

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "dbfolder",
33
"name": "DB Folder",
4-
"version": "1.3.2",
4+
"version": "1.4.0",
55
"minAppVersion": "0.14.6",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dbfolder",
3-
"version": "1.3.2",
3+
"version": "1.4.0",
44
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/Settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface LocalSettings {
2929
remove_field_when_delete_column: boolean;
3030
show_metadata_created: boolean;
3131
show_metadata_modified: boolean;
32+
show_metadata_tasks: boolean;
3233
}
3334

3435
export interface DatabaseSettings {
@@ -52,6 +53,7 @@ export const DEFAULT_SETTINGS: DatabaseSettings = {
5253
group_folder_column: '',
5354
show_metadata_created: false,
5455
show_metadata_modified: false,
56+
show_metadata_tasks: false
5557
}
5658
};
5759

src/components/Cell.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import CalendarPortal from "./portals/CalendarPortal";
1010
import { TableColumn } from "cdm/FolderModel";
1111
import CalendarTimePortal from "components/portals/CalendarTimePortal";
1212
import { renderMarkdown } from "components/markdown/MarkdownRenderer";
13+
import { DataviewService } from "services/DataviewService";
1314

1415
export default function DefaultCell(cellProperties: Cell) {
1516
const dataDispatch = (cellProperties as any).dataDispatch;
@@ -24,6 +25,7 @@ export default function DefaultCell(cellProperties: Cell) {
2425
/** Ref to cell container */
2526
const containerCellRef = useRef<HTMLDivElement>();
2627
const editableMdRef = useRef<HTMLInputElement>();
28+
const taskRef = useRef<HTMLDivElement>();
2729
/** state of cell value */
2830
const [contextValue, setContextValue] = useState({
2931
value: initialValue,
@@ -38,11 +40,25 @@ export default function DefaultCell(cellProperties: Cell) {
3840
);
3941
// set contextValue when cell is loaded
4042
useEffect(() => {
41-
if (!dirtyCell && initialValue !== contextValue.value) {
42-
setContextValue({
43-
value: initialValue,
44-
update: false,
45-
});
43+
switch (dataType) {
44+
case DataTypes.TASK:
45+
//TODO - this is a hack. find why is layout effect called twice
46+
taskRef.current.innerHTML = "";
47+
DataviewService.getDataviewAPI().taskList(
48+
contextValue.value,
49+
false,
50+
taskRef.current,
51+
(cellProperties as any).initialState.view,
52+
(cellProperties as any).initialState.view.file.path
53+
);
54+
break;
55+
default:
56+
if (!dirtyCell && initialValue !== contextValue.value) {
57+
setContextValue({
58+
value: initialValue,
59+
update: false,
60+
});
61+
}
4662
}
4763
}, []);
4864

@@ -54,7 +70,6 @@ export default function DefaultCell(cellProperties: Cell) {
5470

5571
useEffect(() => {
5672
if (!dirtyCell && containerCellRef.current) {
57-
renderMarkdown;
5873
//TODO - this is a hack. find why is layout effect called twice
5974
containerCellRef.current.innerHTML = "";
6075
renderMarkdown(
@@ -190,6 +205,9 @@ export default function DefaultCell(cellProperties: Cell) {
190205
</CellContext.Provider>
191206
);
192207

208+
case DataTypes.TASK:
209+
return <div ref={taskRef} className="data-input"></div>;
210+
193211
/** Default option */
194212
default:
195213
LOGGER.warn(`Unknown data type: ${dataType}`);

src/components/Columns.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export async function obtainMetadataColumns(
4545
delete yamlColumns[MetadataColumns.MODIFIED];
4646
}
4747

48+
if (localSetting.show_metadata_tasks) {
49+
// If Modified is not already in the table, add it
50+
yamlColumns[MetadataColumns.TASKS] = {
51+
...MetadataDatabaseColumns.TASKS,
52+
...(yamlColumns[MetadataColumns.TASKS] ?? {}),
53+
};
54+
} else {
55+
delete yamlColumns[MetadataColumns.TASKS];
56+
}
57+
4858
yamlColumns[MetadataColumns.ADD_COLUMN] = MetadataDatabaseColumns.ADD_COLUMN;
4959
return yamlColumns;
5060
}

src/components/Header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import HeaderMenu from "components/HeaderMenu";
88
import CalendarIcon from "components/img/CalendarIcon";
99
import MarkdownObsidian from "components/img/Markdown";
1010
import CalendarTimeIcon from "components/img/CalendarTime";
11+
import TaskIcon from "components/img/TaskIcon";
1112
import {
1213
ActionTypes,
1314
DataTypes,
@@ -90,9 +91,11 @@ export default function Header(headerProps: DatabaseHeaderProps) {
9091
propertyIcon = <CalendarTimeIcon />;
9192
break;
9293
case DataTypes.MARKDOWN:
93-
// TODO : add a markdown icon
9494
propertyIcon = <MarkdownObsidian />;
9595
break;
96+
case DataTypes.TASK:
97+
propertyIcon = <TaskIcon />;
98+
break;
9699
default:
97100
break;
98101
}

src/components/HeaderMenu.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { HeaderContext } from "components/contexts/HeaderContext";
2323
import { getColumnWidthStyle } from "components/styles/ColumnWidthStyle";
2424
import { ColumnModal } from "./modals/ColumnModal";
2525
import { HeaderMenuProps } from "cdm/HeaderModel";
26+
import TaskIcon from "components/img/TaskIcon";
2627

2728
const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
2829
/** state of width columns */
@@ -80,23 +81,28 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
8081
/**
8182
* Array of action buttons asociated to the header
8283
*/
83-
const buttons = [
84-
{
85-
onClick: (e: any) => {
86-
setSortBy([{ id: column.id, desc: false }]);
87-
setExpanded(false);
88-
},
89-
icon: <ArrowUpIcon />,
90-
label: "Sort ascending",
91-
},
92-
{
93-
onClick: (e: any) => {
94-
setSortBy([{ id: column.id, desc: true }]);
95-
setExpanded(false);
84+
const buttons = [];
85+
if (column.dataType !== DataTypes.TASK) {
86+
buttons.push(
87+
{
88+
onClick: (e: any) => {
89+
setSortBy([{ id: column.id, desc: false }]);
90+
setExpanded(false);
91+
},
92+
icon: <ArrowUpIcon />,
93+
label: "Sort ascending",
9694
},
97-
icon: <ArrowDownIcon />,
98-
label: "Sort descending",
99-
},
95+
{
96+
onClick: (e: any) => {
97+
setSortBy([{ id: column.id, desc: true }]);
98+
setExpanded(false);
99+
},
100+
icon: <ArrowDownIcon />,
101+
label: "Sort descending",
102+
}
103+
);
104+
}
105+
buttons.push(
100106
{
101107
onClick: (e: any) => {
102108
dispatch({
@@ -122,8 +128,8 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
122128
},
123129
icon: <ArrowRightIcon />,
124130
label: "Insert right",
125-
},
126-
];
131+
}
132+
);
127133
/**
128134
* Add extra buttons if column is not a metadata
129135
*/

src/components/img/TaskIcon.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from "react";
2+
3+
export default function TaskIcon() {
4+
return (
5+
<svg
6+
width="24"
7+
height="24"
8+
viewBox="0 0 24 24"
9+
strokeWidth="2"
10+
stroke="currentColor"
11+
fill="none"
12+
strokeLinecap="round"
13+
strokeLinejoin="round"
14+
>
15+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
16+
<path d="M13 5h8" />
17+
<path d="M13 9h5" />
18+
<path d="M13 15h8" />
19+
<path d="M13 19h5" />
20+
<rect x="3" y="4" width="6" height="6" rx="1" />
21+
<rect x="3" y="14" width="6" height="6" rx="1" />
22+
</svg>
23+
);
24+
}

src/components/markdown/MarkdownRenderer.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ function handleEmbeds(dom: HTMLDivElement, view: DatabaseView, depth: number) {
6565
if (MediaExtensions.VIDEO.contains(target.extension)) {
6666
return handleVideo(el, target, view);
6767
}
68-
69-
// if (target.extension === "md") {
70-
// return await handleMarkdown(el, target, normalizedPath, view, depth);
71-
// }
72-
73-
//return handleUnknownFile(el, target);
7468
})
7569
);
7670
}

0 commit comments

Comments
 (0)