From f90e9ea3bcf0ebc702675773caafed2fbc9fa3a7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 24 Jul 2025 16:14:57 +0200 Subject: [PATCH] fetch workflow and only show delete button on attachment if workflow is not final --- .../Resources/public/js/generic-doc-api.ts | 17 ++++++- .../ChillMainBundle/Resources/public/types.ts | 50 +++++++++++++++++++ .../public/vuejs/WorkflowAttachment/App.vue | 14 +++++- .../Component/AttachmentList.vue | 5 +- 4 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/js/generic-doc-api.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/js/generic-doc-api.ts index c15eff711..8ec988707 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/js/generic-doc-api.ts +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/js/generic-doc-api.ts @@ -1,5 +1,6 @@ -import { fetchResults } from "ChillMainAssets/lib/api/apiMethods"; +import {fetchResults, makeFetch} from "ChillMainAssets/lib/api/apiMethods"; import { GenericDocForAccompanyingPeriod } from "ChillDocStoreAssets/types/generic_doc"; +import {Address, EntityWorkflow} from "ChillMainAssets/types"; export function fetch_generic_docs_by_accompanying_period( periodId: number, @@ -8,3 +9,17 @@ export function fetch_generic_docs_by_accompanying_period( `/api/1.0/doc-store/generic-doc/by-period/${periodId}/index`, ); } + +export const fetchWorkflow = async ( + workflowId: number, +): Promise => { + try { + return await makeFetch( + "GET", + `/api/1.0/main/workflow/${workflowId}.json`, + ); + } catch (error) { + console.error(`Failed to fetch workflow ${workflowId}:`, error); + throw error; + } +}; diff --git a/src/Bundle/ChillMainBundle/Resources/public/types.ts b/src/Bundle/ChillMainBundle/Resources/public/types.ts index 2cd83bc64..10111a129 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/types.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/types.ts @@ -1,5 +1,6 @@ import { GenericDoc } from "ChillDocStoreAssets/types/generic_doc"; import { StoredObject, StoredObjectStatus } from "ChillDocStoreAssets/types"; +import {Person} from "../../../ChillPersonBundle/Resources/public/types"; export interface DateTime { datetime: string; @@ -202,6 +203,55 @@ export interface WorkflowAttachment { genericDoc: null | GenericDoc; } +export interface Workflow { + name: string; + text: string; +} + +export interface EntityWorkflowStep { + type: "entity_workflow_step"; + id: number; + comment: string; + currentStep: StepDefinition; + isFinal: boolean; + isFreezed: boolean; + isFinalized: boolean; + transitionPrevious: Transition | null; + transitionAfter: Transition | null; + previousId: number | null; + nextId: number | null; + transitionPreviousBy: User | null; + transitionPreviousAt: DateTime | null; +} + +export interface Transition { + name: string; + text: string; + isForward: boolean; +} + +export interface StepDefinition { + name: string; + text: string; +} + +export interface EntityWorkflow { + type: "entity_workflow"; + id: number; + relatedEntityClass: string; + relatedEntityId: number; + workflow: Workflow; + currentStep: EntityWorkflowStep; + steps: EntityWorkflowStep[]; + datas: WorkflowData; + title: string; + isOnHoldAtCurrentStep: boolean; +} + +export interface WorkflowData { + persons: Person[]; +} + export interface ExportGeneration { id: string; type: "export_generation"; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/WorkflowAttachment/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/WorkflowAttachment/App.vue index 9164e134b..8e915a58c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/WorkflowAttachment/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/WorkflowAttachment/App.vue @@ -1,10 +1,11 @@