From a3a9b7fbd32f13293797f48b50f3d2d8601b6a41 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Jul 2022 15:19:44 +0900 Subject: [PATCH] chore(client): tweak deck ui --- locales/ja-JP.yml | 2 + packages/client/src/pages/settings/deck.vue | 14 ---- packages/client/src/ui/deck.vue | 82 +++++++++++++++++++-- packages/client/src/ui/deck/deck-store.ts | 27 ++++--- 4 files changed, 93 insertions(+), 32 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c797c0d55e..6f2cee9f29 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1762,6 +1762,8 @@ _deck: stackLeft: "左に重ねる" popRight: "右に出す" profile: "プロファイル" + newProfile: "新規プロファイル" + deleteProfile: "プロファイルを削除" introduction: "カラムを組み合わせて自分だけのインターフェイスを作りましょう!" introduction2: "画面の右にある + を押して、いつでもカラムを追加できます。" widgetsIntroduction: "カラムのメニューから、「ウィジェットの編集」を選択してウィジェットを追加してください" diff --git a/packages/client/src/pages/settings/deck.vue b/packages/client/src/pages/settings/deck.vue index c62928eeb0..1285a6641c 100644 --- a/packages/client/src/pages/settings/deck.vue +++ b/packages/client/src/pages/settings/deck.vue @@ -9,8 +9,6 @@ - - {{ i18n.ts._deck.profile }} @@ -29,18 +27,6 @@ import { definePageMetadata } from '@/scripts/page-metadata'; const navWindow = computed(deckStore.makeGetterSetter('navWindow')); const alwaysShowMainColumn = computed(deckStore.makeGetterSetter('alwaysShowMainColumn')); const columnAlign = computed(deckStore.makeGetterSetter('columnAlign')); -const profile = computed(deckStore.makeGetterSetter('profile')); - -async function setProfile() { - const { canceled, result: name } = await os.inputText({ - title: i18n.ts._deck.profile, - allowEmpty: false, - }); - if (canceled) return; - - profile.value = name; - unisonReload(); -} const headerActions = $computed(() => []); diff --git a/packages/client/src/ui/deck.vue b/packages/client/src/ui/deck.vue index 94fee1424e..8c9e52063d 100644 --- a/packages/client/src/ui/deck.vue +++ b/packages/client/src/ui/deck.vue @@ -33,8 +33,16 @@
{{ i18n.ts._deck.introduction2 }}
- - +
+ + +
+
+ +
+
+ +
@@ -67,7 +75,7 @@ import { computed, defineAsyncComponent, onMounted, provide, ref, watch } from 'vue'; import { v4 as uuid } from 'uuid'; import XCommon from './_common_/common.vue'; -import { deckStore, addColumn as addColumnToStore, loadDeck } from './deck/deck-store'; +import { deckStore, addColumn as addColumnToStore, loadDeck, getProfiles, deleteProfile as deleteProfile_ } from './deck/deck-store'; import DeckColumnCore from '@/ui/deck/column-core.vue'; import XSidebar from '@/ui/_common_/navbar.vue'; import XDrawerMenu from '@/ui/_common_/navbar-for-mobile.vue'; @@ -78,6 +86,7 @@ import { navbarItemDef } from '@/navbar'; import { $i } from '@/account'; import { i18n } from '@/i18n'; import { mainRouter } from '@/router'; +import { unisonReload } from '@/scripts/unison-reload'; const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue')); mainRouter.navHook = (path): boolean => { @@ -168,6 +177,51 @@ loadDeck(); function moveFocus(id: string, direction: 'up' | 'down' | 'left' | 'right') { // TODO?? } + +function changeProfile(ev: MouseEvent) { + const items = ref([{ + text: deckStore.state.profile, + active: true.valueOf, + }]); + getProfiles().then(profiles => { + items.value = [{ + text: deckStore.state.profile, + active: true.valueOf, + }, ...(profiles.filter(k => k !== deckStore.state.profile).map(k => ({ + text: k, + action: () => { + deckStore.set('profile', k); + unisonReload(); + }, + }))), null, { + text: i18n.ts._deck.newProfile, + icon: 'fas fa-plus', + action: async () => { + const { canceled, result: name } = await os.inputText({ + title: i18n.ts._deck.profile, + allowEmpty: false, + }); + if (canceled) return; + + deckStore.set('profile', name); + unisonReload(); + }, + }]; + }); + os.popupMenu(items, ev.currentTarget ?? ev.target); +} + +async function deleteProfile() { + const { canceled } = await os.confirm({ + type: 'warning', + text: i18n.t('deleteAreYouSure', { x: deckStore.state.profile }), + }); + if (canceled) return; + + deleteProfile_(deckStore.state.profile); + deckStore.set('profile', 'default'); + unisonReload(); +}