Allow Journal Entries to have their own file naming scheme

Adding an individual setting is becoming way too complex now.
This commit is contained in:
Vishesh Handa
2020-10-12 18:20:36 +02:00
parent 0e4bf34843
commit 044592b92d
8 changed files with 53 additions and 1 deletions

View File

@ -398,6 +398,7 @@ feature:
inlineTags: Inline Tags inlineTags: Inline Tags
singleJournalEntry: Single Journal Entry File per day singleJournalEntry: Single Journal Entry File per day
configureBottomMenuBar: Configure the Bottom Menu Bar configureBottomMenuBar: Configure the Bottom Menu Bar
customFileNamePerEditor: Custom FileName per Editor
feature_timeline: feature_timeline:
title: Feature Timeline title: Feature Timeline

View File

@ -6,6 +6,7 @@
- text: "Move metadata configuration features from Pro to Basic" - text: "Move metadata configuration features from Pro to Basic"
- text: "Allow the Bottom Menu bar to be hidden - #261" - text: "Allow the Bottom Menu bar to be hidden - #261"
image: bottom_menu_bar.gif image: bottom_menu_bar.gif
- text: "Allow Journal Entries to have their own file naming scheme"
bugs: bugs:
- text: "Dark Theme: Render checkboxes in a lighter color" - text: "Dark Theme: Render checkboxes in a lighter color"
- text: "Fix Relative Parent links not working - #256" - text: "Fix Relative Parent links not working - #256"

View File

@ -512,7 +512,10 @@ class Note with NotesNotifier {
String _buildFileName() { String _buildFileName() {
var date = created ?? modified ?? fileLastModified ?? DateTime.now(); 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: case NoteFileNameFormat.SimpleDate:
return toSimpleDateTime(date); return toSimpleDateTime(date);
case NoteFileNameFormat.FromTitle: case NoteFileNameFormat.FromTitle:

View File

@ -25,6 +25,7 @@ class NotesFolderConfig extends Equatable {
final StandardViewHeader viewHeader; final StandardViewHeader viewHeader;
final bool showNoteSummary; final bool showNoteSummary;
final NoteFileNameFormat fileNameFormat; final NoteFileNameFormat fileNameFormat;
final NoteFileNameFormat journalFileNameFormat;
final NotesFolderFS folder; final NotesFolderFS folder;
final bool yamlHeaderEnabled; final bool yamlHeaderEnabled;
//int _version = 1; //int _version = 1;
@ -44,6 +45,7 @@ class NotesFolderConfig extends Equatable {
@required this.viewHeader, @required this.viewHeader,
@required this.showNoteSummary, @required this.showNoteSummary,
@required this.fileNameFormat, @required this.fileNameFormat,
@required this.journalFileNameFormat,
@required this.folder, @required this.folder,
@required this.yamlHeaderEnabled, @required this.yamlHeaderEnabled,
@required this.yamlModifiedKey, @required this.yamlModifiedKey,
@ -61,6 +63,7 @@ class NotesFolderConfig extends Equatable {
defaultView, defaultView,
viewHeader, viewHeader,
fileNameFormat, fileNameFormat,
journalFileNameFormat,
folder, folder,
yamlHeaderEnabled, yamlHeaderEnabled,
yamlModifiedKey, yamlModifiedKey,
@ -93,6 +96,7 @@ class NotesFolderConfig extends Equatable {
showNoteSummary: settings.showNoteSummary, showNoteSummary: settings.showNoteSummary,
viewHeader: viewHeader, viewHeader: viewHeader,
fileNameFormat: settings.noteFileNameFormat, fileNameFormat: settings.noteFileNameFormat,
journalFileNameFormat: settings.journalNoteFileNameFormat,
folder: folder, folder: folder,
yamlHeaderEnabled: settings.yamlHeaderEnabled, yamlHeaderEnabled: settings.yamlHeaderEnabled,
yamlCreatedKey: settings.yamlCreatedKey, yamlCreatedKey: settings.yamlCreatedKey,
@ -126,6 +130,7 @@ class NotesFolderConfig extends Equatable {
} }
settings.folderViewHeaderType = ht; settings.folderViewHeaderType = ht;
settings.noteFileNameFormat = fileNameFormat; settings.noteFileNameFormat = fileNameFormat;
settings.journalNoteFileNameFormat = journalFileNameFormat;
settings.yamlHeaderEnabled = yamlHeaderEnabled; settings.yamlHeaderEnabled = yamlHeaderEnabled;
settings.yamlCreatedKey = yamlCreatedKey; settings.yamlCreatedKey = yamlCreatedKey;
settings.yamlModifiedKey = yamlModifiedKey; settings.yamlModifiedKey = yamlModifiedKey;
@ -143,6 +148,7 @@ class NotesFolderConfig extends Equatable {
StandardViewHeader viewHeader, StandardViewHeader viewHeader,
bool showNoteSummary, bool showNoteSummary,
NoteFileNameFormat fileNameFormat, NoteFileNameFormat fileNameFormat,
NoteFileNameFormat journalFileNameFormat,
NotesFolderFS folder, NotesFolderFS folder,
bool yamlHeaderEnabled, bool yamlHeaderEnabled,
String yamlCreatedKey, String yamlCreatedKey,
@ -159,6 +165,8 @@ class NotesFolderConfig extends Equatable {
viewHeader: viewHeader ?? this.viewHeader, viewHeader: viewHeader ?? this.viewHeader,
showNoteSummary: showNoteSummary ?? this.showNoteSummary, showNoteSummary: showNoteSummary ?? this.showNoteSummary,
fileNameFormat: fileNameFormat ?? this.fileNameFormat, fileNameFormat: fileNameFormat ?? this.fileNameFormat,
journalFileNameFormat:
journalFileNameFormat ?? this.journalFileNameFormat,
folder: folder ?? this.folder, folder: folder ?? this.folder,
yamlHeaderEnabled: yamlHeaderEnabled ?? this.yamlHeaderEnabled, yamlHeaderEnabled: yamlHeaderEnabled ?? this.yamlHeaderEnabled,
yamlCreatedKey: yamlCreatedKey ?? this.yamlCreatedKey, yamlCreatedKey: yamlCreatedKey ?? this.yamlCreatedKey,
@ -215,6 +223,7 @@ class NotesFolderConfig extends Equatable {
} }
var fileNameFormat = map['noteFileNameFormat']?.toString(); var fileNameFormat = map['noteFileNameFormat']?.toString();
var journalFileNameFormat = map['journalFileNameFormat'].toString();
var yamlHeaderEnabled = map["yamlHeaderEnabled"]?.toString() != "false"; var yamlHeaderEnabled = map["yamlHeaderEnabled"]?.toString() != "false";
var yamlCreatedKey = map['yamlCreatedKey']?.toString(); var yamlCreatedKey = map['yamlCreatedKey']?.toString();
@ -231,6 +240,8 @@ class NotesFolderConfig extends Equatable {
showNoteSummary: showNoteSummary, showNoteSummary: showNoteSummary,
viewHeader: viewHeader, viewHeader: viewHeader,
fileNameFormat: NoteFileNameFormat.fromInternalString(fileNameFormat), fileNameFormat: NoteFileNameFormat.fromInternalString(fileNameFormat),
journalFileNameFormat:
NoteFileNameFormat.fromInternalString(journalFileNameFormat),
folder: folder, folder: folder,
yamlHeaderEnabled: yamlHeaderEnabled, yamlHeaderEnabled: yamlHeaderEnabled,
yamlCreatedKey: yamlCreatedKey, yamlCreatedKey: yamlCreatedKey,
@ -266,6 +277,7 @@ class NotesFolderConfig extends Equatable {
"showNoteSummary": showNoteSummary, "showNoteSummary": showNoteSummary,
"folderViewHeaderType": ht, "folderViewHeaderType": ht,
"noteFileNameFormat": fileNameFormat.toInternalString(), "noteFileNameFormat": fileNameFormat.toInternalString(),
'journalFileNameFormat': journalFileNameFormat.toInternalString(),
'yamlHeaderEnabled': yamlHeaderEnabled, 'yamlHeaderEnabled': yamlHeaderEnabled,
'yamlModifiedKey': yamlModifiedKey, 'yamlModifiedKey': yamlModifiedKey,
'yamlCreatedKey': yamlCreatedKey, 'yamlCreatedKey': yamlCreatedKey,

View File

@ -41,6 +41,7 @@ class Features {
Feature.inlineTags, Feature.inlineTags,
Feature.singleJournalEntry, Feature.singleJournalEntry,
Feature.configureBottomMenuBar, Feature.configureBottomMenuBar,
Feature.customFileNamePerEditor,
]; ];
static final inProgress = <String>[ static final inProgress = <String>[
@ -347,6 +348,14 @@ class Feature {
"", "",
true, true,
); );
static final customFileNamePerEditor = Feature(
"customFileNamePerEditor",
DateTime(2020, 10, 05),
tr("feature.customFileNamePerEditor"),
"",
true,
);
} }
// Feature Adding checklist // Feature Adding checklist

View File

@ -93,6 +93,22 @@ class SettingsEditorsScreenState extends State<SettingsEditorsScreen> {
}, },
), ),
), ),
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( return Scaffold(

View File

@ -15,6 +15,7 @@ class Settings extends ChangeNotifier {
String gitAuthor = "GitJournal"; String gitAuthor = "GitJournal";
String gitAuthorEmail = "app@gitjournal.io"; String gitAuthorEmail = "app@gitjournal.io";
NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default; NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default;
NoteFileNameFormat journalNoteFileNameFormat = NoteFileNameFormat.Default;
String yamlModifiedKey = "modified"; String yamlModifiedKey = "modified";
String yamlCreatedKey = "created"; String yamlCreatedKey = "created";
@ -70,6 +71,8 @@ class Settings extends ChangeNotifier {
noteFileNameFormat = NoteFileNameFormat.fromInternalString( noteFileNameFormat = NoteFileNameFormat.fromInternalString(
pref.getString("noteFileNameFormat")); pref.getString("noteFileNameFormat"));
journalNoteFileNameFormat = NoteFileNameFormat.fromInternalString(
pref.getString("journalNoteFileNameFormat"));
yamlModifiedKey = pref.getString("yamlModifiedKey") ?? yamlModifiedKey; yamlModifiedKey = pref.getString("yamlModifiedKey") ?? yamlModifiedKey;
yamlCreatedKey = pref.getString("yamlCreatedKey") ?? yamlCreatedKey; yamlCreatedKey = pref.getString("yamlCreatedKey") ?? yamlCreatedKey;
@ -148,6 +151,11 @@ class Settings extends ChangeNotifier {
"noteFileNameFormat", "noteFileNameFormat",
noteFileNameFormat.toInternalString(), noteFileNameFormat.toInternalString(),
defaultSet.noteFileNameFormat.toInternalString()); defaultSet.noteFileNameFormat.toInternalString());
_setString(
pref,
"journalNoteFileNameFormat",
journalNoteFileNameFormat.toInternalString(),
defaultSet.journalNoteFileNameFormat.toInternalString());
_setString( _setString(
pref, "yamlModifiedKey", yamlModifiedKey, defaultSet.yamlModifiedKey); pref, "yamlModifiedKey", yamlModifiedKey, defaultSet.yamlModifiedKey);
_setString( _setString(
@ -265,6 +273,7 @@ class Settings extends ChangeNotifier {
"gitAuthor": gitAuthor, "gitAuthor": gitAuthor,
"gitAuthorEmail": gitAuthorEmail, "gitAuthorEmail": gitAuthorEmail,
"noteFileNameFormat": noteFileNameFormat.toInternalString(), "noteFileNameFormat": noteFileNameFormat.toInternalString(),
"journalNoteFileNameFormat": journalNoteFileNameFormat.toInternalString(),
"yamlModifiedKey": yamlModifiedKey, "yamlModifiedKey": yamlModifiedKey,
"yamlCreatedKey": yamlCreatedKey, "yamlCreatedKey": yamlCreatedKey,
"yamlTagsKey": yamlTagsKey, "yamlTagsKey": yamlTagsKey,

View File

@ -33,6 +33,7 @@ void main() {
SortingMode(SortingField.Modified, SortingOrder.Descending), SortingMode(SortingField.Modified, SortingOrder.Descending),
viewHeader: StandardViewHeader.TitleOrFileName, viewHeader: StandardViewHeader.TitleOrFileName,
fileNameFormat: NoteFileNameFormat.Default, fileNameFormat: NoteFileNameFormat.Default,
journalFileNameFormat: NoteFileNameFormat.Default,
folder: folder, folder: folder,
yamlHeaderEnabled: true, yamlHeaderEnabled: true,
yamlCreatedKey: 'created', yamlCreatedKey: 'created',