settings: add dialog

pull/400/head
Varun Patil 2023-02-09 13:03:06 -08:00
parent e0af54f835
commit 3fde5c1caf
3 changed files with 79 additions and 37 deletions

View File

@ -25,7 +25,6 @@ namespace OCA\Memories\Controller;
use OCA\Memories\AppInfo\Application; use OCA\Memories\AppInfo\Application;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\StreamResponse; use OCP\AppFramework\Http\StreamResponse;

View File

@ -23,9 +23,12 @@
</template> </template>
<template #footer> <template #footer>
<NcAppNavigationSettings :title="t('memories', 'Settings')"> <NcAppNavigationItem
<Settings /> :title="t('memories', 'Settings')"
</NcAppNavigationSettings> @click="showSettings"
>
<CogIcon slot="icon" :size="20" />
</NcAppNavigationItem>
</template> </template>
</NcAppNavigation> </NcAppNavigation>
@ -39,6 +42,8 @@
<router-view /> <router-view />
</div> </div>
</NcAppContent> </NcAppContent>
<Settings :open.sync="settingsOpen" />
</NcContent> </NcContent>
</template> </template>
@ -50,8 +55,6 @@ import NcAppContent from "@nextcloud/vue/dist/Components/NcAppContent";
import NcAppNavigation from "@nextcloud/vue/dist/Components/NcAppNavigation"; import NcAppNavigation from "@nextcloud/vue/dist/Components/NcAppNavigation";
const NcAppNavigationItem = () => const NcAppNavigationItem = () =>
import("@nextcloud/vue/dist/Components/NcAppNavigationItem"); import("@nextcloud/vue/dist/Components/NcAppNavigationItem");
const NcAppNavigationSettings = () =>
import("@nextcloud/vue/dist/Components/NcAppNavigationSettings");
import { generateUrl } from "@nextcloud/router"; import { generateUrl } from "@nextcloud/router";
import { translate as t } from "@nextcloud/l10n"; import { translate as t } from "@nextcloud/l10n";
@ -72,6 +75,7 @@ import PeopleIcon from "vue-material-design-icons/AccountBoxMultiple.vue";
import MarkerIcon from "vue-material-design-icons/MapMarker.vue"; import MarkerIcon from "vue-material-design-icons/MapMarker.vue";
import TagsIcon from "vue-material-design-icons/Tag.vue"; import TagsIcon from "vue-material-design-icons/Tag.vue";
import MapIcon from "vue-material-design-icons/Map.vue"; import MapIcon from "vue-material-design-icons/Map.vue";
import CogIcon from "vue-material-design-icons/Cog.vue";
export default defineComponent({ export default defineComponent({
name: "App", name: "App",
@ -80,7 +84,6 @@ export default defineComponent({
NcAppContent, NcAppContent,
NcAppNavigation, NcAppNavigation,
NcAppNavigationItem, NcAppNavigationItem,
NcAppNavigationSettings,
Timeline, Timeline,
Settings, Settings,
@ -97,11 +100,13 @@ export default defineComponent({
MarkerIcon, MarkerIcon,
TagsIcon, TagsIcon,
MapIcon, MapIcon,
CogIcon,
}, },
data: () => ({ data: () => ({
navItems: [], navItems: [],
metadataComponent: null as any, metadataComponent: null as any,
settingsOpen: false,
}), }),
computed: { computed: {
@ -324,6 +329,10 @@ export default defineComponent({
tokenInput.value = token; tokenInput.value = token;
}, },
showSettings() {
this.settingsOpen = true;
},
}, },
}); });
</script> </script>

View File

@ -22,6 +22,16 @@
<template> <template>
<div> <div>
<NcAppSettingsDialog
:open="open"
:show-navigation="true"
:title="t('memories', 'Memories Settings')"
@update:open="onClose"
>
<NcAppSettingsSection
id="general-settings"
:title="t('memories', 'General')"
>
<label for="timeline-path">{{ t("memories", "Timeline Path") }}</label> <label for="timeline-path">{{ t("memories", "Timeline Path") }}</label>
<input <input
id="timeline-path" id="timeline-path"
@ -30,6 +40,19 @@
type="text" type="text"
/> />
<NcCheckboxRadioSwitch
:checked.sync="config_squareThumbs"
@update:checked="updateSquareThumbs"
type="switch"
>
{{ t("memories", "Square grid mode") }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection
id="folders-settings"
:title="t('memories', 'Folders')"
>
<label for="folders-path">{{ t("memories", "Folders Path") }}</label> <label for="folders-path">{{ t("memories", "Folders Path") }}</label>
<input <input
id="folders-path" id="folders-path"
@ -45,14 +68,8 @@
> >
{{ t("memories", "Show hidden folders") }} {{ t("memories", "Show hidden folders") }}
</NcCheckboxRadioSwitch> </NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcCheckboxRadioSwitch </NcAppSettingsDialog>
:checked.sync="config_squareThumbs"
@update:checked="updateSquareThumbs"
type="switch"
>
{{ t("memories", "Square grid mode") }}
</NcCheckboxRadioSwitch>
<MultiPathSelectionModal <MultiPathSelectionModal
ref="multiPathModal" ref="multiPathModal"
@ -72,6 +89,10 @@ input[type="text"] {
import { defineComponent } from "vue"; import { defineComponent } from "vue";
import { getFilePickerBuilder } from "@nextcloud/dialogs"; import { getFilePickerBuilder } from "@nextcloud/dialogs";
const NcAppSettingsDialog = () =>
import("@nextcloud/vue/dist/Components/NcAppSettingsDialog");
const NcAppSettingsSection = () =>
import("@nextcloud/vue/dist/Components/NcAppSettingsSection");
const NcCheckboxRadioSwitch = () => const NcCheckboxRadioSwitch = () =>
import("@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch"); import("@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch");
@ -81,10 +102,19 @@ export default defineComponent({
name: "Settings", name: "Settings",
components: { components: {
NcAppSettingsDialog,
NcAppSettingsSection,
NcCheckboxRadioSwitch, NcCheckboxRadioSwitch,
MultiPathSelectionModal, MultiPathSelectionModal,
}, },
props: {
open: {
type: Boolean,
required: true,
},
},
computed: { computed: {
pathSelTitle(): string { pathSelTitle(): string {
return this.t("memories", "Choose Timeline Paths"); return this.t("memories", "Choose Timeline Paths");
@ -92,6 +122,10 @@ export default defineComponent({
}, },
methods: { methods: {
onClose() {
this.$emit("update:open", false);
},
async chooseFolder(title: string, initial: string) { async chooseFolder(title: string, initial: string) {
const picker = getFilePickerBuilder(title) const picker = getFilePickerBuilder(title)
.setMultiSelect(false) .setMultiSelect(false)