@@ -4,11 +4,13 @@ import { ActionType } from 'react-table';
44import { VaultManagerDB } from 'services/FileManagerService' ;
55import { LOGGER } from "services/Logger" ;
66import NoteInfo from 'services/NoteInfo' ;
7- import { DatabaseCore , UpdateRowOptions } from "helpers/Constants" ;
7+ import { DatabaseCore , SourceDataTypes , UpdateRowOptions } from "helpers/Constants" ;
88import obtainRowDatabaseFields from 'parsers/FileToRowDatabaseFields' ;
99import { parseFrontmatterFieldsToString } from 'parsers/RowDatabaseFieldsToFile' ;
1010import { 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
1315const 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+ }
8696export 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 } ` ) ;
0 commit comments