@@ -3,60 +3,60 @@ import { destination_folder } from "helpers/FileManagement";
33import { FileGroupingService } from "services/FileGroupingService" ;
44import { AbstractSettingsHandler , SettingHandlerResponse } from "settings/handlers/AbstractSettingHandler" ;
55import { add_toggle } from "settings/SettingsComponents" ;
6- import { FileGroupingColumnsSetting } from ". /FileGroupingColumnsSetting" ;
6+ import { FileGroupingColumnsSetting } from "settings/handlers/columns /FileGroupingColumnsSetting" ;
77
88export class GroupFolderColumnTextInputHandler extends AbstractSettingsHandler {
99 settingTitle : string = 'Define a schema to group files into folders' ;
10- handle ( settingHandlerResponse : SettingHandlerResponse ) : SettingHandlerResponse {
11- const { containerEl, local, view, settingsManager } = settingHandlerResponse ;
12- if ( local ) {
13- const columns = view . diskConfig . yaml . columns ;
14- const allowedColumns = new Set (
15- Object . keys ( columns )
16- . filter ( ( f ) => columns [ f ] . input === InputType . SELECT )
17- . map ( ( key ) => columns [ key ] . label ) ,
18- ) ;
19-
20- settingsManager . cleanupFns . push ( async ( ) => {
21- const config = view . diskConfig . yaml . config ;
22- if ( config . automatically_group_files ) {
23- const folderPath = destination_folder ( view , config ) ;
24- await FileGroupingService . organizeNotesIntoSubfolders ( folderPath , view . rows , config ) ;
25- await FileGroupingService . removeEmptyFolders ( folderPath , config ) ;
26- view . reloadDatabase ( ) ;
27- }
28- } ) ;
29-
30- new FileGroupingColumnsSetting ( view , allowedColumns ) . init ( containerEl ) ;
10+ handle ( settingHandlerResponse : SettingHandlerResponse ) : SettingHandlerResponse {
11+ const { containerEl, local, view, settingsManager } = settingHandlerResponse ;
12+ if ( local ) {
13+ const columns = view . diskConfig . yaml . columns ;
14+ const allowedColumns = new Set (
15+ Object . keys ( columns )
16+ . filter ( ( f ) => columns [ f ] . input === InputType . SELECT )
17+ . map ( ( key ) => columns [ key ] . label ) ,
18+ ) ;
3119
32- add_toggle (
33- containerEl ,
34- "Group all files into folders automatically" ,
35- "By default, files are groupped individually, after a value is updated" ,
36- view . diskConfig . yaml . config . automatically_group_files ,
37- async ( value ) => {
38- view . diskConfig . updateConfig ( { automatically_group_files : value } ) ;
39- }
40- )
41- add_toggle (
42- containerEl ,
43- "Remove empty folders" ,
44- "Automatically remove empty folders after grouping files." ,
45- view . diskConfig . yaml . config . remove_empty_folders ,
46- async ( value ) => {
47- view . diskConfig . updateConfig ( { remove_empty_folders : value } ) ;
48- }
49- )
20+ settingsManager . cleanupFns . push ( async ( ) => {
21+ const config = view . diskConfig . yaml . config ;
22+ if ( config . automatically_group_files ) {
23+ const folderPath = destination_folder ( view , config ) ;
24+ await FileGroupingService . organizeNotesIntoSubfolders ( folderPath , view . rows , config ) ;
25+ await FileGroupingService . removeEmptyFolders ( folderPath , config ) ;
26+ view . reloadDatabase ( ) ;
27+ }
28+ } ) ;
5029
51- add_toggle (
52- containerEl ,
53- "Hoist files with missing attributes to root folder" ,
54- "By default, files with missing attributes are hoisted to the lowest possible folder" ,
55- view . diskConfig . yaml . config . hoist_files_with_empty_attributes ,
56- async ( value ) => {
57- view . diskConfig . updateConfig ( { hoist_files_with_empty_attributes : value } ) ;
58- }
59- )
30+ new FileGroupingColumnsSetting ( view , allowedColumns ) . init ( containerEl ) ;
31+
32+ add_toggle (
33+ containerEl ,
34+ "Group all files into folders automatically" ,
35+ "By default, files are groupped individually, after a value is updated" ,
36+ view . diskConfig . yaml . config . automatically_group_files ,
37+ async ( value ) => {
38+ view . diskConfig . updateConfig ( { automatically_group_files : value } ) ;
39+ }
40+ )
41+ add_toggle (
42+ containerEl ,
43+ "Remove empty folders" ,
44+ "Automatically remove empty folders after grouping files." ,
45+ view . diskConfig . yaml . config . remove_empty_folders ,
46+ async ( value ) => {
47+ view . diskConfig . updateConfig ( { remove_empty_folders : value } ) ;
48+ }
49+ )
50+
51+ add_toggle (
52+ containerEl ,
53+ "Hoist files with missing attributes to root folder" ,
54+ "By default, files with missing attributes are hoisted to the lowest possible folder" ,
55+ view . diskConfig . yaml . config . hoist_files_with_empty_attributes ,
56+ async ( value ) => {
57+ view . diskConfig . updateConfig ( { hoist_files_with_empty_attributes : value } ) ;
58+ }
59+ )
6060 }
6161 return this . goNext ( settingHandlerResponse ) ;
6262 }
0 commit comments