Bug 29828: Prevent additional content to be created without default

When creating or editing an additional content, the form is submitted if
only the title of the 'default' tab is filled in.
We should submit the form only if both title and content exist.

Test plan:
Create a new content using text editor (codemirror)
Confirm that the form is submitted only if title and content from the
default tab are not empty
Try again with wysiwyg (tinymce)

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-01-10 10:15:35 +01:00 committed by Tomas Cohen Arazi
parent 554c9cb7d9
commit 05934b89b1
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -574,6 +574,18 @@
alert(_("Please specify a title for 'Default'"));
return false;
}
else {
[% UNLESS wysiwyg %]
let content = $('#content_default').siblings(".CodeMirror")[0].CodeMirror.getValue();
[% ELSE %]
let content = tinyMCE.get('content_default').getContent();
[% END %]
if ( ! content.length > 0 ) {
alert(__("Please specify a content for 'Default'"));
return false;
}
}
form.submit();
}