From 5ae2882334ad9b34f53a6b30e5a4438e26eed6e3 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 3 Sep 2022 18:13:35 +0300 Subject: [PATCH] fix: use events instead of watch for color handling Signed-off-by: mertmit --- .../components/general/ColorPicker.vue | 22 +++--- packages/nc-gui-v2/composables/useProject.ts | 16 +++-- .../pages/[projectType]/[projectId]/index.vue | 70 +++++++++---------- .../nc-gui-v2/pages/index/index/index.vue | 67 ++++++------------ 4 files changed, 77 insertions(+), 98 deletions(-) diff --git a/packages/nc-gui-v2/components/general/ColorPicker.vue b/packages/nc-gui-v2/components/general/ColorPicker.vue index e5bb3bdc1d..5302c398ab 100644 --- a/packages/nc-gui-v2/components/general/ColorPicker.vue +++ b/packages/nc-gui-v2/components/general/ColorPicker.vue @@ -1,5 +1,4 @@ @@ -50,11 +50,11 @@ watch(picked, (n, _o) => { v-for="(color, i) of colors.slice((colId - 1) * rowSize, colId * rowSize)" :key="`color-${colId}-${i}`" class="color-selector" - :class="compare(typeof picked === 'string' ? picked : picked.hex8, color) ? 'selected' : ''" + :class="compare(picked, color) ? 'selected' : ''" :style="{ 'background-color': `${color}` }" @click="selectColor(color)" > - {{ compare(typeof picked === 'string' ? picked : picked.hex8, color) ? '✓' : '' }} + {{ compare(picked, color) ? '✓' : '' }} @@ -64,7 +64,7 @@ watch(picked, (n, _o) => { Pick Color
- +
diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index da9f6d1b92..57bcbb0302 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -10,7 +10,7 @@ const [setup, use] = useInjectionState((_projectId?: MaybeRef) => { const { $api } = useNuxtApp() const route = useRoute() const { includeM2M } = useGlobal() - const { setTheme } = useTheme() + const { setTheme, theme } = useTheme() const projectId = computed(() => (_projectId ? unref(_projectId) : (route.params.projectId as string))) const project = ref({}) @@ -99,15 +99,21 @@ const [setup, use] = useInjectionState((_projectId?: MaybeRef) => { } } - async function saveTheme(theme: Partial) { + async function saveTheme(_theme: Partial) { + const fullTheme = { + primaryColor: theme.value.primaryColor, + accentColor: theme.value.accentColor, + ..._theme, + } + await updateProject({ - color: theme.primaryColor, + color: fullTheme.primaryColor, meta: { ...projectMeta.value, - theme, + theme: fullTheme, }, }) - setTheme(theme) + setTheme(fullTheme) } watch( diff --git a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue index d6954d9c05..45120dfbd5 100644 --- a/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue @@ -1,6 +1,5 @@