[IMP] mass_mailing_custom_unsubscribe: black, isort, prettier
This commit is contained in:
parent
2543d73274
commit
8ff3bdb743
@ -1,13 +1,13 @@
|
||||
/* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
odoo.define("mass_mailing_custom_unsubscribe.contact_tour", function(require) {
|
||||
odoo.define("mass_mailing_custom_unsubscribe.contact_tour", function (require) {
|
||||
"use strict";
|
||||
var base = require("web_editor.base");
|
||||
var tour = require("web_tour.tour");
|
||||
|
||||
// Allow to know if an element is required
|
||||
$.extend($.expr[":"], {
|
||||
propRequired: function(element) {
|
||||
propRequired: function (element) {
|
||||
return $(element).prop("required");
|
||||
},
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
/* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||
odoo.define("mass_mailing_custom_unsubscribe.partner_tour", function(require) {
|
||||
odoo.define("mass_mailing_custom_unsubscribe.partner_tour", function (require) {
|
||||
"use strict";
|
||||
var base = require("web_editor.base");
|
||||
var tour = require("web_tour.tour");
|
||||
|
||||
// Allow to know if an element is required
|
||||
$.extend($.expr[":"], {
|
||||
propRequired: function(element) {
|
||||
propRequired: function (element) {
|
||||
return $(element).prop("required");
|
||||
},
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
* to extend it as it is currently designed. It is almost a copy+paste from
|
||||
* upstream, to allow easier version/patch updates, so linter is disabled. */
|
||||
/* eslint-disable */
|
||||
odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function (require) {
|
||||
"use strict";
|
||||
|
||||
var ajax = require("web.ajax");
|
||||
@ -28,7 +28,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
var $radio = $(":radio");
|
||||
var $info_state = $("#info_state, #custom_div_feedback");
|
||||
|
||||
$radio.on("change click", function(e) {
|
||||
$radio.on("change click", function (e) {
|
||||
$details.prop(
|
||||
"required",
|
||||
$(e.target).is("[data-details-required]") && $(e.target).is(":visible")
|
||||
@ -36,9 +36,9 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
});
|
||||
|
||||
// Display reasons form only if there are unsubscriptions
|
||||
var toggle_reasons = function() {
|
||||
var toggle_reasons = function () {
|
||||
// Find contacts that were checked and now are unchecked
|
||||
var $disabled = $mailing_lists.filter(function() {
|
||||
var $disabled = $mailing_lists.filter(function () {
|
||||
var $this = $(this);
|
||||
return !$this.prop("checked") && $this.attr("checked");
|
||||
});
|
||||
@ -61,7 +61,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
}
|
||||
};
|
||||
|
||||
$mailing_lists.change(function(e) {
|
||||
$mailing_lists.change(function (e) {
|
||||
toggle_reasons();
|
||||
$("#info_state").addClass("invisible");
|
||||
});
|
||||
@ -73,7 +73,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
res_id: res_id,
|
||||
token: token,
|
||||
})
|
||||
.then(function(result) {
|
||||
.then(function (result) {
|
||||
if (result == "unauthorized") {
|
||||
$("#button_add_blacklist").hide();
|
||||
$("#button_remove_blacklist").hide();
|
||||
@ -94,7 +94,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
.addClass("alert-error");
|
||||
}
|
||||
})
|
||||
.guardedCatch(function() {
|
||||
.guardedCatch(function () {
|
||||
$("#subscription_info").html(
|
||||
_t("An error occured. Please try again later or contact us.")
|
||||
);
|
||||
@ -122,16 +122,16 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
);
|
||||
}
|
||||
|
||||
$("#unsubscribe_form").on("submit", function(e) {
|
||||
$("#unsubscribe_form").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var checked_ids = [];
|
||||
$("input[type='checkbox']:checked").each(function(i) {
|
||||
$("input[type='checkbox']:checked").each(function (i) {
|
||||
checked_ids[i] = parseInt($(this).val(), 10);
|
||||
});
|
||||
|
||||
var unchecked_ids = [];
|
||||
$("input[type='checkbox']:not(:checked)").each(function(i) {
|
||||
$("input[type='checkbox']:not(:checked)").each(function (i) {
|
||||
unchecked_ids[i] = parseInt($(this).val(), 10);
|
||||
});
|
||||
|
||||
@ -153,7 +153,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
}
|
||||
|
||||
ajax.jsonRpc("/mail/mailing/unsubscribe", "call", values)
|
||||
.then(function(result) {
|
||||
.then(function (result) {
|
||||
if (result == "unauthorized") {
|
||||
$("#info_state").removeClass("invisible");
|
||||
$("#subscription_info").html(
|
||||
@ -169,7 +169,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
$("#subscription_info").html(_t("Your changes have been saved."));
|
||||
$info_state.removeClass("alert-info").addClass("alert-success");
|
||||
// Store checked status, to enable further changes
|
||||
$mailing_lists.each(function() {
|
||||
$mailing_lists.each(function () {
|
||||
var $this = $(this);
|
||||
$this.attr("checked", $this.prop("checked"));
|
||||
});
|
||||
@ -184,7 +184,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
$info_state.removeClass("alert-info").addClass("alert-warning");
|
||||
}
|
||||
})
|
||||
.guardedCatch(function() {
|
||||
.guardedCatch(function () {
|
||||
$("#info_state").removeClass("invisible");
|
||||
$("#subscription_info").html(
|
||||
_t(
|
||||
@ -198,7 +198,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
// ==================
|
||||
// Blacklist
|
||||
// ==================
|
||||
$("#button_add_blacklist").click(function(e) {
|
||||
$("#button_add_blacklist").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if ($reasons.is(":hidden")) {
|
||||
@ -217,7 +217,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
reason_id: parseInt($reasons.find("[name='reason_id']:checked").val(), 10),
|
||||
details: $details.val(),
|
||||
})
|
||||
.then(function(result) {
|
||||
.then(function (result) {
|
||||
if (result == "unauthorized") {
|
||||
$("#info_state").removeClass("invisible");
|
||||
$("#subscription_info").html(
|
||||
@ -244,7 +244,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
.addClass("alert-success");
|
||||
toggle_opt_out_section(false);
|
||||
// set mailing lists checkboxes to previous state
|
||||
$mailing_lists.each(function() {
|
||||
$mailing_lists.each(function () {
|
||||
var $this = $(this);
|
||||
$this.prop("checked", $(this)[0].hasAttribute("checked"));
|
||||
});
|
||||
@ -272,7 +272,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
$("#unsubscribed_info").hide();
|
||||
}
|
||||
})
|
||||
.guardedCatch(function() {
|
||||
.guardedCatch(function () {
|
||||
$("#subscription_info").html(
|
||||
_t("An error occured. Please try again later or contact us.")
|
||||
);
|
||||
@ -284,7 +284,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#button_remove_blacklist").click(function(e) {
|
||||
$("#button_remove_blacklist").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
ajax.jsonRpc("/mailing/blacklist/remove", "call", {
|
||||
@ -293,7 +293,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
res_id: res_id,
|
||||
token: token,
|
||||
})
|
||||
.then(function(result) {
|
||||
.then(function (result) {
|
||||
if (result == "unauthorized") {
|
||||
$("#info_state").removeClass("invisible");
|
||||
$("#subscription_info").html(
|
||||
@ -337,7 +337,7 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
$("#unsubscribed_info").hide();
|
||||
}
|
||||
})
|
||||
.guardedCatch(function() {
|
||||
.guardedCatch(function () {
|
||||
$("#info_state").removeClass("invisible");
|
||||
$("#subscription_info").html(
|
||||
_t("An error occured. Please try again later or contact us.")
|
||||
@ -353,14 +353,10 @@ odoo.define("mass_mailing_custom_unsubscribe.unsubscribe", function(require) {
|
||||
|
||||
function toggle_opt_out_section(value) {
|
||||
var result = !value;
|
||||
$("#div_opt_out")
|
||||
.find("*")
|
||||
.attr("disabled", result);
|
||||
$("#div_opt_out").find("*").attr("disabled", result);
|
||||
$("#button_add_blacklist").attr("disabled", false);
|
||||
$("#button_remove_blacklist").attr("disabled", false);
|
||||
$("#custom_div_feedback")
|
||||
.find("*")
|
||||
.attr("disabled", false);
|
||||
$("#custom_div_feedback").find("*").attr("disabled", false);
|
||||
if (value) {
|
||||
$('[name="button_subscription"]').addClass("clickable");
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user