-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c02940
commit c4d9ac9
Showing
9 changed files
with
159 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import ObsidianSetting from "../obsidian/ObsidianSetting.vue"; | ||
import ObsidianTextInput from "../obsidian/ObsidianTextInput.vue"; | ||
import ObsidianButton from "../obsidian/ObsidianButton.vue"; | ||
import { pluginSettings$ } from "@/stores/settings.store"; | ||
const props = defineProps<{ | ||
name: string; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(event: "save", name: string): void; | ||
(event: "close"): void; | ||
}>(); | ||
const newName = ref(props.name); | ||
const canSave = computed(() => { | ||
return ( | ||
newName.value.length > 0 && | ||
newName.value !== props.name && | ||
pluginSettings$.value.shelves[newName.value] === undefined | ||
); | ||
}); | ||
const showUniqeWarning = computed(() => { | ||
return newName.value && newName.value !== props.name && pluginSettings$.value.shelves[newName.value] !== undefined; | ||
}); | ||
function save() { | ||
emit("save", newName.value); | ||
emit("close"); | ||
} | ||
</script> | ||
|
||
<template> | ||
<ObsidianSetting name="New name"> | ||
<template #description> | ||
<span v-if="showUniqeWarning" class="journal-important">This name is already used.</span> | ||
</template> | ||
<ObsidianTextInput v-model="newName" /> | ||
</ObsidianSetting> | ||
<ObsidianSetting> | ||
<ObsidianButton @click="$emit('close')">Cancel</ObsidianButton> | ||
<ObsidianButton cta :disabled="!canSave" @click="save">Save</ObsidianButton> | ||
</ObsidianSetting> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup lang="ts"> | ||
import { pluginSettings$ } from "@/stores/settings.store"; | ||
import { computed } from "vue"; | ||
import ObsidianSetting from "@/components/obsidian/ObsidianSetting.vue"; | ||
import ObsidianIconButton from "@/components/obsidian/ObsidianIconButton.vue"; | ||
import { VueModal } from "@/components/modals/vue-modal"; | ||
import { plugin$ } from "@/stores/obsidian.store"; | ||
import RenameShelfModal from "@/components/modals/RenameShelf.modal.vue"; | ||
import CreateJournal from "@/components/modals/CreateJournal.modal.vue"; | ||
import type { JournalSettings } from "@/types/settings.types"; | ||
import JournalSettingsList from "./JournalSettingsList.vue"; | ||
const { shelfName } = defineProps<{ | ||
shelfName: string; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(event: "back"): void; | ||
(event: "edit" | "organize", name: string): void; | ||
}>(); | ||
const shelf = computed(() => pluginSettings$.value.shelves[shelfName]); | ||
const shelfJournals = computed(() => { | ||
if (!shelf.value) return []; | ||
return shelf.value.journals.map((journalName) => pluginSettings$.value.journals[journalName]); | ||
}); | ||
function showRenameModal(): void { | ||
new VueModal("Rename shelf", RenameShelfModal, { | ||
name: shelf.value.name, | ||
onSave(name: string) { | ||
plugin$.value.renameShelf(shelfName, name); | ||
emit("organize", name); | ||
}, | ||
}).open(); | ||
} | ||
function create(): void { | ||
new VueModal("Add Journal", CreateJournal, { | ||
onCreate(name: string, writing: JournalSettings["write"]) { | ||
const journal = plugin$.value.createJournal(name, writing); | ||
shelf.value.journals.push(name); | ||
journal.shelves.push(shelfName); | ||
emit("edit", name); | ||
}, | ||
}).open(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div v-if="shelf"> | ||
<ObsidianSetting heading> | ||
<template #name> Configuring {{ shelf.name }} </template> | ||
<ObsidianIconButton icon="pencil" tooltip="Rename shelf" @click="showRenameModal" /> | ||
<ObsidianIconButton icon="chevron-left" tooltip="Back to list" @click="$emit('back')" /> | ||
</ObsidianSetting> | ||
|
||
<ObsidianSetting name="Journals" heading> | ||
<ObsidianIconButton icon="plus" cta tooltip="Create new journal" @click="create" /> | ||
</ObsidianSetting> | ||
|
||
<JournalSettingsList :journals="shelfJournals" @edit="$emit('edit', $event)" /> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters