diff --git a/structures-frontend-next/components.d.ts b/structures-frontend-next/components.d.ts index 87c479c8..3aa4ace6 100644 --- a/structures-frontend-next/components.d.ts +++ b/structures-frontend-next/components.d.ts @@ -53,10 +53,11 @@ declare module 'vue' { SidebarItem: typeof import('./src/components/SidebarItem.vue')['default'] SideNav: typeof import('./src/components/SideNav.vue')['default'] Structure: typeof import('./src/components/structures/flow-components/Structure.vue')['default'] + StructureDataViewModal: typeof import('./src/components/modals/StructureDataViewModal.vue')['default'] StructureItemModal: typeof import('./src/components/modals/StructureItemModal.vue')['default'] StructureNode: typeof import('./src/components/structures/flow-components/StructureNode.vue')['default'] StructureSettings: typeof import('./src/components/structures/sidebar-dashboard/StructureSettings.vue')['default'] - StructureSidebarDashboard: typeof import('./src/components/structures/StructureSidebarDashboard.vue')['default'] + StructureSidebarDashboard: typeof import('./src/components/structures/sidebar-dashboard/StructureSidebarDashboard.vue')['default'] StructuresList: typeof import('./src/components/StructuresList.vue')['default'] Tab: typeof import('primevue/tab')['default'] TabList: typeof import('primevue/tablist')['default'] diff --git a/structures-frontend-next/src/components/ProjectStructuresTable.vue b/structures-frontend-next/src/components/ProjectStructuresTable.vue index 3d142001..e6997314 100644 --- a/structures-frontend-next/src/components/ProjectStructuresTable.vue +++ b/structures-frontend-next/src/components/ProjectStructuresTable.vue @@ -2,6 +2,7 @@ import { Component, Vue, Prop, Watch, Ref } from 'vue-facing-decorator' import CrudTable from '@/components/CrudTable.vue' import StructureItemModal from '@/components/modals/StructureItemModal.vue' +import StructureDataViewModal from '@/components/modals/StructureDataViewModal.vue' import { Structure, Structures } from '@kinotic/structures-api' import type { CrudHeader } from '@/types/CrudHeader' import { APPLICATION_STATE } from '@/states/IApplicationState' @@ -9,7 +10,7 @@ import type { Identifiable, IterablePage, Pageable } from '@kinotic/continuum-cl import DatetimeUtil from "@/util/DatetimeUtil" @Component({ - components: { CrudTable, StructureItemModal } + components: { CrudTable, StructureItemModal, StructureDataViewModal } }) export default class ProjectStructuresTable extends Vue { @Prop({ required: true }) applicationId!: string @@ -24,14 +25,18 @@ export default class ProjectStructuresTable extends Vue { { field: 'description', header: 'Description', sortable: false }, { field: 'created', header: 'Created', sortable: false }, { field: 'updated', header: 'Updated', sortable: false }, - { field: 'published', header: 'Status', sortable: false } + { field: 'published', header: 'Status', sortable: false, centered: true } ] searchText: string = '' showModal = false + showItemModal = false selectedStructure: Structure | null = null isInitialized = false public DatetimeUtil = DatetimeUtil + actionMenus: any[] = [] + currentActionItem: Structure | null = null + private dataSource1 = Structures.getStructureService() mounted() { this.searchText = (this.$route.query['search-structure'] as string) || '' @@ -100,6 +105,16 @@ export default class ProjectStructuresTable extends Vue { this.selectedStructure = null } + openItemModal(item: Structure) { + this.selectedStructure = item + this.showItemModal = true + } + + closeItemModal() { + this.showItemModal = false + this.selectedStructure = null + } + onAddItem() { // this.$router.push("/new-structure") } @@ -112,6 +127,63 @@ export default class ProjectStructuresTable extends Vue { this.openModal(item) } + toggleMenu(event: Event, item: Structure, index: number) { + this.currentActionItem = item + const menu = this.actionMenus[index] + if (menu) { + menu.toggle(event) + } + } + + async publish(item: any) { + item['publishing'] = true + if (confirm('Are you sure you want to Publish this Structure?')) { + let table: any = this.$refs?.crudTable + try { + await this.dataSource1.publish(item.id) + table?.find() + delete item['publishing'] + } catch (error: any) { + delete item['publishing'] + table?.displayAlert(error.message) + } + } + } + + async unPublish(item: any) { + item['publishing'] = true + if (confirm('Are you sure you want to Remove Published Status for this Structure? \nAll data saved under this Structure will be permanently deleted, proceed with caution.')) { + let table: any = this.$refs?.crudTable + try { + await this.dataSource1.unPublish(item.id) + table?.find() + delete item['publishing'] + } catch (error: any) { + delete item['publishing'] + table?.displayAlert(error.message) + } + } + } + + getActionMenu(item: Structure) { + return [ + { + label: item.published ? 'Unpublish' : 'Publish', + icon: item.published ? 'pi pi-eye-slash' : 'pi pi-eye', + command: () => (item.published ? this.unPublish(item) : this.publish(item)) + }, + { + label: 'View', + icon: 'pi pi-file', + command: (e: any) => { + e?.originalEvent?.stopPropagation?.() + e?.originalEvent?.preventDefault?.() + this.openItemModal(item) + } + } + ] + } + async markProjectAsActive() { try { const header = this.$root?.$refs?.header as { setActiveProjectById?: (appId: string, projId: string) => Promise } | undefined @@ -154,14 +226,51 @@ export default class ProjectStructuresTable extends Vue { {{ DatetimeUtil.formatRelativeDate(item.updated) }} + + + + diff --git a/structures-frontend-next/src/components/SideBar.vue b/structures-frontend-next/src/components/SideBar.vue index 46d8faaf..abb8edca 100644 --- a/structures-frontend-next/src/components/SideBar.vue +++ b/structures-frontend-next/src/components/SideBar.vue @@ -79,7 +79,7 @@ export default class Sidebar extends Vue {