Commit ba8cceb1 by Damien Moulard

linting

parent ab49214a
Pipeline #1880 passed with stage
in 1 minute 31 seconds
...@@ -20,7 +20,7 @@ function init_faq() { ...@@ -20,7 +20,7 @@ function init_faq() {
} }
$(document).on('click', "#shift_exchange_btn", () => { $(document).on('click', "#shift_exchange_btn", () => {
goto('echange-de-services'); goto('echange-de-services');
}); });
$(document).on('click', '.accordion', function() { $(document).on('click', '.accordion', function() {
......
...@@ -68,8 +68,7 @@ function prepare_server_data(data) { ...@@ -68,8 +68,7 @@ function prepare_server_data(data) {
if (history_item.associate_registered == false || history_item.associate_registered == undefined) { if (history_item.associate_registered == false || history_item.associate_registered == undefined) {
history_item.associate_registered = ""; history_item.associate_registered = "";
} } else {
else {
if (partner_data.associated_partner_id != "False") { if (partner_data.associated_partner_id != "False") {
if (history_item.associate_registered==="partner") { if (history_item.associate_registered==="partner") {
history_item.associate_registered = partner_data.name; history_item.associate_registered = partner_data.name;
......
...@@ -22,7 +22,7 @@ function can_exchange_shifts() { ...@@ -22,7 +22,7 @@ function can_exchange_shifts() {
* @returns boolean * @returns boolean
*/ */
function should_select_makeup() { function should_select_makeup() {
return partner_data.makeups_to_do > 0 || (partner_data.makeups_to_do > 0 && partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False"); return partner_data.makeups_to_do > 0 || (partner_data.makeups_to_do > 0 && partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False");
} }
/* - Server requests */ /* - Server requests */
...@@ -40,7 +40,7 @@ function add_or_change_shift(new_shift_id) { ...@@ -40,7 +40,7 @@ function add_or_change_shift(new_shift_id) {
+'&idPartner=' + partner_data.partner_id +'&idPartner=' + partner_data.partner_id
+ '&shift_type=' + partner_data.shift_type + '&shift_type=' + partner_data.shift_type
+ '&verif_token=' + partner_data.verif_token; + '&verif_token=' + partner_data.verif_token;
} else if(partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False") { } else if (partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False") {
tData = 'idNewShift=' + new_shift_id tData = 'idNewShift=' + new_shift_id
+'&idPartner=' + partner_data.parent_id +'&idPartner=' + partner_data.parent_id
+ '&shift_type=' + partner_data.shift_type + '&shift_type=' + partner_data.shift_type
...@@ -105,10 +105,10 @@ function add_or_change_shift(new_shift_id) { ...@@ -105,10 +105,10 @@ function add_or_change_shift(new_shift_id) {
`Il est néanmoins possible que la requête ait abouti, ` + `Il est néanmoins possible que la requête ait abouti, ` +
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`); `veuillez patienter quelques secondes puis vérifier vos services enregistrés.`);
// Refectch shifts anyway, if registration/exchange was still succesful // Refectch shifts anyway, if registration/exchange was still succesful
setTimeout(() => { setTimeout(() => {
load_partner_shifts(partner_data.concerned_partner_id) load_partner_shifts(partner_data.concerned_partner_id)
.then(init_shifts_list); .then(init_shifts_list);
}, 300); }, 300);
} }
}, },
...@@ -144,6 +144,8 @@ function add_or_change_shift(new_shift_id) { ...@@ -144,6 +144,8 @@ function add_or_change_shift(new_shift_id) {
} }
}); });
} }
return null;
} }
/** /**
...@@ -153,19 +155,19 @@ function add_or_change_shift(new_shift_id) { ...@@ -153,19 +155,19 @@ function add_or_change_shift(new_shift_id) {
function delete_shift_registration(shift_registration_id) { function delete_shift_registration(shift_registration_id) {
if (is_time_to('delete_shift_registration')) { if (is_time_to('delete_shift_registration')) {
openModal(); openModal();
tData = 'idPartner=' + partner_data.concerned_partner_id tData = 'idPartner=' + partner_data.concerned_partner_id
+ '&idRegister=' + shift_registration_id + '&idRegister=' + shift_registration_id
+ '&extra_shift_done=' + partner_data.extra_shift_done; + '&extra_shift_done=' + partner_data.extra_shift_done;
if (partner_data.is_associated_people === "False") { if (partner_data.is_associated_people === "False") {
tData += '&verif_token=' + partner_data.verif_token; tData += '&verif_token=' + partner_data.verif_token;
} else if(partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False") { } else if (partner_data.is_associated_people === "True" && block_actions_for_attached_people === "False") {
tData += '&verif_token=' + partner_data.parent_verif_token; tData += '&verif_token=' + partner_data.parent_verif_token;
} else { } else {
return false; return false;
} }
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: "/shifts/cancel_shift", url: "/shifts/cancel_shift",
...@@ -174,7 +176,7 @@ function delete_shift_registration(shift_registration_id) { ...@@ -174,7 +176,7 @@ function delete_shift_registration(shift_registration_id) {
timeout: 3000, timeout: 3000,
success: function() { success: function() {
partner_data.extra_shift_done -= 1; partner_data.extra_shift_done -= 1;
// Refetch partner shifts list & update DOM // Refetch partner shifts list & update DOM
load_partner_shifts(partner_data.concerned_partner_id) load_partner_shifts(partner_data.concerned_partner_id)
.then(() => { .then(() => {
...@@ -190,12 +192,12 @@ function delete_shift_registration(shift_registration_id) { ...@@ -190,12 +192,12 @@ function delete_shift_registration(shift_registration_id) {
} }
closeModal(); closeModal();
setTimeout(() => { setTimeout(() => {
alert("La présence a bien été annulée !"); alert("La présence a bien été annulée !");
}, 100); }, 100);
}); });
// Redraw calendar // Redraw calendar
calendar.refetchEvents(); calendar.refetchEvents();
}, },
...@@ -205,6 +207,8 @@ function delete_shift_registration(shift_registration_id) { ...@@ -205,6 +207,8 @@ function delete_shift_registration(shift_registration_id) {
} }
}); });
} }
return null;
} }
/** /**
...@@ -212,15 +216,15 @@ function delete_shift_registration(shift_registration_id) { ...@@ -212,15 +216,15 @@ function delete_shift_registration(shift_registration_id) {
* @param {string} partner * @param {string} partner
* @param {string} shift_id * @param {string} shift_id
*/ */
function affect_shift(partner, shift_id) { function affect_shift(partner, shift_id) {
if (is_time_to('affect_shift')) { if (is_time_to('affect_shift')) {
tData = 'idShiftRegistration=' + shift_id tData = 'idShiftRegistration=' + shift_id
+'&idPartner=' + partner_data.partner_id +'&idPartner=' + partner_data.partner_id
+ '&affected_partner=' + partner + '&affected_partner=' + partner
+ '&verif_token=' + partner_data.verif_token; + '&verif_token=' + partner_data.verif_token;
tUrl = '/shifts/affect_shift'; tUrl = '/shifts/affect_shift';
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: tUrl, url: tUrl,
...@@ -239,7 +243,7 @@ function delete_shift_registration(shift_registration_id) { ...@@ -239,7 +243,7 @@ function delete_shift_registration(shift_registration_id) {
init_shifts_list(); init_shifts_list();
modal.find(".btn-modal-ok").show(); modal.find(".btn-modal-ok").show();
closeModal(); closeModal();
alert(`Une erreur est survenue. ` + alert(`Une erreur est survenue. ` +
`Il est néanmoins possible que la requête ait abouti, ` + `Il est néanmoins possible que la requête ait abouti, ` +
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`); `veuillez patienter quelques secondes puis vérifier vos services enregistrés.`);
...@@ -295,6 +299,7 @@ function init_shifts_list() { ...@@ -295,6 +299,7 @@ function init_shifts_list() {
let datetime_shift_start = new Date(shift.date_begin.replace(/\s/, 'T')); let datetime_shift_start = new Date(shift.date_begin.replace(/\s/, 'T'));
let f_date_shift_start = datetime_shift_start.toLocaleDateString("fr-fr", date_options); let f_date_shift_start = datetime_shift_start.toLocaleDateString("fr-fr", date_options);
f_date_shift_start = f_date_shift_start.charAt(0).toUpperCase() + f_date_shift_start.slice(1); f_date_shift_start = f_date_shift_start.charAt(0).toUpperCase() + f_date_shift_start.slice(1);
shift_line_template.find(".shift_line_date").text(f_date_shift_start); shift_line_template.find(".shift_line_date").text(f_date_shift_start);
...@@ -316,7 +321,8 @@ function init_shifts_list() { ...@@ -316,7 +321,8 @@ function init_shifts_list() {
if (partner_data.associated_partner_id === "False" && partner_data.parent_id === "False") { if (partner_data.associated_partner_id === "False" && partner_data.parent_id === "False") {
shift_line_template.find('.affect_associate_registered').hide(); shift_line_template.find('.affect_associate_registered').hide();
} else { } else {
shift_line_template.find('.affect_associate_registered').closest(".shift_line_container").attr('id', 'shift_id_'+shift.id); shift_line_template.find('.affect_associate_registered').closest(".shift_line_container")
.attr('id', 'shift_id_'+shift.id);
if (shift.associate_registered==="both") { if (shift.associate_registered==="both") {
shift_line_template.find('.affect_associate_registered').text("Les deux"); shift_line_template.find('.affect_associate_registered').text("Les deux");
} else if (shift.associate_registered==="partner") { } else if (shift.associate_registered==="partner") {
...@@ -341,6 +347,7 @@ function init_shifts_list() { ...@@ -341,6 +347,7 @@ function init_shifts_list() {
if (partner_data.extra_shift_done > 0 && shift.is_makeup === false) { if (partner_data.extra_shift_done > 0 && shift.is_makeup === false) {
if (shift_line_template.find(".delete_registration_button").length === 0) { if (shift_line_template.find(".delete_registration_button").length === 0) {
let delete_reg_button_template = $("#delete_registration_button_template"); let delete_reg_button_template = $("#delete_registration_button_template");
shift_line_template.find(".shift_line_container").append(delete_reg_button_template.html()); shift_line_template.find(".shift_line_container").append(delete_reg_button_template.html());
} }
} else { } else {
...@@ -379,7 +386,8 @@ function init_shifts_list() { ...@@ -379,7 +386,8 @@ function init_shifts_list() {
$(".affect_associate_registered").on("click", function() { $(".affect_associate_registered").on("click", function() {
// Display modal // Display modal
let id = $(this).closest(".shift_line_container").attr('id') let id = $(this).closest(".shift_line_container")
.attr('id')
.split('_')[2]; .split('_')[2];
let modal_template = $("#modal_affect_shift"); let modal_template = $("#modal_affect_shift");
...@@ -453,7 +461,7 @@ function init_calendar_page() { ...@@ -453,7 +461,7 @@ function init_calendar_page() {
$(".makeups_nb").text(partner_data.makeups_to_do); $(".makeups_nb").text(partner_data.makeups_to_do);
$("#need_to_select_makeups_message").show(); $("#need_to_select_makeups_message").show();
} }
if (partner_data.extra_shift_done > 0) { if (partner_data.extra_shift_done > 0) {
$(".extra_shift_done").text(partner_data.extra_shift_done); $(".extra_shift_done").text(partner_data.extra_shift_done);
$("#can_delete_future_registrations_area").show(); $("#can_delete_future_registrations_area").show();
...@@ -694,13 +702,17 @@ function init_read_only_calendar_page() { ...@@ -694,13 +702,17 @@ function init_read_only_calendar_page() {
calendar.render(); calendar.render();
} }
function init_delete_registration_buttons() { function init_delete_registration_buttons() {
$(".delete_registration_button").off(); $(".delete_registration_button").off();
$(".delete_registration_button").on("click", function() { $(".delete_registration_button").on("click", function() {
let shift_name = $(this).closest("div").siblings(".selectable_shift_line").text().trim(); let shift_name = $(this).closest("div")
let shift_id = $(this).closest(".shift_line_container").attr('id') .siblings(".selectable_shift_line")
.text()
.trim();
let shift_id = $(this).closest(".shift_line_container")
.attr('id')
.split('_')[2]; .split('_')[2];
openModal( openModal(
`<p>Je m'apprête supprimer ma présence au service du <b>${shift_name}</b></p>`, `<p>Je m'apprête supprimer ma présence au service du <b>${shift_name}</b></p>`,
() => { () => {
......
...@@ -147,7 +147,7 @@ function prepare_shift_line_template(date_begin) { ...@@ -147,7 +147,7 @@ function prepare_shift_line_template(date_begin) {
shift_line_template.find(".shift_line_date").text(f_date_shift_start); shift_line_template.find(".shift_line_date").text(f_date_shift_start);
shift_line_template.find(".shift_line_time").text(datetime_shift_start.toLocaleTimeString("fr-fr", time_options)); shift_line_template.find(".shift_line_time").text(datetime_shift_start.toLocaleTimeString("fr-fr", time_options));
return shift_line_template; return shift_line_template;
} }
...@@ -265,7 +265,7 @@ $(document).ready(function() { ...@@ -265,7 +265,7 @@ $(document).ready(function() {
// debouncing function from John Hann // debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) { var debounce = function (func, threshold, execAsap) {
var timeout; var timeout = null;
return function debounced () { return function debounced () {
var obj = this, args = arguments; var obj = this, args = arguments;
......
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