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

Commit efa155b

Browse files
committed
tag source
1 parent cb0134f commit efa155b

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/DatabaseView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
132132
const rows = await adapterTFilesToRows(
133133
this.file.parent.path,
134134
columns,
135-
this.diskConfig.yaml.filters
135+
this.diskConfig.yaml
136136
);
137137
const initialState: InitialState = obtainInitialState(columns, rows);
138138
// Define table properties

src/helpers/VaultManagement.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { ActionType } from 'react-table';
44
import { VaultManagerDB } from 'services/FileManagerService';
55
import { LOGGER } from "services/Logger";
66
import NoteInfo from 'services/NoteInfo';
7-
import { DatabaseCore, UpdateRowOptions } from "helpers/Constants";
7+
import { DatabaseCore, SourceDataTypes, UpdateRowOptions } from "helpers/Constants";
88
import obtainRowDatabaseFields from 'parsers/FileToRowDatabaseFields';
99
import { parseFrontmatterFieldsToString } from 'parsers/RowDatabaseFieldsToFile';
1010
import { DataviewService } from 'services/DataviewService';
11-
import { FilterCondition } from 'cdm/DatabaseModel';
11+
import { DatabaseYaml } from 'cdm/DatabaseModel';
12+
import { Literal } from 'obsidian-dataview/lib/data-model/value';
13+
import { DataArray } from 'obsidian-dataview/lib/api/data-array';
1214

1315
const noBreakSpace = /\u00A0/g;
1416

@@ -62,16 +64,16 @@ export function getNormalizedPath(path: string): NormalizedPath {
6264
* @param folderPath
6365
* @returns
6466
*/
65-
export async function adapterTFilesToRows(folderPath: string, columns: TableColumn[], filters: FilterCondition[]): Promise<Array<RowDataType>> {
67+
export async function adapterTFilesToRows(folderPath: string, columns: TableColumn[], dbYaml: DatabaseYaml): Promise<Array<RowDataType>> {
6668
LOGGER.debug(`=> adapterTFilesToRows. folderPath:${folderPath}`);
6769
const rows: Array<RowDataType> = [];
6870
let id = 0;
6971

70-
let folderFiles = DataviewService.getDataviewAPI().pages(`"${folderPath}"`)
72+
let folderFiles = sourceDataviewPages(folderPath, dbYaml)
7173
.where(p => !p[DatabaseCore.FRONTMATTER_KEY]);
7274
// Config filters asociated with the database
73-
if (filters) {
74-
folderFiles = folderFiles.where(p => DataviewService.filter(filters, p));
75+
if (dbYaml.filters) {
76+
folderFiles = folderFiles.where(p => DataviewService.filter(dbYaml.filters, p));
7577
}
7678

7779
folderFiles.map(async (page) => {
@@ -83,6 +85,14 @@ export async function adapterTFilesToRows(folderPath: string, columns: TableColu
8385
return rows;
8486
}
8587

88+
export function sourceDataviewPages(folderPath: string, dbYaml: DatabaseYaml): DataArray<Record<string, Literal>> {
89+
switch (dbYaml.config.source_data) {
90+
case SourceDataTypes.TAG:
91+
return DataviewService.getDataviewAPI().pages(`#${dbYaml.config.source_form_result}`);
92+
default:
93+
return DataviewService.getDataviewAPI().pages(`"${folderPath}"`);
94+
}
95+
}
8696
export async function updateRowFileProxy(file: TFile, columnId: string, newValue: string, state: TableDataType, option: string): Promise<void> {
8797
await updateRowFile(file, columnId, newValue, state, option).catch(e => {
8898
LOGGER.error(`updateRowFileProxy. Error:${e}`);

src/services/MarkdownPostProcessorService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class PreviewDatabaseModeService {
137137
const rows = await adapterTFilesToRows(
138138
dbFile.parent.path,
139139
columns,
140-
databaseDisk.yaml.filters
140+
databaseDisk.yaml
141141
);
142142
const dataviewCols: string[] = columns
143143
.filter((col) => !col.skipPersist)

0 commit comments

Comments
 (0)