[REF] *: remove dom_ready module
This commit removes the module "web.dom_ready" and adapts the modules that imported it. This module was used to wait for the content to be loaded to manipulate the dom after that. The goal is to remove async modules and simplify the module loader in the future. task id: 3265979 closes odoo/odoo#119158 Related: odoo/enterprise#40051 Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import "web.dom_ready";
|
||||
import { ConcretePolicy, recommendations } from "@auth_password_policy/password_policy";
|
||||
import PasswordMeter from "@auth_password_policy_signup/js/password_meter";
|
||||
import { whenReady } from "@odoo/owl";
|
||||
|
||||
const signupForm = document.querySelector('.oe_signup_form, .oe_reset_password_form');
|
||||
if (signupForm) {
|
||||
const password = document.querySelector("[type=password][minlength]");
|
||||
const minlength = Number(password.getAttribute("minlength"));
|
||||
if (!isNaN(minlength)) {
|
||||
const meter = new PasswordMeter(null, new ConcretePolicy({minlength}), recommendations);
|
||||
meter.insertAfter(password);
|
||||
password.addEventListener("input", (e) => {
|
||||
meter.update(e.target.value);
|
||||
});
|
||||
whenReady(() => {
|
||||
const signupForm = document.querySelector('.oe_signup_form, .oe_reset_password_form');
|
||||
if (signupForm) {
|
||||
const password = document.querySelector("[type=password][minlength]");
|
||||
const minlength = Number(password.getAttribute("minlength"));
|
||||
if (!isNaN(minlength)) {
|
||||
const meter = new PasswordMeter(null, new ConcretePolicy({minlength}), recommendations);
|
||||
meter.insertAfter(password);
|
||||
password.addEventListener("input", (e) => {
|
||||
meter.update(e.target.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -171,7 +171,6 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'web/static/src/legacy/js/core/cookie_utils.js',
|
||||
'web/static/src/legacy/js/core/utils.js',
|
||||
'web/static/src/legacy/js/core/dom.js',
|
||||
'web/static/src/legacy/js/core/dom_ready.js',
|
||||
'web/static/src/legacy/js/core/qweb.js',
|
||||
'web/static/src/legacy/js/core/bus.js',
|
||||
'web/static/src/legacy/js/services/core.js',
|
||||
|
||||
@@ -1,189 +1,192 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import session from "web.session";
|
||||
import ajax from "web.ajax";
|
||||
import core from "web.core";
|
||||
import "web.dom_ready";
|
||||
import { sprintf, escape } from "@web/core/utils/strings";
|
||||
import session from "web.session";
|
||||
import ajax from "web.ajax";
|
||||
import core from "web.core";
|
||||
import { sprintf, escape } from "@web/core/utils/strings";
|
||||
import { whenReady } from "@odoo/owl";
|
||||
|
||||
var _t = core._t;
|
||||
var _t = core._t;
|
||||
|
||||
whenReady(() => {
|
||||
var email = $("input[name='email']").val();
|
||||
var mailing_id = parseInt($("input[name='mailing_id']").val());
|
||||
var res_id = parseInt($("input[name='res_id']").val());
|
||||
var token = (location.search.split('token' + '=')[1] || '').split('&')[0];
|
||||
|
||||
if ($('.o_unsubscribe_form').length) {
|
||||
session.load_translations().then(function () {
|
||||
if (email != '' && email != undefined){
|
||||
ajax.jsonRpc('/mailing/blacklist/check', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#button_add_blacklist').hide();
|
||||
$('#button_remove_blacklist').hide();
|
||||
}
|
||||
else if (result == true) {
|
||||
$('#button_remove_blacklist').show();
|
||||
toggle_opt_out_section(false);
|
||||
}
|
||||
else if (result == false) {
|
||||
$('#button_add_blacklist').show();
|
||||
toggle_opt_out_section(true);
|
||||
}
|
||||
else {
|
||||
if ($('.o_unsubscribe_form').length) {
|
||||
session.load_translations().then(function () {
|
||||
if (email != '' && email != undefined){
|
||||
ajax.jsonRpc('/mailing/blacklist/check', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#button_add_blacklist').hide();
|
||||
$('#button_remove_blacklist').hide();
|
||||
}
|
||||
else if (result == true) {
|
||||
$('#button_remove_blacklist').show();
|
||||
toggle_opt_out_section(false);
|
||||
}
|
||||
else if (result == false) {
|
||||
$('#button_add_blacklist').show();
|
||||
toggle_opt_out_section(true);
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('#div_blacklist').hide();
|
||||
}
|
||||
|
||||
var unsubscribed_list = $("input[name='unsubscribed_list']").val();
|
||||
if (unsubscribed_list){
|
||||
$('#subscription_info').html(sprintf(
|
||||
_t("You have been <strong>successfully unsubscribed from %s</strong>."),
|
||||
escape(unsubscribed_list)
|
||||
));
|
||||
}
|
||||
else{
|
||||
$('#subscription_info').html(_t('You have been <strong>successfully unsubscribed</strong>.'));
|
||||
}
|
||||
});
|
||||
|
||||
$('#unsubscribe_form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var checked_ids = [];
|
||||
$("input[type='checkbox']:checked").each(function (i){
|
||||
checked_ids[i] = parseInt($(this).val());
|
||||
});
|
||||
|
||||
var unchecked_ids = [];
|
||||
$("input[type='checkbox']:not(:checked)").each(function (i){
|
||||
unchecked_ids[i] = parseInt($(this).val());
|
||||
});
|
||||
|
||||
ajax.jsonRpc('/mailing/list/update', 'call', {'opt_in_ids': checked_ids, 'opt_out_ids': unchecked_ids, 'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else if (result == true) {
|
||||
$('#subscription_info').text(_t('Your changes have been saved.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-success');
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Your changes have not been saved, try again later.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-warning');
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Your changes have not been saved, try again later.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-warning');
|
||||
});
|
||||
});
|
||||
|
||||
// ==================
|
||||
// Blacklist
|
||||
// ==================
|
||||
$('#button_add_blacklist').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
ajax.jsonRpc('/mailing/blacklist/add', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result) {
|
||||
$('#subscription_info').html(_t('You have been successfully <strong>added to our blacklist</strong>. '
|
||||
+ 'You will not be contacted anymore by our services.'));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
toggle_opt_out_section(false);
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
}
|
||||
$('#button_add_blacklist').hide();
|
||||
$('#button_remove_blacklist').show();
|
||||
$('#unsubscribed_info').hide();
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('#div_blacklist').hide();
|
||||
}
|
||||
|
||||
var unsubscribed_list = $("input[name='unsubscribed_list']").val();
|
||||
if (unsubscribed_list){
|
||||
$('#subscription_info').html(sprintf(
|
||||
_t("You have been <strong>successfully unsubscribed from %s</strong>."),
|
||||
escape(unsubscribed_list)
|
||||
));
|
||||
}
|
||||
else{
|
||||
$('#subscription_info').html(_t('You have been <strong>successfully unsubscribed</strong>.'));
|
||||
}
|
||||
});
|
||||
|
||||
$('#unsubscribe_form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var checked_ids = [];
|
||||
$("input[type='checkbox']:checked").each(function (i){
|
||||
checked_ids[i] = parseInt($(this).val());
|
||||
});
|
||||
|
||||
var unchecked_ids = [];
|
||||
$("input[type='checkbox']:not(:checked)").each(function (i){
|
||||
unchecked_ids[i] = parseInt($(this).val());
|
||||
});
|
||||
|
||||
ajax.jsonRpc('/mailing/list/update', 'call', {'opt_in_ids': checked_ids, 'opt_out_ids': unchecked_ids, 'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else if (result == true) {
|
||||
$('#subscription_info').text(_t('Your changes have been saved.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-success');
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Your changes have not been saved, try again later.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-warning');
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Your changes have not been saved, try again later.'));
|
||||
$('#info_state').removeClass('alert-info').addClass('alert-warning');
|
||||
});
|
||||
});
|
||||
|
||||
// ==================
|
||||
// Blacklist
|
||||
// ==================
|
||||
$('#button_add_blacklist').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
ajax.jsonRpc('/mailing/blacklist/add', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result) {
|
||||
$('#subscription_info').html(_t('You have been successfully <strong>added to our blacklist</strong>. '
|
||||
+ 'You will not be contacted anymore by our services.'));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
toggle_opt_out_section(false);
|
||||
|
||||
$('#button_remove_blacklist').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
ajax.jsonRpc('/mailing/blacklist/remove', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
else
|
||||
{
|
||||
if (result) {
|
||||
$('#subscription_info').html(_t("You have been successfully <strong>removed from our blacklist</strong>. "
|
||||
+ "You are now able to be contacted by our services."));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
toggle_opt_out_section(true);
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
}
|
||||
$('#button_add_blacklist').show();
|
||||
$('#button_remove_blacklist').hide();
|
||||
$('#unsubscribed_info').hide();
|
||||
}
|
||||
$('#button_add_blacklist').hide();
|
||||
$('#button_remove_blacklist').show();
|
||||
$('#unsubscribed_info').hide();
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
});
|
||||
});
|
||||
|
||||
$('#button_remove_blacklist').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
ajax.jsonRpc('/mailing/blacklist/remove', 'call', {'email': email, 'mailing_id': mailing_id, 'res_id': res_id, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result) {
|
||||
$('#subscription_info').html(_t("You have been successfully <strong>removed from our blacklist</strong>. "
|
||||
+ "You are now able to be contacted by our services."));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
toggle_opt_out_section(true);
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
}
|
||||
$('#button_add_blacklist').show();
|
||||
$('#button_remove_blacklist').hide();
|
||||
$('#unsubscribed_info').hide();
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
});
|
||||
});
|
||||
|
||||
// ==================
|
||||
// Feedback
|
||||
// ==================
|
||||
$('#button_feedback').click(function (e) {
|
||||
var feedback = $("textarea[name='opt_out_feedback']").val();
|
||||
e.preventDefault();
|
||||
ajax.jsonRpc('/mailing/feedback', 'call', {'mailing_id': mailing_id, 'res_id': res_id, 'email': email, 'feedback': feedback, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else if (result == true){
|
||||
$('#subscription_info').text(_t('Thank you! Your feedback has been sent successfully!'));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
$("#div_feedback").hide();
|
||||
}
|
||||
else {
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-info').removeClass('alert-success').removeClass('alert-error').addClass('alert-warning');
|
||||
});
|
||||
});
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-warning').addClass('alert-error');
|
||||
});
|
||||
});
|
||||
|
||||
// ==================
|
||||
// Feedback
|
||||
// ==================
|
||||
$('#button_feedback').click(function (e) {
|
||||
var feedback = $("textarea[name='opt_out_feedback']").val();
|
||||
e.preventDefault();
|
||||
ajax.jsonRpc('/mailing/feedback', 'call', {'mailing_id': mailing_id, 'res_id': res_id, 'email': email, 'feedback': feedback, 'token': token})
|
||||
.then(function (result) {
|
||||
if (result == 'unauthorized'){
|
||||
$('#subscription_info').text(_t('You are not authorized to do this!'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
else if (result == true){
|
||||
$('#subscription_info').text(_t('Thank you! Your feedback has been sent successfully!'));
|
||||
$('#info_state').removeClass('alert-warning').removeClass('alert-info').removeClass('alert-error').addClass('alert-success');
|
||||
$("#div_feedback").hide();
|
||||
}
|
||||
else {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-success').removeClass('alert-info').removeClass('alert-error').addClass('alert-warning');
|
||||
}
|
||||
})
|
||||
.guardedCatch(function () {
|
||||
$('#subscription_info').text(_t('An error occurred. Please try again later or contact us.'));
|
||||
$('#info_state').removeClass('alert-info').removeClass('alert-success').removeClass('alert-error').addClass('alert-warning');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function toggle_opt_out_section(value) {
|
||||
var result = !value;
|
||||
@@ -193,4 +196,3 @@ function toggle_opt_out_section(value) {
|
||||
if (value) { $('[name="button_subscription"]').addClass('clickable'); }
|
||||
else { $('[name="button_subscription"]').removeClass('clickable'); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,6 @@ This module provides the core of the Odoo Web Client.
|
||||
'web/static/src/legacy/js/core/owl_dialog.js',
|
||||
'web/static/src/legacy/js/core/popover.js',
|
||||
'web/static/src/legacy/js/core/dom.js',
|
||||
'web/static/src/legacy/js/core/dom_ready.js',
|
||||
'web/static/src/legacy/js/core/local_storage.js',
|
||||
'web/static/src/legacy/js/core/mixins.js',
|
||||
'web/static/src/legacy/js/core/qweb.js',
|
||||
@@ -380,7 +379,6 @@ This module provides the core of the Odoo Web Client.
|
||||
'web/static/src/legacy/js/core/owl_dialog.js',
|
||||
'web/static/src/legacy/js/core/popover.js',
|
||||
'web/static/src/legacy/js/core/dom.js',
|
||||
'web/static/src/legacy/js/core/dom_ready.js',
|
||||
'web/static/src/legacy/js/core/local_storage.js',
|
||||
'web/static/src/legacy/js/core/menu.js',
|
||||
'web/static/src/legacy/js/core/mixins.js',
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
/** @odoo-module alias=web.dom_ready **/
|
||||
|
||||
export default new Promise(function (resolve, reject) {
|
||||
$(resolve);
|
||||
});
|
||||
@@ -5,8 +5,6 @@
|
||||
* content too.
|
||||
*/
|
||||
|
||||
import "web.dom_ready";
|
||||
|
||||
// Check the browser and its version and add the info as an attribute of the
|
||||
// HTML element so that css selectors can match it
|
||||
var browser = _.findKey($.browser, function (v) { return v === true; });
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import "web.dom_ready";
|
||||
import {_t} from "web.core";
|
||||
import options from "web_editor.snippets.options";
|
||||
import "website.editor.snippets.options";
|
||||
|
||||
@@ -220,7 +220,6 @@ Featuring
|
||||
'web/static/src/legacy/js/core/owl_dialog.js',
|
||||
'web/static/src/legacy/js/core/popover.js',
|
||||
'web/static/src/legacy/js/core/dom.js',
|
||||
'web/static/src/legacy/js/core/dom_ready.js',
|
||||
'web/static/src/legacy/js/core/local_storage.js',
|
||||
'web/static/src/legacy/js/core/mixins.js',
|
||||
'web/static/src/legacy/js/core/qweb.js',
|
||||
|
||||
Reference in New Issue
Block a user