diff --git a/src/views/CreateWorkPackageModal.vue b/src/views/CreateWorkPackageModal.vue
index 1c5bc81fe..6a408a2c0 100644
--- a/src/views/CreateWorkPackageModal.vue
+++ b/src/views/CreateWorkPackageModal.vue
@@ -69,7 +69,7 @@
{{ t('integration_openproject', 'Please select a project') }}
-
@@ -123,7 +123,7 @@
{{ t("integration_openproject", "Cancel") }}
-
+
{{ t("integration_openproject", "Create") }}
@@ -218,6 +218,7 @@ export default {
projectId: null,
description: DEFAULT_DESCRIPTION_VALUE,
error: DEFAULT_ERROR_VALUE,
+ customTypeError: false,
}),
computed: {
openModal() {
@@ -241,6 +242,17 @@ export default {
mappedNodes() {
return this.mappedProjects()
},
+ sanitizedRequiredCustomTypeValidationErrorMessage() {
+ 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}.',
+ { htmlLink },
+ null,
+ { escape: false, sanitize: false }
+ )
+ return dompurify.sanitize(message, { ADD_ATTR: ['target'] })
+ },
},
methods: {
mappedProjects() {
@@ -335,8 +347,8 @@ export default {
await this.validateWorkPackageForm(this.projectId, true, true)
},
async onSelectType(selectedOption) {
- if (this.error.error) {
- this.error = DEFAULT_ERROR_VALUE
+ if (this.customTypeError) {
+ this.customTypeError = false
}
this.type = selectedOption
// set the allowed values for status when type selection changes
@@ -381,20 +393,7 @@ export default {
const validationErrors = response.data.validationErrors
for (const errors in validationErrors) {
if (errors.startsWith('customField')) {
- 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}.',
- { htmlLink },
- null,
- { escape: false, sanitize: false }
- )
- this.error = {
- error: true,
- attribute: 'type',
- message: dompurify.sanitize(message, { ADD_ATTR: ['target'] }),
- multipleErrors: {},
- }
+ this.customTypeError = true
return
}
}
diff --git a/tests/jest/components/tab/SearchInput.spec.js b/tests/jest/components/tab/SearchInput.spec.js
index 7157c4436..7b21ecb01 100644
--- a/tests/jest/components/tab/SearchInput.spec.js
+++ b/tests/jest/components/tab/SearchInput.spec.js
@@ -880,7 +880,7 @@ describe('SearchInput.vue', () => {
const workpackageCreationEventData = {
openProjectEventName: 'work_package_creation_cancellation',
}
- wrapper.vm.handelCreateWorkPackageEvent(workpackageCreationEventData)
+ wrapper.vm.onCreateWorkPackageEvent(workpackageCreationEventData)
expect(dialogs.showError).toBeCalledTimes(1)
expect(dialogs.showError).toBeCalledWith('Work package creation was not successful.')
})
@@ -918,7 +918,7 @@ describe('SearchInput.vue', () => {
fileInfo: { id: 1234, name: 'file.txt' },
})
await wrapper.vm.$nextTick()
- wrapper.vm.handelCreateWorkPackageEvent(workpackageCreationEventData)
+ wrapper.vm.onCreateWorkPackageEvent(workpackageCreationEventData)
await wrapper.vm.$nextTick()
expect(dialogs.showSuccess).toBeCalledTimes(2)
expect(dialogs.showSuccess).toBeCalledWith('Work package created successfully.')
diff --git a/tests/jest/views/CreateWorkpackageModal.spec.js b/tests/jest/views/CreateWorkpackageModal.spec.js
index 2903bc9fc..30e88e4b8 100644
--- a/tests/jest/views/CreateWorkpackageModal.spec.js
+++ b/tests/jest/views/CreateWorkpackageModal.spec.js
@@ -475,7 +475,7 @@ describe('CreateWorkPackageModal.vue', () => {
})
})
- it('should display error when theirs a required custom field', async () => {
+ it('should display error when there is a required custom field', async () => {
const bodyFormValidation = {
body: {
_links: {
diff --git a/tests/jest/views/__snapshots__/CreateWorkpackageModal.spec.js.snap b/tests/jest/views/__snapshots__/CreateWorkpackageModal.spec.js.snap
index b5e974d4a..1568133bc 100644
--- a/tests/jest/views/__snapshots__/CreateWorkpackageModal.spec.js.snap
+++ b/tests/jest/views/__snapshots__/CreateWorkpackageModal.spec.js.snap
@@ -3,10 +3,7 @@
exports[`CreateWorkPackageModal.vue workpackage creation form should display available projects in the project dropdown 1`] = `