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

Commit b3062b0

Browse files
committed
Merge branch 'metadata_filters'
2 parents dc50271 + b2b19dd commit b3062b0

File tree

8 files changed

+197
-145
lines changed

8 files changed

+197
-145
lines changed

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929
"@testing-library/jest-dom": "5.16.5",
3030
"@testing-library/react": "13.4.0",
3131
"@types/jest": "29.2.5",
32-
"@types/luxon": "3.1.0",
32+
"@types/luxon": "3.2.0",
3333
"@types/node": "18.11.18",
3434
"@types/react": "18.0.26",
3535
"@types/react-csv": "1.1.3",
3636
"@types/react-datepicker": "4.8.0",
3737
"@types/react-dom": "18.0.10",
3838
"@types/react-window": "1.8.5",
39-
"@typescript-eslint/eslint-plugin": "5.47.1",
40-
"@typescript-eslint/parser": "5.47.1",
39+
"@typescript-eslint/eslint-plugin": "5.48.0",
40+
"@typescript-eslint/parser": "5.48.0",
4141
"eslint": "8.31.0",
4242
"jest": "29.3.1",
4343
"jest-mock-extended": "3.0.1",
4444
"jest-environment-jsdom": "29.3.1",
4545
"obsidian": "1.1.1",
46-
"rollup": "3.9.0",
46+
"rollup": "3.9.1",
4747
"rollup-plugin-typescript2": "0.34.1",
4848
"ts-jest": "29.0.3",
4949
"tslib": "2.4.1",
@@ -52,22 +52,22 @@
5252
"dependencies": {
5353
"@emotion/styled": "11.10.5",
5454
"@mui/icons-material": "5.11.0",
55-
"@mui/material": "5.11.2",
55+
"@mui/material": "5.11.3",
5656
"@popperjs/core": "2.11.6",
5757
"@tanstack/match-sorter-utils": "8.7.2",
5858
"@tanstack/react-table": "8.7.4",
5959
"eventemitter3": "5.0.0",
6060
"fuse.js": "6.6.2",
61-
"luxon": "3.2.0",
61+
"luxon": "3.2.1",
6262
"monkey-around": "2.3.0",
63-
"obsidian-dataview": "0.5.51",
63+
"obsidian-dataview": "0.5.52",
6464
"obsidian-projects-types": "0.6.0",
6565
"react": "18.2.0",
6666
"react-csv": "2.2.2",
6767
"react-datepicker": "4.8.0",
6868
"react-dom": "18.2.0",
6969
"react-select": "5.7.0",
7070
"react-window": "1.8.8",
71-
"zustand": "4.1.5"
71+
"zustand": "4.2.0"
7272
}
7373
}

src/cdm/TableStateInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface DataState {
6161
renameFile: (rowIndex: number) => Promise<void>;
6262
saveDataFromFile: (file: File, columns: TableColumn[], config: LocalSettings) => Promise<void>;
6363
groupFiles: () => Promise<void>;
64-
bulkRowUpdate: (rows: RowDataType[], action: string) => Promise<void>;
64+
bulkRowUpdate: (rows: RowDataType[], columns: TableColumn[], action: string) => Promise<void>;
6565
}
6666
}
6767

src/components/contextMenu/HeaderContextMenu.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default function HeaderContextMenu(
1616
const { table } = context;
1717
const { tableState, view } = table.options.meta;
1818

19+
const columnsInfo = tableState.columns((state) => state.info);
1920
const contextState = tableState.configState(
2021
(state) => state.ephimeral.context_header
2122
);
@@ -92,8 +93,10 @@ export default function HeaderContextMenu(
9293
case ContextMenuAction.SELECT:
9394
rowActions.bulkRowUpdate(
9495
table.getSelectedRowModel().rows.map((row) => row.original),
96+
columnsInfo.getAllColumns(),
9597
data.option
9698
);
99+
table.toggleAllPageRowsSelected(false);
97100
default:
98101
// Do nothing
99102
}

src/components/obsidianArq/menu/headerContextMenu.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export default function showHeaderContextMenu(event: MouseEvent, currentState: C
1414
.onClick(() => {
1515
emitter.emit(EMITTERS_GROUPS.CONTEXT_HEADER, { action: ContextMenuAction.SELECT, option: "remove" });
1616
}));
17+
18+
contextMenu.addItem((item) => item
19+
.setTitle("Duplicate selected rows")
20+
.setIcon("checkmark")
21+
.onClick(() => {
22+
emitter.emit(EMITTERS_GROUPS.CONTEXT_HEADER, { action: ContextMenuAction.SELECT, option: "duplicate" });
23+
}));
1724
break;
1825
default:
1926
// Do nothing
@@ -35,7 +42,7 @@ export default function showHeaderContextMenu(event: MouseEvent, currentState: C
3542

3643
if (currentState.action !== ContextMenuAction.SELECT) {
3744
contextMenu.addItem((item) => item
38-
.setTitle("Select actions")
45+
.setTitle("Bulk actions (rows)")
3946
.setIcon("vertical-three-dots")
4047
.onClick(() => {
4148
setAction({ action: ContextMenuAction.SELECT });

src/services/FileManagerService.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ class VaultManager {
6060
app.vault.delete(note);
6161
new Notice(`File ${note.path} removed from vault`);
6262
}
63+
64+
/**
65+
* Duplicate file from vault
66+
* @param note
67+
* @returns
68+
*/
69+
async duplicateNote(note: TFile): Promise<TFile> {
70+
const duplidatedContent = await this.obtainContentFromTfile(note);
71+
const duplicatePath = note.path.replace(".md", " (copy).md");
72+
73+
return await app.vault.create(duplicatePath,
74+
duplidatedContent ?? "",
75+
{ ctime: note.stat.ctime, mtime: note.stat.mtime }
76+
);
77+
}
78+
6379
/**
6480
* Edit file content
6581
* @param note

src/stateManagement/data/handlers/BulkRowUpdateHandlerAction.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import { RowDataType } from "cdm/FolderModel";
1+
import { NoteInfoPage } from "cdm/DatabaseModel";
2+
import { RowDataType, TableColumn } from "cdm/FolderModel";
23
import { DataState, TableActionResponse } from "cdm/TableStateInterface";
4+
import { TFile } from "obsidian";
5+
import { DataviewService } from "services/DataviewService";
36
import { VaultManagerDB } from "services/FileManagerService";
7+
import NoteInfo from "services/NoteInfo";
48
import { AbstractTableAction } from "stateManagement/AbstractTableAction";
59

610
export default class BulkRowUpdateHandlerAction extends AbstractTableAction<DataState> {
711
handle(tableActionResponse: TableActionResponse<DataState>): TableActionResponse<DataState> {
812
const { get, set, implementation } = tableActionResponse;
9-
implementation.actions.bulkRowUpdate = async (alteredRows: RowDataType[], action: string) => {
13+
implementation.actions.bulkRowUpdate = async (alteredRows: RowDataType[], columns: TableColumn[], action: string) => {
1014
let updatedRows: RowDataType[] = get().rows;
1115
switch (action) {
1216
case "remove":
1317
updatedRows = await this.removeRows(get(), alteredRows);
1418
break;
19+
case "duplicate":
20+
updatedRows = await this.duplicateRows(get(), alteredRows);
1521
default:
1622
// Do nothing
1723
}
@@ -25,11 +31,31 @@ export default class BulkRowUpdateHandlerAction extends AbstractTableAction<Data
2531
return this.goNext(tableActionResponse);
2632

2733
}
34+
/**
35+
* Delete the rows from the database and remove them from the state
36+
* @param state
37+
* @param rowsToDelete
38+
* @returns
39+
*/
2840
private async removeRows(state: DataState, rowsToDelete: RowDataType[]): Promise<RowDataType[]> {
2941
const filePathToFilter = rowsToDelete.map((row) => row.__note__.filepath);
3042
rowsToDelete.forEach(async (row) => {
3143
await VaultManagerDB.removeNote(row.__note__.getFile());
3244
});
3345
return state.rows.filter((row) => !filePathToFilter.includes(row.__note__.filepath));
3446
}
47+
48+
/**
49+
* Duplicate the rows from the database and insert them into the state
50+
* @param state
51+
* @param rowsToDuplicate
52+
* @returns
53+
*/
54+
private duplicateRows(state: DataState, rowsToDuplicate: RowDataType[]) {
55+
cancelAnimationFrame
56+
rowsToDuplicate.forEach(async (row) => {
57+
await VaultManagerDB.duplicateNote(row.__note__.getFile());
58+
})
59+
return state.rows;
60+
}
3561
}

src/stateManagement/data/handlers/DataviewUpdaterHandlerAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class DataviewUpdaterHandlerAction extends AbstractTableAction<Da
4747
break;
4848
}
4949
case DATAVIEW_UPDATER_OPERATIONS.UPDATE: {
50-
if (updaterData.isActive) {
50+
if (updaterData.isActive && isFileInDDBB) {
5151
LOGGER.info(`Refreshing File "${updaterData.file}" due to active file update. Ignore`);
5252
return updater;
5353
}

0 commit comments

Comments
 (0)