mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-02 05:57:45 +00:00
fetch workflow and only show delete button on attachment if workflow is not final
This commit is contained in:
parent
5465a6f336
commit
f90e9ea3bc
@ -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 { GenericDocForAccompanyingPeriod } from "ChillDocStoreAssets/types/generic_doc";
|
||||||
|
import {Address, EntityWorkflow} from "ChillMainAssets/types";
|
||||||
|
|
||||||
export function fetch_generic_docs_by_accompanying_period(
|
export function fetch_generic_docs_by_accompanying_period(
|
||||||
periodId: number,
|
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`,
|
`/api/1.0/doc-store/generic-doc/by-period/${periodId}/index`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const fetchWorkflow = async (
|
||||||
|
workflowId: number,
|
||||||
|
): Promise<EntityWorkflow> => {
|
||||||
|
try {
|
||||||
|
return await makeFetch<null, EntityWorkflow>(
|
||||||
|
"GET",
|
||||||
|
`/api/1.0/main/workflow/${workflowId}.json`,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to fetch workflow ${workflowId}:`, error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { GenericDoc } from "ChillDocStoreAssets/types/generic_doc";
|
import { GenericDoc } from "ChillDocStoreAssets/types/generic_doc";
|
||||||
import { StoredObject, StoredObjectStatus } from "ChillDocStoreAssets/types";
|
import { StoredObject, StoredObjectStatus } from "ChillDocStoreAssets/types";
|
||||||
|
import {Person} from "../../../ChillPersonBundle/Resources/public/types";
|
||||||
|
|
||||||
export interface DateTime {
|
export interface DateTime {
|
||||||
datetime: string;
|
datetime: string;
|
||||||
@ -202,6 +203,55 @@ export interface WorkflowAttachment {
|
|||||||
genericDoc: null | GenericDoc;
|
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 {
|
export interface ExportGeneration {
|
||||||
id: string;
|
id: string;
|
||||||
type: "export_generation";
|
type: "export_generation";
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, useTemplateRef } from "vue";
|
import {computed, onMounted, ref, useTemplateRef} from "vue";
|
||||||
import type { WorkflowAttachment } from "ChillMainAssets/types";
|
import type {EntityWorkflow, WorkflowAttachment} from "ChillMainAssets/types";
|
||||||
import PickGenericDocModal from "ChillMainAssets/vuejs/WorkflowAttachment/Component/PickGenericDocModal.vue";
|
import PickGenericDocModal from "ChillMainAssets/vuejs/WorkflowAttachment/Component/PickGenericDocModal.vue";
|
||||||
import { GenericDocForAccompanyingPeriod } from "ChillDocStoreAssets/types/generic_doc";
|
import { GenericDocForAccompanyingPeriod } from "ChillDocStoreAssets/types/generic_doc";
|
||||||
import AttachmentList from "ChillMainAssets/vuejs/WorkflowAttachment/Component/AttachmentList.vue";
|
import AttachmentList from "ChillMainAssets/vuejs/WorkflowAttachment/Component/AttachmentList.vue";
|
||||||
import { GenericDoc } from "ChillDocStoreAssets/types";
|
import { GenericDoc } from "ChillDocStoreAssets/types";
|
||||||
|
import {fetch_generic_docs_by_accompanying_period, fetchWorkflow} from "ChillDocStoreAssets/js/generic-doc-api";
|
||||||
|
|
||||||
interface AppConfig {
|
interface AppConfig {
|
||||||
workflowId: number;
|
workflowId: number;
|
||||||
@ -34,6 +35,13 @@ const attachedGenericDoc = computed<GenericDocForAccompanyingPeriod[]>(
|
|||||||
) as GenericDocForAccompanyingPeriod[],
|
) as GenericDocForAccompanyingPeriod[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const workflow = ref<EntityWorkflow | null>(null);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
workflow.value = await fetchWorkflow(Number(props.workflowId));
|
||||||
|
console.log('workflow', workflow.value);
|
||||||
|
});
|
||||||
|
|
||||||
const openModal = function () {
|
const openModal = function () {
|
||||||
pickDocModal.value?.openModal();
|
pickDocModal.value?.openModal();
|
||||||
};
|
};
|
||||||
@ -53,12 +61,14 @@ const onRemoveAttachment = (payload: { attachment: WorkflowAttachment }) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<pick-generic-doc-modal
|
<pick-generic-doc-modal
|
||||||
|
:workflow="workflow"
|
||||||
:accompanying-period-id="props.accompanyingPeriodId"
|
:accompanying-period-id="props.accompanyingPeriodId"
|
||||||
:to-remove="attachedGenericDoc"
|
:to-remove="attachedGenericDoc"
|
||||||
ref="pickDocModal"
|
ref="pickDocModal"
|
||||||
@pickGenericDoc="onPickGenericDoc"
|
@pickGenericDoc="onPickGenericDoc"
|
||||||
></pick-generic-doc-modal>
|
></pick-generic-doc-modal>
|
||||||
<attachment-list
|
<attachment-list
|
||||||
|
:workflow="workflow"
|
||||||
:attachments="props.attachments"
|
:attachments="props.attachments"
|
||||||
@removeAttachment="onRemoveAttachment"
|
@removeAttachment="onRemoveAttachment"
|
||||||
></attachment-list>
|
></attachment-list>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { WorkflowAttachment } from "ChillMainAssets/types";
|
import {EntityWorkflow, WorkflowAttachment} from "ChillMainAssets/types";
|
||||||
import GenericDocItemBox from "ChillMainAssets/vuejs/WorkflowAttachment/Component/GenericDocItemBox.vue";
|
import GenericDocItemBox from "ChillMainAssets/vuejs/WorkflowAttachment/Component/GenericDocItemBox.vue";
|
||||||
import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue";
|
import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue";
|
||||||
|
|
||||||
interface AttachmentListProps {
|
interface AttachmentListProps {
|
||||||
attachments: WorkflowAttachment[];
|
attachments: WorkflowAttachment[];
|
||||||
|
workflow: EntityWorkflow | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -36,7 +37,7 @@ const props = defineProps<AttachmentListProps>();
|
|||||||
:stored-object="a.genericDoc.storedObject"
|
:stored-object="a.genericDoc.storedObject"
|
||||||
></document-action-buttons-group>
|
></document-action-buttons-group>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li v-if="!workflow?.currentStep.isFinal">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-delete"
|
class="btn btn-delete"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user