diff --git a/assets/langs/en.yaml b/assets/langs/en.yaml index 23f50770..b103a835 100644 --- a/assets/langs/en.yaml +++ b/assets/langs/en.yaml @@ -398,6 +398,7 @@ feature: inlineTags: Inline Tags singleJournalEntry: Single Journal Entry File per day configureBottomMenuBar: Configure the Bottom Menu Bar + customFileNamePerEditor: Custom FileName per Editor feature_timeline: title: Feature Timeline diff --git a/changelog.yml b/changelog.yml index 7f960564..f63a3812 100644 --- a/changelog.yml +++ b/changelog.yml @@ -6,6 +6,7 @@ - text: "Move metadata configuration features from Pro to Basic" - text: "Allow the Bottom Menu bar to be hidden - #261" image: bottom_menu_bar.gif + - text: "Allow Journal Entries to have their own file naming scheme" bugs: - text: "Dark Theme: Render checkboxes in a lighter color" - text: "Fix Relative Parent links not working - #256" diff --git a/lib/core/note.dart b/lib/core/note.dart index d2579608..d4a201c5 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -512,7 +512,10 @@ class Note with NotesNotifier { String _buildFileName() { var date = created ?? modified ?? fileLastModified ?? DateTime.now(); - switch (parent.config.fileNameFormat) { + var isJournal = type == NoteType.Journal; + switch (!isJournal + ? parent.config.fileNameFormat + : parent.config.journalFileNameFormat) { case NoteFileNameFormat.SimpleDate: return toSimpleDateTime(date); case NoteFileNameFormat.FromTitle: diff --git a/lib/core/notes_folder_config.dart b/lib/core/notes_folder_config.dart index b78c2720..b6c3183e 100644 --- a/lib/core/notes_folder_config.dart +++ b/lib/core/notes_folder_config.dart @@ -25,6 +25,7 @@ class NotesFolderConfig extends Equatable { final StandardViewHeader viewHeader; final bool showNoteSummary; final NoteFileNameFormat fileNameFormat; + final NoteFileNameFormat journalFileNameFormat; final NotesFolderFS folder; final bool yamlHeaderEnabled; //int _version = 1; @@ -44,6 +45,7 @@ class NotesFolderConfig extends Equatable { @required this.viewHeader, @required this.showNoteSummary, @required this.fileNameFormat, + @required this.journalFileNameFormat, @required this.folder, @required this.yamlHeaderEnabled, @required this.yamlModifiedKey, @@ -61,6 +63,7 @@ class NotesFolderConfig extends Equatable { defaultView, viewHeader, fileNameFormat, + journalFileNameFormat, folder, yamlHeaderEnabled, yamlModifiedKey, @@ -93,6 +96,7 @@ class NotesFolderConfig extends Equatable { showNoteSummary: settings.showNoteSummary, viewHeader: viewHeader, fileNameFormat: settings.noteFileNameFormat, + journalFileNameFormat: settings.journalNoteFileNameFormat, folder: folder, yamlHeaderEnabled: settings.yamlHeaderEnabled, yamlCreatedKey: settings.yamlCreatedKey, @@ -126,6 +130,7 @@ class NotesFolderConfig extends Equatable { } settings.folderViewHeaderType = ht; settings.noteFileNameFormat = fileNameFormat; + settings.journalNoteFileNameFormat = journalFileNameFormat; settings.yamlHeaderEnabled = yamlHeaderEnabled; settings.yamlCreatedKey = yamlCreatedKey; settings.yamlModifiedKey = yamlModifiedKey; @@ -143,6 +148,7 @@ class NotesFolderConfig extends Equatable { StandardViewHeader viewHeader, bool showNoteSummary, NoteFileNameFormat fileNameFormat, + NoteFileNameFormat journalFileNameFormat, NotesFolderFS folder, bool yamlHeaderEnabled, String yamlCreatedKey, @@ -159,6 +165,8 @@ class NotesFolderConfig extends Equatable { viewHeader: viewHeader ?? this.viewHeader, showNoteSummary: showNoteSummary ?? this.showNoteSummary, fileNameFormat: fileNameFormat ?? this.fileNameFormat, + journalFileNameFormat: + journalFileNameFormat ?? this.journalFileNameFormat, folder: folder ?? this.folder, yamlHeaderEnabled: yamlHeaderEnabled ?? this.yamlHeaderEnabled, yamlCreatedKey: yamlCreatedKey ?? this.yamlCreatedKey, @@ -215,6 +223,7 @@ class NotesFolderConfig extends Equatable { } var fileNameFormat = map['noteFileNameFormat']?.toString(); + var journalFileNameFormat = map['journalFileNameFormat'].toString(); var yamlHeaderEnabled = map["yamlHeaderEnabled"]?.toString() != "false"; var yamlCreatedKey = map['yamlCreatedKey']?.toString(); @@ -231,6 +240,8 @@ class NotesFolderConfig extends Equatable { showNoteSummary: showNoteSummary, viewHeader: viewHeader, fileNameFormat: NoteFileNameFormat.fromInternalString(fileNameFormat), + journalFileNameFormat: + NoteFileNameFormat.fromInternalString(journalFileNameFormat), folder: folder, yamlHeaderEnabled: yamlHeaderEnabled, yamlCreatedKey: yamlCreatedKey, @@ -266,6 +277,7 @@ class NotesFolderConfig extends Equatable { "showNoteSummary": showNoteSummary, "folderViewHeaderType": ht, "noteFileNameFormat": fileNameFormat.toInternalString(), + 'journalFileNameFormat': journalFileNameFormat.toInternalString(), 'yamlHeaderEnabled': yamlHeaderEnabled, 'yamlModifiedKey': yamlModifiedKey, 'yamlCreatedKey': yamlCreatedKey, diff --git a/lib/features.dart b/lib/features.dart index f06f608c..7d8dabef 100644 --- a/lib/features.dart +++ b/lib/features.dart @@ -41,6 +41,7 @@ class Features { Feature.inlineTags, Feature.singleJournalEntry, Feature.configureBottomMenuBar, + Feature.customFileNamePerEditor, ]; static final inProgress = [ @@ -347,6 +348,14 @@ class Feature { "", true, ); + + static final customFileNamePerEditor = Feature( + "customFileNamePerEditor", + DateTime(2020, 10, 05), + tr("feature.customFileNamePerEditor"), + "", + true, + ); } // Feature Adding checklist diff --git a/lib/screens/settings_editors.dart b/lib/screens/settings_editors.dart index 77f53095..dfbc7aa1 100644 --- a/lib/screens/settings_editors.dart +++ b/lib/screens/settings_editors.dart @@ -93,6 +93,22 @@ class SettingsEditorsScreenState extends State { }, ), ), + ProOverlay( + feature: Feature.singleJournalEntry, + child: ListPreference( + title: tr('settings.note.fileName'), + currentOption: settings.journalNoteFileNameFormat.toPublicString(), + options: NoteFileNameFormat.options + .map((f) => f.toPublicString()) + .toList(), + onChange: (String publicStr) { + var format = NoteFileNameFormat.fromPublicString(publicStr); + settings.journalNoteFileNameFormat = format; + settings.save(); + setState(() {}); + }, + ), + ), ]); return Scaffold( diff --git a/lib/settings.dart b/lib/settings.dart index d9c3789c..4618095a 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -15,6 +15,7 @@ class Settings extends ChangeNotifier { String gitAuthor = "GitJournal"; String gitAuthorEmail = "app@gitjournal.io"; NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default; + NoteFileNameFormat journalNoteFileNameFormat = NoteFileNameFormat.Default; String yamlModifiedKey = "modified"; String yamlCreatedKey = "created"; @@ -70,6 +71,8 @@ class Settings extends ChangeNotifier { noteFileNameFormat = NoteFileNameFormat.fromInternalString( pref.getString("noteFileNameFormat")); + journalNoteFileNameFormat = NoteFileNameFormat.fromInternalString( + pref.getString("journalNoteFileNameFormat")); yamlModifiedKey = pref.getString("yamlModifiedKey") ?? yamlModifiedKey; yamlCreatedKey = pref.getString("yamlCreatedKey") ?? yamlCreatedKey; @@ -148,6 +151,11 @@ class Settings extends ChangeNotifier { "noteFileNameFormat", noteFileNameFormat.toInternalString(), defaultSet.noteFileNameFormat.toInternalString()); + _setString( + pref, + "journalNoteFileNameFormat", + journalNoteFileNameFormat.toInternalString(), + defaultSet.journalNoteFileNameFormat.toInternalString()); _setString( pref, "yamlModifiedKey", yamlModifiedKey, defaultSet.yamlModifiedKey); _setString( @@ -265,6 +273,7 @@ class Settings extends ChangeNotifier { "gitAuthor": gitAuthor, "gitAuthorEmail": gitAuthorEmail, "noteFileNameFormat": noteFileNameFormat.toInternalString(), + "journalNoteFileNameFormat": journalNoteFileNameFormat.toInternalString(), "yamlModifiedKey": yamlModifiedKey, "yamlCreatedKey": yamlCreatedKey, "yamlTagsKey": yamlTagsKey, diff --git a/test/notes_folder_config_test.dart b/test/notes_folder_config_test.dart index 73adb237..4be4f0f8 100644 --- a/test/notes_folder_config_test.dart +++ b/test/notes_folder_config_test.dart @@ -33,6 +33,7 @@ void main() { SortingMode(SortingField.Modified, SortingOrder.Descending), viewHeader: StandardViewHeader.TitleOrFileName, fileNameFormat: NoteFileNameFormat.Default, + journalFileNameFormat: NoteFileNameFormat.Default, folder: folder, yamlHeaderEnabled: true, yamlCreatedKey: 'created',