From 8872674ba650d84778ede51779b0d739508348dd Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 6 Sep 2024 16:21:21 +0300 Subject: [PATCH] revert visible --- front/src/stores/promo_scene.ts | 7 ++++++- front/src/stores/promo_sidebar.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/front/src/stores/promo_scene.ts b/front/src/stores/promo_scene.ts index 9ac0053..6c8fe14 100644 --- a/front/src/stores/promo_scene.ts +++ b/front/src/stores/promo_scene.ts @@ -4,12 +4,14 @@ type state = { name?: string, description?: string, clickable: PromoScene[], + _visible: { id: number, is_enabled: boolean }[], visible: PromoScene[], } export const usePromoScene = defineStore('promo_scene', { state: () => { return { clickable: [], + _visible: [], visible: [], } as state }, @@ -22,7 +24,10 @@ export const usePromoScene = defineStore('promo_scene', { this.clickable = data }, setVisible(data: PromoScene[]) { - this.visible = data + this._visible = data.slice(0).map(el => { + return { id: el.id, is_enabled: el.is_enabled ?? true } + }) + this.visible = data.slice(0) } } }) diff --git a/front/src/stores/promo_sidebar.ts b/front/src/stores/promo_sidebar.ts index 49e8bc3..a77a2af 100644 --- a/front/src/stores/promo_sidebar.ts +++ b/front/src/stores/promo_sidebar.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import { useClickable } from './clickable' +import { usePromoScene } from './promo_scene' export const usePromoSidebar = defineStore('promo_sidebar', { state: () => { @@ -47,13 +48,18 @@ export const usePromoSidebar = defineStore('promo_sidebar', { // this.target = undefined; // this.loading = true; this.is_open = false; - this.accordions = [] + this.accordions = []; } }, closeBtn() { this.$reset; this.is_open = false; this.is_btn_open = false; + + const sidebar_scene = usePromoScene() + sidebar_scene.visible.map(el => { + el.is_enabled = (sidebar_scene._visible.find(item => item.id == el.id) ?? { is_enabled: true }).is_enabled + }) }, toggleAccordion(name: string, newState = null) { if (name == 'obj' && this.accordions.includes('clickable')) this.toggleAccordion('clickable')