[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>
This commit is contained in:
fja-odoo
2020-03-02 15:18:29 +00:00
parent b657463d56
commit 3959f30d73
6 changed files with 17 additions and 11 deletions
@@ -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 {
@@ -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: {
@@ -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">
@@ -50,7 +50,7 @@
</div>
<!-- Add Field -->
<div data-js="AddField" data-selector=".s_website_form_field">
<div data-js="AddField" data-selector=".s_website_form_field" data-exclude=".s_website_form_dnone">
<we-button class="fa fa-fw fa-plus"
title="Add a new field after this one"
data-add-field=""
@@ -58,7 +58,8 @@
</div>
<!-- Field -->
<div data-js='WebsiteFieldEditor' data-selector=".s_website_form_field" data-drop-near=".s_website_form_field">
<div data-js='WebsiteFieldEditor' data-selector=".s_website_form_field"
data-exclude=".s_website_form_dnone" data-drop-near=".s_website_form_field">
<we-select data-name="type_opt" string="Type" data-no-preview="true">
<we-title>Custom field</we-title>
<we-button data-custom-field="char">Text</we-button>
@@ -57,7 +57,7 @@
</div>
</div>
</div>
<div class="form-group col-12 s_website_form_field d-none">
<div class="form-group col-12 s_website_form_field s_website_form_dnone">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="contact7">Email To</label>
<div class="col-sm">
@@ -180,7 +180,7 @@
</div>
</div>
</div>
<div class="form-group col-12 s_website_form_field d-none">
<div class="form-group col-12 s_website_form_field s_website_form_dnone">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="recruitment6">Job</label>
<div class="col-sm">
@@ -188,7 +188,7 @@
</div>
</div>
</div>
<div class="form-group col-12 s_website_form_field d-none">
<div class="form-group col-12 s_website_form_field s_website_form_dnone">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="recruitment7">Department</label>
<div class="col-sm">