From c4d9ac9f84a9a5e9f8f6bd95678bbbf9296cdb4b Mon Sep 17 00:00:00 2001 From: Sergii Kostyrko Date: Sat, 19 Oct 2024 14:59:43 +0300 Subject: [PATCH] feat: add shelf page --- src/components/modals/RenameShelf.modal.vue | 48 ++++++++++++++ src/main.ts | 3 +- src/settings/JournalSettingsDashboard.vue | 4 +- src/settings/JournalSettingsList.vue | 29 ++++++-- src/settings/JournalSettingsRoot.vue | 11 +++- src/settings/JournalSettingsShelfDetails.vue | 66 +++++++++++++++++++ src/settings/JournalSettingsWithShelves.vue | 5 +- .../JournalSettingsWithoutShelves.vue | 24 ++----- src/types/plugin.types.ts | 2 +- 9 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 src/components/modals/RenameShelf.modal.vue create mode 100644 src/settings/JournalSettingsShelfDetails.vue diff --git a/src/components/modals/RenameShelf.modal.vue b/src/components/modals/RenameShelf.modal.vue new file mode 100644 index 0000000..ecb8337 --- /dev/null +++ b/src/components/modals/RenameShelf.modal.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/src/main.ts b/src/main.ts index 5db8270..2b5af0d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,7 +31,7 @@ export default class JournalPlugin extends Plugin { return this.#journals.get(name); } - createJournal(name: string, write: JournalSettings["write"]): void { + createJournal(name: string, write: JournalSettings["write"]): JournalSettings { const settings: JournalSettings = deepCopy({ ...deepCopy(defaultJournalSettings), ...prepareJournalDefaultsBasedOnType(write), @@ -40,6 +40,7 @@ export default class JournalPlugin extends Plugin { }); pluginSettings$.value.journals[name] = settings; this.#journals.set(name, new Journal(name)); + return pluginSettings$.value.journals[name]; } async renameJournal(name: string, newName: string): Promise { diff --git a/src/settings/JournalSettingsDashboard.vue b/src/settings/JournalSettingsDashboard.vue index eb8d023..5013aba 100644 --- a/src/settings/JournalSettingsDashboard.vue +++ b/src/settings/JournalSettingsDashboard.vue @@ -10,7 +10,7 @@ import { updateLocale } from "../calendar"; import JournalSettingsWithoutShelves from "./JournalSettingsWithoutShelves.vue"; import JournalSettingsWithShelves from "./JournalSettingsWithShelves.vue"; -const emit = defineEmits<(event: "edit" | "orgamize", name: string) => void>(); +const emit = defineEmits<(event: "edit" | "organize", name: string) => void>(); const fow = moment().localeData().firstDayOfWeek(); const fowText = moment().localeData().weekdays()[fow]; @@ -58,7 +58,7 @@ function changeFirstWeekOfYear(value: number): void { - + diff --git a/src/settings/JournalSettingsList.vue b/src/settings/JournalSettingsList.vue index c7f2ec8..0548ea4 100644 --- a/src/settings/JournalSettingsList.vue +++ b/src/settings/JournalSettingsList.vue @@ -1,16 +1,31 @@ - + diff --git a/src/settings/JournalSettingsRoot.vue b/src/settings/JournalSettingsRoot.vue index fb444c3..ffe141c 100644 --- a/src/settings/JournalSettingsRoot.vue +++ b/src/settings/JournalSettingsRoot.vue @@ -2,8 +2,10 @@ import { ref } from "vue"; import JournalSettingsDashboard from "./JournalSettingsDashboard.vue"; import JournalSettingsEdit from "./JournalSettingsEdit.vue"; +import JournalSettingsShelfDetails from "./JournalSettingsShelfDetails.vue"; const selectedJournalName = ref(null); +const selectedShelfName = ref(null); diff --git a/src/settings/JournalSettingsShelfDetails.vue b/src/settings/JournalSettingsShelfDetails.vue new file mode 100644 index 0000000..636521b --- /dev/null +++ b/src/settings/JournalSettingsShelfDetails.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/settings/JournalSettingsWithShelves.vue b/src/settings/JournalSettingsWithShelves.vue index d3e1a33..31627c2 100644 --- a/src/settings/JournalSettingsWithShelves.vue +++ b/src/settings/JournalSettingsWithShelves.vue @@ -47,8 +47,9 @@ function removeShelf(shelfName: string): void { diff --git a/src/settings/JournalSettingsWithoutShelves.vue b/src/settings/JournalSettingsWithoutShelves.vue index 44539a0..6a9ce94 100644 --- a/src/settings/JournalSettingsWithoutShelves.vue +++ b/src/settings/JournalSettingsWithoutShelves.vue @@ -4,12 +4,11 @@ import JournalSettingsList from "./JournalSettingsList.vue"; import ObsidianIconButton from "@/components/obsidian/ObsidianIconButton.vue"; import { VueModal } from "@/components/modals/vue-modal"; import CreateJournal from "@/components/modals/CreateJournal.modal.vue"; -import RemoveJournal from "@/components/modals/RemoveJournal.modal.vue"; import { plugin$ } from "@/stores/obsidian.store"; -import type { JournalSettings, NotesProcessing } from "@/types/settings.types"; -import { journals$ } from "@/stores/settings.store"; +import type { JournalSettings } from "@/types/settings.types"; +import { journalsList$ } from "@/stores/settings.store"; -const emit = defineEmits<(event: "edit", name: string) => void>(); +defineEmits<(event: "edit", name: string) => void>(); function create(): void { new VueModal("Add Journal", CreateJournal, { @@ -18,27 +17,14 @@ function create(): void { }, }).open(); } -function edit(name: string): void { - emit("edit", name); -} -function remove(name: string): void { - const journal = journals$.value[name]; - if (!journal) return; - new VueModal(`Remove ${journal.name} journal`, RemoveJournal, { - onRemove(_noteProcessing: NotesProcessing) { - // TODO Process notes on remove - plugin$.value.removeJournal(name); - }, - }).open(); -} diff --git a/src/types/plugin.types.ts b/src/types/plugin.types.ts index b5c6230..7dcfcd8 100644 --- a/src/types/plugin.types.ts +++ b/src/types/plugin.types.ts @@ -6,7 +6,7 @@ import type { Journal } from "../journals/journal"; export interface JournalPlugin extends Plugin { readonly index: JournalsIndex; getJournal(name: string): Journal | undefined; - createJournal(name: string, write: JournalSettings["write"]): void; + createJournal(name: string, write: JournalSettings["write"]): JournalSettings; renameJournal(name: string, newName: string): void; removeJournal(name: string): void;