pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
297 stars 442 forks source link

Unable to save edited email template #7413

Closed Vitaliy-1 closed 2 years ago

Vitaliy-1 commented 2 years ago

Describe the bug When trying to save the edited email template, I'm receiving js error:

build.js?v=3.1.1.4:171244 TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at build.js?v=3.1.1.4:14635
    at Array.forEach (<anonymous>)
    at VueComponent.submitValues (build.js?v=3.1.1.4:14623)
    at Watcher.get (build.js?v=3.1.1.4:173837)
    at Watcher.evaluate (build.js?v=3.1.1.4:173939)
    at VueComponent.computedGetter [as submitValues] (build.js?v=3.1.1.4:174191)
    at VueComponent.submit (build.js?v=3.1.1.4:14706)
    at VueComponent.nextPage (build.js?v=3.1.1.4:14666)
    at invokeWithErrorHandling (build.js?v=3.1.1.4:171210)

The error refers to this line: https://github.com/pkp/ui-library/blob/7a0659967fa39eef926c35fb7445f6f28d18a256/src/components/Form/Form.vue#L188

To Reproduce Steps to reproduce the behavior:

  1. Go to Workflow -> Email -> Email Templates
  2. Click on Edit
  3. Click on Save
  4. See error

What application are you using? OJS main branch Google Chrome Version 95.0.4638.54

Additional information It's strange that I haven't received this error before, as I don't see any new changes there. What's is happening is that there are 3 fields in the form: field-html, field-text and field-rich-textarea. By the time when the method submitValues is executed, field-html (description) doesn't have a value property. If add additional check above referenced line to:

} else if ('value' in field) {
....

Fixes the issue.

edit This is what props Vue debugging tool gives me when inspecting the FieldHTML before saving


allErrors: Object (empty)
component: "field-html"
description: "The email is sent to registered users that have selected to have this type of notification emailed to them."
formId: "editEmailTemplate"
groupId: "default"
helpSection: undefined
helpTopic: undefined
isMultilingual: true
isRequired: false
label: "Description"
localeKey: "en_US"
locales: Array[1]
  0: Object
    key: "en_US"
    label: "English"
name: "description"
primaryLocale: "en_US"
showWhen: undefined
tooltip: undefined
value: undefined
NateWr commented 2 years ago

This sounds like a duplicate of https://github.com/pkp/pkp-lib/issues/6969. Are you sure that your copy of lib/ui-library is up-to-date and that you've recently recompiled the JS?

Vitaliy-1 commented 2 years ago

For some reason unable to replicate, probably bug with browser's cache or js compilation.