From f316e051a30269098e22e085d6ef17366de63bc6 Mon Sep 17 00:00:00 2001 From: malyusgun Date: Fri, 30 Aug 2024 17:31:56 +0500 Subject: [PATCH 1/2] add Divider entity and start to change settings sidebar of entities --- src/app/components.d.ts | 7 +- src/app/helpers/images.ts | 4 +- src/app/interfaces/entities.ts | 7 + src/app/interfaces/environment.ts | 2 + src/app/stores/websocket.ts | 6 +- src/components/CreateEntityMenu.vue | 26 ++- .../entities/image/ImagePositionMenu.vue | 10 +- .../entities/image/ImageStateMenu.vue | 7 +- src/components/entities/share/EntityTitle.vue | 2 +- .../entities/share/TextFontMenu.vue | 4 +- .../entities/text/TextPositionMenu.vue | 10 +- src/modules/PageBackgroundMenu.vue | 2 +- src/modules/entities/DividerItem.vue | 24 +++ src/modules/{ => entities}/EntitiesList.vue | 0 src/modules/{ => entities}/EntityItem.vue | 6 +- src/modules/entities/ImageItem.vue | 29 +++- src/modules/entities/TextItem.vue | 18 +- src/modules/entities/menu/DividerMenu.vue | 156 ++++++++++++++++++ src/modules/entities/menu/ImageMenu.vue | 4 +- src/modules/entities/menu/TextMenu.vue | 4 +- src/output.css | 58 +++++++ src/shared/BaseDivider.vue | 10 +- vue/Knob.vue | 22 +-- 23 files changed, 360 insertions(+), 58 deletions(-) create mode 100644 src/modules/entities/DividerItem.vue rename src/modules/{ => entities}/EntitiesList.vue (100%) rename src/modules/{ => entities}/EntityItem.vue (76%) create mode 100644 src/modules/entities/menu/DividerMenu.vue diff --git a/src/app/components.d.ts b/src/app/components.d.ts index 053d351..2bef6d0 100644 --- a/src/app/components.d.ts +++ b/src/app/components.d.ts @@ -17,9 +17,11 @@ declare module 'vue' { CropImageModal: typeof import('./../modules/CropImageModal.vue')['default'] Dialog: typeof import('primevue/dialog')['default'] Divider: typeof import('primevue/divider')['default'] + DividerItem: typeof import('./../modules/entities/DividerItem.vue')['default'] + DividerMenu: typeof import('./../modules/entities/menu/DividerMenu.vue')['default'] Drawer: typeof import('primevue/drawer')['default'] - EntitiesList: typeof import('./../modules/EntitiesList.vue')['default'] - EntityItem: typeof import('./../modules/EntityItem.vue')['default'] + EntitiesList: typeof import('./../modules/entities/EntitiesList.vue')['default'] + EntityItem: typeof import('./../modules/entities/EntityItem.vue')['default'] EntityTitle: typeof import('./../components/entities/share/EntityTitle.vue')['default'] HomePage: typeof import('./../pages/HomePage.vue')['default'] ImageItem: typeof import('./../modules/entities/ImageItem.vue')['default'] @@ -40,6 +42,7 @@ declare module 'vue' { TextMenu: typeof import('./../modules/entities/menu/TextMenu.vue')['default'] TextPositionMenu: typeof import('./../components/entities/text/TextPositionMenu.vue')['default'] TextStateMenu: typeof import('./../components/entities/text/TextStateMenu.vue')['default'] + ToggleSwitch: typeof import('primevue/toggleswitch')['default'] Tree: typeof import('primevue/tree')['default'] UserInfoHeaderWithSettings: typeof import('./../components/UserInfoHeaderWithSettings.vue')['default'] } diff --git a/src/app/helpers/images.ts b/src/app/helpers/images.ts index 2372f5f..a32ed3d 100644 --- a/src/app/helpers/images.ts +++ b/src/app/helpers/images.ts @@ -8,7 +8,7 @@ export const addUrlsToImageEntities = (entities: IEntity[]) => { const filesBuffer = filesWebsocketStore.filesBuffer; let index = 0; const entitiesToReturn = entities.map((entity: IEntity) => { - if (!entity.image_width) return entity; + if (!entity?.image_width) return entity; if (entity.imageUrl) return entity; if (filesWebsocketStore.imageUrl) { // редактирование сущности изображения @@ -26,7 +26,7 @@ export const addUrlsToImageEntities = (entities: IEntity[]) => { }; export const checkIsImage = (entity: IEntity) => { - if (!entity.image_width) { + if (!entity?.image_width) { return entity; } const entityToReturn = { ...entity }; diff --git a/src/app/interfaces/entities.ts b/src/app/interfaces/entities.ts index 0767db1..b367311 100644 --- a/src/app/interfaces/entities.ts +++ b/src/app/interfaces/entities.ts @@ -26,6 +26,13 @@ type ITableColumnTypes = | 'rating' | 'knob'; +export interface IDivider extends IEntity { + entity_type: 'divider'; + entity_uuid: string; + divider_height: number; + divider_type: 'solid' | 'dashed' | 'dotted'; +} + export interface IText extends IEntity { entity_type: 'text'; entity_uuid: string; diff --git a/src/app/interfaces/environment.ts b/src/app/interfaces/environment.ts index c0a1f38..e307c3d 100644 --- a/src/app/interfaces/environment.ts +++ b/src/app/interfaces/environment.ts @@ -13,6 +13,8 @@ export interface IEntity { user_nick_name?: string; entity_order?: number; entity_type: string; + divider_height?: number; + divider_type?: 'solid' | 'dashed' | 'dotted'; title?: string | null; text?: string | null; font_size?: string | null; diff --git a/src/app/stores/websocket.ts b/src/app/stores/websocket.ts index 6638f7c..6135d33 100644 --- a/src/app/stores/websocket.ts +++ b/src/app/stores/websocket.ts @@ -13,7 +13,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { const filesBufferLength = computed(() => filesWebsocketStore.filesBuffer.length); const homeEntities = computed(() => dataStore.homeEntities); const imageEntitiesCount = computed( - () => homeEntities.value.filter((entity) => entity.image_width).length + () => homeEntities.value.filter((entity) => entity?.image_width).length ); const socket = ref(); @@ -50,7 +50,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { } case 'createHomeEntity': { const entities = [...homeEntities.value]; - if (response.data.image_width) { + if (response.data?.image_width) { response.data.imageUrl = filesWebsocketStore.imageUrl; filesWebsocketStore.cleanImageUrl(); } @@ -74,7 +74,7 @@ export const useWebsocketStore = defineStore('websocketStore', () => { let entities = [...homeEntities.value]; entities = entities.map((entity: IEntity) => { if (entity.entity_uuid !== response.data.entity_uuid) return entity; - if (response.data.image_width) { + if (response.data?.image_width) { response.data.imageUrl = filesWebsocketStore.imageUrl; filesWebsocketStore.cleanImageUrl(); } diff --git a/src/components/CreateEntityMenu.vue b/src/components/CreateEntityMenu.vue index 60176cd..6c5db93 100644 --- a/src/components/CreateEntityMenu.vue +++ b/src/components/CreateEntityMenu.vue @@ -50,6 +50,18 @@ onChange((files) => { }); const speedDialItems = ref([ + { + label: 'Divider', + icon: 'pi pi-pause', + command: () => { + emit('createEntity', { + entity_type: 'divider', + entity_uuid: uuidv4(), + divider_height: 1, + divider_type: 'solid' + }); + } + }, { label: 'Text', icon: 'pi pi-pencil', @@ -108,7 +120,19 @@ const speedDialItems = ref([ class="flex flex-col items-center justify-between -translate-8 gap-2 p-2 border rounded border-surface-200 dark:border-surface-700 w-20 cursor-pointer" @click="toggleCallback" > - + + + + {{ item.label }} diff --git a/src/components/entities/image/ImagePositionMenu.vue b/src/components/entities/image/ImagePositionMenu.vue index 2630506..8a7e919 100644 --- a/src/components/entities/image/ImagePositionMenu.vue +++ b/src/components/entities/image/ImagePositionMenu.vue @@ -19,8 +19,10 @@ const dataStore = useDataStore(); const homeEntities = computed(() => dataStore.homeEntities); const position = computed(() => props.entityData.entity_position); const titlePosition = computed(() => props.entityData.entity_title_position); -const entityIndex = homeEntities.value.findIndex( - (entity: IEntity) => entity.entity_uuid === props.entityData.entity_uuid +const entityIndex = computed(() => + homeEntities.value.findIndex( + (entity: IEntity) => entity.entity_uuid === props.entityData.entity_uuid + ) ); const speedDialMove = computed(() => { @@ -75,14 +77,14 @@ const speedDialMove = computed(() => { case 'right': state.push(left, center); } - if (entityIndex !== 0) { + if (entityIndex.value !== 0) { state.push({ label: 'Up', icon: 'pi pi-arrow-up', command: () => changeOrderHomeEntity(props.entityData.entity_uuid, 'up') }); } - if (entityIndex !== homeEntities.value.length - 1) { + if (entityIndex.value !== homeEntities.value.length - 1) { state.push({ label: 'Down', icon: 'pi pi-arrow-down', diff --git a/src/components/entities/image/ImageStateMenu.vue b/src/components/entities/image/ImageStateMenu.vue index a7ea583..d77a75a 100644 --- a/src/components/entities/image/ImageStateMenu.vue +++ b/src/components/entities/image/ImageStateMenu.vue @@ -65,12 +65,7 @@ const speedDialState = computed(() => {