mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-29 08:24:51 +00:00 
			
		
		
		
	Rewrite the Component PickWorkflow.vue into typescript
This commit is contained in:
		| @@ -1,12 +1,8 @@ | ||||
| const buildLinkCreate = function(workflowName, relatedEntityClass, relatedEntityId) { | ||||
| export const buildLinkCreate = (workflowName: string, relatedEntityClass: string, relatedEntityId: number): string => { | ||||
|     let params = new URLSearchParams(); | ||||
|     params.set('entityClass', relatedEntityClass); | ||||
|     params.set('entityId', relatedEntityId); | ||||
|     params.set('entityId', relatedEntityId.toString(10)); | ||||
|     params.set('workflow', workflowName); | ||||
| 
 | ||||
|     return `/fr/main/workflow/create?`+params.toString(); | ||||
| }; | ||||
| 
 | ||||
| export { | ||||
|     buildLinkCreate, | ||||
| }; | ||||
| @@ -168,3 +168,8 @@ export interface NewsItemType { | ||||
|     startDate: DateTime; | ||||
|     endDate: DateTime | null; | ||||
| } | ||||
|  | ||||
| export interface WorkflowAvailable { | ||||
|     name: string; | ||||
|     text: string; | ||||
| } | ||||
|   | ||||
| @@ -1,63 +1,52 @@ | ||||
| <template> | ||||
|     <template v-if="workflowsAvailables.length >= 1"> | ||||
|     <template v-if="props.workflowsAvailables.length >= 1"> | ||||
|         <div class="dropdown d-grid gap-2"> | ||||
|             <button class="btn btn-primary dropdown-toggle" type="button" id="createWorkflowButton" data-bs-toggle="dropdown" aria-expanded="false"> | ||||
|                 Créer un workflow | ||||
|             </button> | ||||
|             <ul class="dropdown-menu" aria-labelledby="createWorkflowButton"> | ||||
|                 <li v-for="w in workflowsAvailables" :key="w.name"> | ||||
|                     <a class="dropdown-item" :href="makeLink(w.name)" @click.prevent="goToGenerateWorkflow($event, w.name)">{{ w.text }}</a> | ||||
|                 <li v-for="w in props.workflowsAvailables" :key="w.name"> | ||||
|                     <button class="dropdown-item" type="button" @click.prevent="goToGenerateWorkflow($event, w.name)">{{ w.text }}</button> | ||||
|                 </li> | ||||
|             </ul> | ||||
|         </div> | ||||
|     </template> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| <script setup lang="ts"> | ||||
|  | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; | ||||
| import {buildLinkCreate} from '../../../lib/entity-workflow/api'; | ||||
| import {WorkflowAvailable} from "../../../types"; | ||||
|  | ||||
| export default { | ||||
|     name: "PickWorkflow", | ||||
|     props: { | ||||
|         relatedEntityClass: { | ||||
|             type: String, | ||||
|             required: true, | ||||
|         }, | ||||
|         relatedEntityId: { | ||||
|             type: Number, | ||||
|             required: false, | ||||
|         }, | ||||
|         workflowsAvailables: { | ||||
|             type: Array, | ||||
|             required: true, | ||||
|         }, | ||||
|         preventDefaultMoveToGenerate: { | ||||
|             type: Boolean, | ||||
|             required: false, | ||||
|             default: false, | ||||
|         }, | ||||
|         goToGenerateWorkflowPayload: { | ||||
|             required: false, | ||||
|             default: {} | ||||
|         }, | ||||
|     }, | ||||
|     emits: ['goToGenerateWorkflow'], | ||||
|     methods: { | ||||
|         makeLink(workflowName) { | ||||
|             return buildLinkCreate(workflowName, this.relatedEntityClass, this.relatedEntityId); | ||||
|         }, | ||||
|         goToGenerateWorkflow(event, workflowName) { | ||||
|             console.log('goToGenerateWorkflow', event, workflowName); | ||||
| interface PickWorkflowConfig { | ||||
|     relatedEntityClass: string; | ||||
|     relatedEntityId: number; | ||||
|     workflowsAvailables: WorkflowAvailable[]; | ||||
|     preventDefaultMoveToGenerate: boolean; | ||||
|     goToGenerateWorkflowPayload: object; | ||||
| } | ||||
|  | ||||
|             if (!this.$props.preventDefaultMoveToGenerate) { | ||||
|                 console.log('to go generate'); | ||||
|                 window.location.assign(this.makeLink(workflowName)); | ||||
|             } | ||||
| const props = withDefaults(defineProps<PickWorkflowConfig>(), {preventDefaultMoveToGenerate: false, goToGenerateWorkflowPayload: {}}); | ||||
|  | ||||
|             this.$emit('goToGenerateWorkflow', {event, workflowName, link: this.makeLink(workflowName), payload: this.goToGenerateWorkflowPayload}); | ||||
|         } | ||||
| const emit = defineEmits<{ | ||||
|     (e: 'goToGenerateWorkflow', {event: MouseEvent, workflowName: string, link: string, payload: object}): void; | ||||
| }>(); | ||||
|  | ||||
| const makeLink = (workflowName: string): string => buildLinkCreate(workflowName, props.relatedEntityClass, props.relatedEntityId); | ||||
|  | ||||
| const goToGenerateWorkflow = (event: MouseEvent, workflowName: string): void  => { | ||||
|     console.log('goToGenerateWorkflow', event, workflowName); | ||||
|  | ||||
|     if (!props.preventDefaultMoveToGenerate) { | ||||
|         console.log('to go generate'); | ||||
|         window.location.assign(makeLink(workflowName)); | ||||
|     } | ||||
|  | ||||
|     emit('goToGenerateWorkflow', {event, workflowName, link: makeLink(workflowName), payload: props.goToGenerateWorkflowPayload}); | ||||
| } | ||||
|  | ||||
| const goToDuplicateRelatedEntity = (event: MouseEvent, workflowName: string): void => { | ||||
|  | ||||
| } | ||||
| </script> | ||||
|  | ||||
|   | ||||
| @@ -342,7 +342,7 @@ import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue'; | ||||
| import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue'; | ||||
| import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue'; | ||||
| import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api'; | ||||
| import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods'; | ||||
|  | ||||
| const i18n = { | ||||
|   | ||||
| @@ -54,7 +54,7 @@ | ||||
| import FormEvaluation from './FormEvaluation.vue'; | ||||
| import Modal from 'ChillMainAssets/vuejs/_components/Modal'; | ||||
| import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api'; | ||||
|  | ||||
| const i18n = { | ||||
|    messages: { | ||||
|   | ||||
| @@ -189,7 +189,7 @@ import { mapGetters, mapState } from 'vuex'; | ||||
| import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue'; | ||||
| import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator'; | ||||
| import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js'; | ||||
| import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api'; | ||||
| import {buildLinkCreate as buildLinkCreateNotification} from 'ChillMainAssets/lib/entity-notification/api'; | ||||
| import DocumentActionButtonsGroup from "ChillDocStoreAssets/vuejs/DocumentActionButtonsGroup.vue"; | ||||
| import DropFileModal from "ChillDocStoreAssets/vuejs/DropFileWidget/DropFileModal.vue"; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user