Skip to content

Commit

Permalink
update url to direct to the workpackage creation form directly
Browse files Browse the repository at this point in the history
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
  • Loading branch information
SwikritiT committed Oct 19, 2023
1 parent 07d9578 commit 89079d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/views/CreateWorkPackageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ export default {
return this.mappedProjects()
},
sanitizedRequiredCustomTypeValidationErrorMessage() {
const htmlLink = `<a class="openProjectUrl" href=${this.openProjectUrl} target="_blank" title="OpenProject">OpenProject</a>`
// 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 = `<a class="openProjectUrl" href=${createWorkpackageFullUrl} target="_blank" title="OpenProject">OpenProject</a>`
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}.',
Expand Down
1 change: 1 addition & 0 deletions tests/jest/views/CreateWorkpackageModal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 89079d2

Please sign in to comment.