Commit 186dcc63 by François C.

Add enqueing messages method to display them after page has been reloaded

parent b1c320b6
Pipeline #2020 passed with stage
in 1 minute 27 seconds
......@@ -205,7 +205,7 @@ function delete_pair(childId) {
contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload),
success: function() {
// alert("binôme désolidarisé");
enqueue_message_for_next_loading("Binôme désolidarisé.");
location.reload();
},
error: function(data) {
......@@ -223,9 +223,6 @@ function delete_pair(childId) {
function confirmDeletion(childId) {
var modalContent = $('#confirmModal')
modalContent.find("#parentName").text(parentName)
modalContent.find("#childName").text(childName)
......@@ -234,7 +231,7 @@ function confirmDeletion(childId) {
if (is_time_to('delete_pair')) {
delete_pair(childId)
}
}, 'Valider');
}, 'Valider', false);
}
......@@ -246,7 +243,8 @@ function create_pair(payload) {
contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload),
success: function(data) {
location.reload()
enqueue_message_for_next_loading("Binôme créé.");
location.reload()
},
error: function(data) {
......@@ -384,20 +382,23 @@ $(document).ready(function() {
});
$("#createPair").on('click', function() {
var payload = {
if (parentId && childId) { // Note : after reload, button "Créer le binôme" is clickable...It shouldn't
var payload = {
"parent": {"id": parentId},
"child": {"id": childId}
};
var modalContent = $('#confirmModal')
modalContent.find("#parentName").text(parentName)
modalContent.find("#childName").text(childName)
modalContent = modalContent.html();
openModal(modalContent, () => {
if (is_time_to('create_pair')) {
create_pair(payload)
}
}, 'Valider');
};
var modalContent = $('#confirmModal')
modalContent.find("#parentName").text(parentName)
modalContent.find("#childName").text(childName)
modalContent = modalContent.html();
openModal(modalContent, () => {
if (is_time_to('create_pair')) {
create_pair(payload)
}
}, 'Valider', false);
}
});
if ($("#attached_members_table") != "undefined") {
......@@ -413,7 +414,6 @@ $(document).ready(function() {
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data.member)
parentName = data.member.parent_barcode_base + ' - ' + data.member.parent_name
childName = data.member.barcode_base + ' - ' + data.member.name
confirmDeletion(childId);
......
......@@ -6,7 +6,7 @@
.b_yellow {background: #fcf3cc;}
.red {color:#FF0000;}
.b_red, .b_less_than_25pc {background:#ff3333 !important;}
.loading {background-image: url("/static/img/ajax-loader.gif"); background-repeat:no-repeat;}
.loading {background-image: url("/static/img/ajax-loader.gif"); background-repeat:no-repeat; background-position: center; background-color: #efefef;}
.loading2 {display: none; position:absolute; top:-20px;}
.loading2-container {position:relative;}
......
var actions_last_dates = {};
var show_enqueued_messages = function() {
var stored = null;
try {
stored = JSON.parse(localStorage.getItem('enqueued_messages'));
alert(stored.join("\n"))
localStorage.removeItem('enqueued_messages')
} catch (e) {
//no rescue system for the moment
}
};
var enqueue_message_for_next_loading = function(msg) {
try {
let messages = [],
stored = localStorage.getItem('enqueued_messages');
if (stored) {
messages = JSON.parse(stored);
}
messages.push(msg)
localStorage.setItem('enqueued_messages', JSON.stringify(messages));
} catch (e) {
//no rescue system for the moment
}
}
function get_litteral_shift_template_name(name) {
var l_name = '';
......@@ -209,6 +236,10 @@ function openModal() {
// 4th argument: if set and false, validate button doesn't close the modal
if (typeof (arguments[3]) == "undefined" || arguments[3] != false)
btn_ok.on('click', closeModal);
else
btn_ok.on('click', function() {
$(this).addClass("loading")
})
btns.append(btn_ok);
......@@ -482,3 +513,5 @@ function isMacUser() {
}
if (isMacUser() && isSafari()) $('.mac-msg').show();
show_enqueued_messages();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment