From 89079d24bcc4a1f1830b0ec9cb20ca4178227731 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Thu, 19 Oct 2023 15:37:47 +0545 Subject: [PATCH] update url to direct to the workpackage creation form directly Signed-off-by: Swikriti Tripathi --- src/views/CreateWorkPackageModal.vue | 5 ++++- tests/jest/views/CreateWorkpackageModal.spec.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/CreateWorkPackageModal.vue b/src/views/CreateWorkPackageModal.vue index 5fa123c86..c16f5e359 100644 --- a/src/views/CreateWorkPackageModal.vue +++ b/src/views/CreateWorkPackageModal.vue @@ -248,7 +248,10 @@ export default { return this.mappedProjects() }, sanitizedRequiredCustomTypeValidationErrorMessage() { - const htmlLink = `OpenProject` + // get the last number from the href i.e `/api/v3/types/1`, which is the type id + const typeID = parseInt(this.type.self.href.match(/\d+$/)[0], 10) + const createWorkpackageFullUrl = this.openProjectUrl.replace(/\/+$/, '') + '/projects/' + this.project.identifier + `/work_packages/new?type=${typeID}` + const htmlLink = `OpenProject` const message = t( 'integration_openproject', 'This type has mandatory fields which cannot be filled here. Please, create work packages of this type directly in {htmlLink}.', diff --git a/tests/jest/views/CreateWorkpackageModal.spec.js b/tests/jest/views/CreateWorkpackageModal.spec.js index 30e88e4b8..e8d65a60b 100644 --- a/tests/jest/views/CreateWorkpackageModal.spec.js +++ b/tests/jest/views/CreateWorkpackageModal.spec.js @@ -543,6 +543,7 @@ describe('CreateWorkPackageModal.vue', () => { subject: 'This is a workpackage', allowedTypes, projectId: 2, + openProjectUrl: 'https://openproject.example.com', }) await wrapper.find(typeInputFieldSelector).setValue('Required') await wrapper.find(typeOptionsSelector).trigger('click')