diff --git a/src/app/components.d.ts b/src/app/components.d.ts index 053d35139dc98b727a9a7a7354c0732cd08813c3..2bef6d082259dcafb5c742ec5543b073d7485710 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 2372f5f92e96bbf7542e4d3cd865b6b28a2666c8..a32ed3dabf23f16d76570cf923b6b0d41604f32f 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 0767db1ca62f04565c4d7a52b3faa31126f43f12..b367311ad87eb2e26f7fa75050846d150157d3aa 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 c0a1f38281b1cc78fa79cc99d0c2b8a439f3b171..e307c3dc36d972708f365b6250ae1aaaf7dad480 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 6638f7ca530cc35d496d7ce830330bbcd2ed789e..6135d337eb3965574beef216398e03d828dc6d04 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 60176cdcaf8502f6414418daa2d8b610c54376be..6c5db931fb5d72d46fafd27c9c6d6d2aee02bc5e 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 2630506aaec6b8d6bec03409f70e9816514efb6e..8a7e919c9f61b4249e41319888743dcb8634a0f3 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 a7ea583c28f2f00f9336518a92da41bbae4a8c85..d77a75a925e6915c82b4bdf69923f52ce35ae375 100644 --- a/src/components/entities/image/ImageStateMenu.vue +++ b/src/components/entities/image/ImageStateMenu.vue @@ -65,12 +65,7 @@ const speedDialState = computed(() => {