[IMP] website_form_editor: various improvements
- Prevent user from removing the Submit button - Renamed Success Page into Thank You Page in the modal - Destroy the snippet if user closes the very first configuration modal - Replaced display_name field by subject in tour because the former was readonly - Changed "Editor" to "Builder" in module name - Removed field domain, need to fix it later - Removed lingering console.log - Require recipient e-mail - Added missing Date field
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
'name': 'Website Form Editor',
|
||||
'name': 'Website Form Builder',
|
||||
'category': 'Website',
|
||||
'summary': 'Build custom web forms using the website builder',
|
||||
'version': '1.0',
|
||||
|
||||
@@ -27,9 +27,19 @@ odoo.define('website_form_editor', function (require) {
|
||||
self.$modal.appendTo('body');
|
||||
|
||||
// Process the modal on_save then hide it
|
||||
self.$modal.find("#modal-save").on('click', function(){
|
||||
on_save();
|
||||
self.$modal.modal('hide');
|
||||
self.$modal.find("#modal-save").on('click', function(e){
|
||||
if (self.$modal.find("form")[0].checkValidity()) {
|
||||
on_save();
|
||||
self.$modal.modal('hide');
|
||||
} else {
|
||||
_.each(self.$modal.find('input'), function(input) {
|
||||
var $field = $(input).closest('.form-field');
|
||||
$field.removeClass('has-error');
|
||||
if (!input.checkValidity()) {
|
||||
$field.addClass('has-error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy the modal when it is closed, as we will use many of them
|
||||
@@ -122,7 +132,7 @@ odoo.define('website_form_editor', function (require) {
|
||||
var success_page = qweb.render("website_form_editor.field_char", {
|
||||
field: {
|
||||
name: 'success_page',
|
||||
string: 'Success Page',
|
||||
string: 'Thank You Page',
|
||||
value: self.$target.attr('data-success_page')
|
||||
}
|
||||
});
|
||||
@@ -151,6 +161,15 @@ odoo.define('website_form_editor', function (require) {
|
||||
self.$modal.find("[name='model_selection']").on('change', function() {
|
||||
self.toggle_email_to();
|
||||
});
|
||||
|
||||
// On modal close, if there is no data-model, it means
|
||||
// that the user refused to configure the form on the
|
||||
// first modal, so we remove the snippet.
|
||||
self.$modal.on('hidden.bs.modal', function (e) {
|
||||
if (!self.$target.attr('data-model_name')){
|
||||
self.$target.remove();
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
@@ -186,10 +205,6 @@ odoo.define('website_form_editor', function (require) {
|
||||
self.append_field(selected_field);
|
||||
}
|
||||
);
|
||||
|
||||
self.$modal.find("[name='field_selection']").on('change', function() {
|
||||
console.log('changed');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -290,7 +305,7 @@ odoo.define('website_form_editor', function (require) {
|
||||
model: field.relation,
|
||||
method: 'search_read',
|
||||
args: [
|
||||
field.domain,
|
||||
// field.domain, TODO: Handle field domains
|
||||
['display_name']
|
||||
],
|
||||
kwargs:{"context": base.get_context()}
|
||||
|
||||
@@ -51,7 +51,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
title: "Click on Save",
|
||||
element: ".modal-footer #modal-save"
|
||||
},
|
||||
// Add the display_name field
|
||||
// Add the subject field
|
||||
{
|
||||
title: "Click on Form snippet",
|
||||
element: ".s_website_form[data-model_name]"
|
||||
@@ -65,19 +65,19 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
element: ".oe_overlay_options:visible li[data-website_form_field_modal] a"
|
||||
},
|
||||
{
|
||||
title: "Select the display_name field",
|
||||
title: "Select the subject field",
|
||||
element: "select[name='field_selection']",
|
||||
sampleText: "display_name"
|
||||
sampleText: "subject"
|
||||
},
|
||||
{
|
||||
title: "Click on Save",
|
||||
element: ".modal-footer #modal-save"
|
||||
},
|
||||
|
||||
// Customize display_name field
|
||||
// Customize subject field
|
||||
{
|
||||
title: "Change the label",
|
||||
element: ".control-label[for='display_name']",
|
||||
element: ".control-label[for='subject']",
|
||||
sampleText: "Name"
|
||||
},
|
||||
{
|
||||
@@ -91,7 +91,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
{
|
||||
title: "Check the resulting field",
|
||||
waitFor: ".form-field.o_website_form_required_custom" +
|
||||
":has(input[type=text][name=display_name][required])" +
|
||||
":has(input[type=text][name=subject][required])" +
|
||||
":has(label:contains('Name'))"
|
||||
},
|
||||
|
||||
@@ -109,7 +109,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
element: ".oe_overlay_options:visible li[data-website_form_field_modal] a"
|
||||
},
|
||||
{
|
||||
title: "Select the display_name field",
|
||||
title: "Select the subject field",
|
||||
element: "select[name='field_selection']",
|
||||
sampleText: "record_name"
|
||||
},
|
||||
@@ -154,7 +154,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
element: ".oe_overlay_options:visible li[data-website_form_field_modal] a"
|
||||
},
|
||||
{
|
||||
title: "Select the display_name field",
|
||||
title: "Select the subject field",
|
||||
element: "select[name='field_selection']",
|
||||
sampleText: "body_html"
|
||||
},
|
||||
@@ -163,7 +163,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
element: ".modal-footer #modal-save"
|
||||
},
|
||||
|
||||
// Customize display_name field
|
||||
// Customize subject field
|
||||
{
|
||||
title: "Change the label",
|
||||
element: ".control-label[for='body_html']",
|
||||
@@ -434,7 +434,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
element: ".oe_overlay_options:visible li[data-website_form_field_modal] a"
|
||||
},
|
||||
{
|
||||
title: "Select the display_name field",
|
||||
title: "Select the subject field",
|
||||
element: "select[name='field_selection']",
|
||||
sampleText: "attachment_ids"
|
||||
},
|
||||
@@ -486,7 +486,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
title: "Try to send empty form",
|
||||
waitFor: "form[data-model_name='mail.mail']" +
|
||||
"[data-success_page='']" +
|
||||
":has(.form-field:has(label:contains('Name')):has(input[type='text'][name='display_name'][required]))" +
|
||||
":has(.form-field:has(label:contains('Name')):has(input[type='text'][name='subject'][required]))" +
|
||||
":has(.form-field:has(label:contains('Awesome Label')):hidden)" +
|
||||
":has(.form-field:has(label:contains('Your Message')):has(textarea[name='body_html'][required]))" +
|
||||
":has(.form-field:has(label:contains('Products')):has(input[type='checkbox'][name='Products'][value='Iphone'][required]))" +
|
||||
@@ -513,7 +513,7 @@ odoo.define('website_form_editor.tour', function(require) {
|
||||
":has(.form-field:has(label:contains('Service')):not(.has-error))" +
|
||||
":has(.form-field:has(label:contains('State')):not(.has-error))" +
|
||||
":has(.form-field:has(label:contains('Invoice Scan')):not(.has-error))",
|
||||
element: "input[name=display_name]",
|
||||
element: "input[name=subject]",
|
||||
sampleText: "Jane Smith"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -99,6 +99,18 @@
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<!-- Date Field -->
|
||||
<t t-name="website_form_editor.field_date">
|
||||
<t t-call="website_form_editor.field">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control o_website_form_input o_website_form_date"
|
||||
t-att-name="field.name"
|
||||
t-att-required="field.required"
|
||||
/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<!-- Datetime Field -->
|
||||
<t t-name="website_form_editor.field_datetime">
|
||||
<t t-call="website_form_editor.field">
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<li data-website_form_custom_field="selection"><a>Radio Buttons</a></li>
|
||||
<li data-website_form_custom_field="many2one"><a>Selection</a></li>
|
||||
<li data-website_form_custom_field="one2many"><a>Multiple Checkboxes</a></li>
|
||||
<li data-website_form_custom_field="date"><a>Date</a></li>
|
||||
<li data-website_form_custom_field="datetime"><a>Date & Time</a></li>
|
||||
<li data-website_form_custom_field="binary"><a>File Upload</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -68,6 +70,9 @@
|
||||
<!-- Remove the duplicate option of model select items -->
|
||||
<div data-js="website_form_editor_field_x2many" data-selector=".s_website_form .form-field:not(.o_website_form_custom) .o_website_form_select_item" data-drop-near=".o_website_form_select_item"/>
|
||||
|
||||
<!-- Remove the delete options of the Submit button -->
|
||||
<div data-js="website_form_editor_field_required" data-selector=".s_website_form .o_website_form_send"/>
|
||||
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user