mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'signature-app/OP762-fix-create-workflow-action' into 'signature-app-master'
Fix the triggering of the vent goToGenerateWorkflow when relatedentityId is not know in PickWorkflow vue component See merge request Chill-Projet/chill-bundles!747
This commit is contained in:
commit
71aaf01687
@ -1,4 +1,18 @@
|
|||||||
export const buildLinkCreate = (workflowName: string, relatedEntityClass: string, relatedEntityId: number): string => {
|
/**
|
||||||
|
* Constructs a URL for creating a workflow link associated with a specific entity.
|
||||||
|
*
|
||||||
|
* @param {string} workflowName - The name of the workflow to associate.
|
||||||
|
* @param {string} relatedEntityClass - The class/type of the related entity.
|
||||||
|
* @param {number|undefined} relatedEntityId - The unique identifier of the related entity. Must be defined.
|
||||||
|
*
|
||||||
|
* @returns {string} The constructed URL containing query parameters based on the provided arguments.
|
||||||
|
*
|
||||||
|
* @throws {Error} If the related entity ID is undefined.
|
||||||
|
*/
|
||||||
|
export const buildLinkCreate = (workflowName: string, relatedEntityClass: string, relatedEntityId: number|undefined): string => {
|
||||||
|
if (typeof (relatedEntityId) === 'undefined') {
|
||||||
|
throw new Error("the related entity id is not set");
|
||||||
|
}
|
||||||
let params = new URLSearchParams();
|
let params = new URLSearchParams();
|
||||||
params.set('entityClass', relatedEntityClass);
|
params.set('entityClass', relatedEntityClass);
|
||||||
params.set('entityId', relatedEntityId.toString(10));
|
params.set('entityId', relatedEntityId.toString(10));
|
||||||
|
@ -20,7 +20,13 @@ import {WorkflowAvailable} from "../../../types";
|
|||||||
|
|
||||||
interface PickWorkflowConfig {
|
interface PickWorkflowConfig {
|
||||||
relatedEntityClass: string;
|
relatedEntityClass: string;
|
||||||
relatedEntityId: number;
|
/**
|
||||||
|
* Represents the identifier of a related entity.
|
||||||
|
* This variable can store either a numerical value representing the entity's ID or an undefined value
|
||||||
|
* if the related entity is not specified or available, for instance when the entity is created within
|
||||||
|
* the interface and the id will be available later
|
||||||
|
*/
|
||||||
|
relatedEntityId: number|undefined;
|
||||||
workflowsAvailables: WorkflowAvailable[];
|
workflowsAvailables: WorkflowAvailable[];
|
||||||
preventDefaultMoveToGenerate: boolean;
|
preventDefaultMoveToGenerate: boolean;
|
||||||
goToGenerateWorkflowPayload: object;
|
goToGenerateWorkflowPayload: object;
|
||||||
@ -29,20 +35,28 @@ interface PickWorkflowConfig {
|
|||||||
const props = withDefaults(defineProps<PickWorkflowConfig>(), {preventDefaultMoveToGenerate: false, goToGenerateWorkflowPayload: {}});
|
const props = withDefaults(defineProps<PickWorkflowConfig>(), {preventDefaultMoveToGenerate: false, goToGenerateWorkflowPayload: {}});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'goToGenerateWorkflow', {event: MouseEvent, workflowName: string, link: string, payload: object}): void;
|
(e: 'goToGenerateWorkflow', {event: MouseEvent, workflowName: string, isLinkValid: boolean, link: string, payload: object}): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const makeLink = (workflowName: string): string => buildLinkCreate(workflowName, props.relatedEntityClass, props.relatedEntityId);
|
const makeLink = (workflowName: string): string => buildLinkCreate(workflowName, props.relatedEntityClass, props.relatedEntityId);
|
||||||
|
|
||||||
const goToGenerateWorkflow = (event: MouseEvent, workflowName: string): void => {
|
const goToGenerateWorkflow = (event: MouseEvent, workflowName: string): void => {
|
||||||
console.log('goToGenerateWorkflow', event, workflowName);
|
console.log('goToGenerateWorkflow', event, workflowName);
|
||||||
|
let link = '';
|
||||||
|
let isLinkValid = false;
|
||||||
|
|
||||||
if (!props.preventDefaultMoveToGenerate) {
|
try {
|
||||||
console.log('to go generate');
|
link = makeLink(workflowName);
|
||||||
window.location.assign(makeLink(workflowName));
|
isLinkValid = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.info("could not generate link to create workflow, maybe the relatedEntityId is not yet known", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('goToGenerateWorkflow', {event, workflowName, link: makeLink(workflowName), payload: props.goToGenerateWorkflowPayload});
|
if (!props.preventDefaultMoveToGenerate) {
|
||||||
|
window.location.assign(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('goToGenerateWorkflow', {event, workflowName, link, isLinkValid, payload: props.goToGenerateWorkflowPayload});
|
||||||
}
|
}
|
||||||
|
|
||||||
const goToDuplicateRelatedEntity = (event: MouseEvent, workflowName: string): void => {
|
const goToDuplicateRelatedEntity = (event: MouseEvent, workflowName: string): void => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user