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