summaryrefslogtreecommitdiff
path: root/addons/website_form/static
diff options
context:
space:
mode:
authorfja-odoo <fja@odoo.com>2020-02-28 09:08:28 +0000
committerfja-odoo <fja@odoo.com>2020-03-02 15:18:29 +0000
commit3959f30d738e02855ca4acb5f607a0148ffc2388 (patch)
tree8a470d4f498c2c58a9465261b9d712c7318a69fe /addons/website_form/static
parentb657463d56cc2bd1ec993233cf40eb384fb35700 (diff)
[FIX] website_form,*: fix d-none field no options
* = website_hr_recruitment The hidden fields containing form infos have options activated on them because of the class s_website_form_field. When a saved snippet is dropped the snippet editor tries to activate them. They should not have any options. closes odoo/odoo#46660 X-original-commit: 14d2283e739282f82828e0ba3792f9f1126d0033 Related: odoo/enterprise#8956 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website_form/static')
-rw-r--r--addons/website_form/static/src/snippets/s_website_form/001.scss4
-rw-r--r--addons/website_form/static/src/snippets/s_website_form/options.js11
-rw-r--r--addons/website_form/static/src/xml/website_form_editor.xml2
3 files changed, 11 insertions, 6 deletions
diff --git a/addons/website_form/static/src/snippets/s_website_form/001.scss b/addons/website_form/static/src/snippets/s_website_form/001.scss
index cb0ad2e2c2b..acfaae6f5a1 100644
--- a/addons/website_form/static/src/snippets/s_website_form/001.scss
+++ b/addons/website_form/static/src/snippets/s_website_form/001.scss
@@ -31,6 +31,10 @@
font-weight: 400;
}
+ .s_website_form_dnone {
+ display: none;
+ }
+
// The snippet editor uses padding and not margin.
// This will include bootstrap margin in the dragable y axes
.s_website_form_rows > .form-group {
diff --git a/addons/website_form/static/src/snippets/s_website_form/options.js b/addons/website_form/static/src/snippets/s_website_form/options.js
index d1eb41c14be..44c66f9fe24 100644
--- a/addons/website_form/static/src/snippets/s_website_form/options.js
+++ b/addons/website_form/static/src/snippets/s_website_form/options.js
@@ -433,7 +433,7 @@ options.registry.WebsiteFormEditor = FormEditor.extend({
if (params.isSelect === 'true') {
value = parseInt(value);
}
- this.addHiddenField(value, fieldName);
+ this._addHiddenField(value, fieldName);
},
/**
* Changes the onSuccess event.
@@ -489,7 +489,7 @@ options.registry.WebsiteFormEditor = FormEditor.extend({
case 'selectAction':
return this.activeForm.id;
case 'addActionField': {
- const value = this.$target.find(`.s_website_form_field.d-none input[name="${params.fieldName}"]`).val();
+ const value = this.$target.find(`.s_website_form_dnone input[name="${params.fieldName}"]`).val();
if (value) {
return value;
} else {
@@ -535,7 +535,7 @@ options.registry.WebsiteFormEditor = FormEditor.extend({
if (field.required) {
// Get default value or for many2one fields the first option.
const defaultValue = field.defaultValue || field.records[0].id;
- this.addHiddenField(defaultValue, field.name);
+ this._addHiddenField(defaultValue, field.name);
}
uiFragment.insertBefore(option, firstOption);
});
@@ -544,11 +544,12 @@ options.registry.WebsiteFormEditor = FormEditor.extend({
/**
* Add a hidden field to the form
*
+ * @private
* @param {string} value
* @param {string} fieldName
*/
- addHiddenField: function (value, fieldName) {
- this.$target.find(`.s_website_form_field.d-none:has(input[name="${fieldName}"])`).remove();
+ _addHiddenField: function (value, fieldName) {
+ this.$target.find(`.s_website_form_dnone:has(input[name="${fieldName}"])`).remove();
if (value) {
const hiddenField = qweb.render('website_form.field_hidden', {
field: {
diff --git a/addons/website_form/static/src/xml/website_form_editor.xml b/addons/website_form/static/src/xml/website_form_editor.xml
index f191edc8f39..0d718178300 100644
--- a/addons/website_form/static/src/xml/website_form_editor.xml
+++ b/addons/website_form/static/src/xml/website_form_editor.xml
@@ -24,7 +24,7 @@
<!-- Generic Field Layout -->
<!-- Changes made here needs to be reflected in the different Form view (Contact Us, Jobs, ...) -->
<t t-name="website_form.field">
- <div t-attf-class="form-group s_website_form_field #{field.formatInfo.col or 'col-12'} #{field.custom and 's_website_form_custom' or ''} #{(field.required and 's_website_form_required' or '') or (field.modelRequired and 's_website_form_model_required' or '')} #{field.hidden and 's_website_form_field_hidden' or ''} #{field.dnone and 'd-none' or ''}"
+ <div t-attf-class="form-group s_website_form_field #{field.formatInfo.col or 'col-12'} #{field.custom and 's_website_form_custom' or ''} #{(field.required and 's_website_form_required' or '') or (field.modelRequired and 's_website_form_model_required' or '')} #{field.hidden and 's_website_form_field_hidden' or ''} #{field.dnone and 's_website_form_dnone' or ''}"
t-att-data-type="field.type"
data-name="Field">
<div t-if="field.formatInfo.labelPosition != 'none' and field.formatInfo.labelPosition != 'top'" class="row s_col_no_resize s_col_no_bgcolor">