Commit 9df74e1f by François

lintjs

parent 0f788280
Pipeline #1293 passed with stage
in 1 minute 27 seconds
...@@ -448,13 +448,14 @@ function record_service_presence() { ...@@ -448,13 +448,14 @@ function record_service_presence() {
var res = rData.res; var res = rData.res;
var next = (res.update == 'ok') var next = (res.update == 'ok')
||(res.rattrapage && !isNaN(res.rattrapage)); ||(res.rattrapage && !isNaN(res.rattrapage));
if (next) { if (next) {
fill_service_entry_sucess(rData.res.member); fill_service_entry_sucess(rData.res.member);
goto_page(pages.service_entry_success); goto_page(pages.service_entry_success);
} else if (rData.res.error) { } else if (rData.res.error) {
alert(rData.res.error); alert(rData.res.error);
} else { } else {
alert("Un problème est survenu. S'il persiste merci de le signaler à un responsable du magasin.") alert("Un problème est survenu. S'il persiste merci de le signaler à un responsable du magasin.");
} }
} }
loading2.hide(); loading2.hide();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
function toggleHeader() { function toggleHeader() {
var x = document.getElementById("topnav"); var x = document.getElementById("topnav");
if (x.className === "topnav") { if (x.className === "topnav") {
x.className += " responsive"; x.className += " responsive";
} else { } else {
......
function init_my_shifts_tile() { function init_my_shifts_tile() {
if (incoming_shifts.length === 0) { if (incoming_shifts.length === 0) {
$("#home_tile_my_services #home_incoming_services").text("Aucun service à venir...") $("#home_tile_my_services #home_incoming_services").text("Aucun service à venir...");
} else { } else {
$("#home_tile_my_services #home_incoming_services").empty(); $("#home_tile_my_services #home_incoming_services").empty();
let cpt = 0; let cpt = 0;
for (shift of incoming_shifts) { for (shift of incoming_shifts) {
if (cpt === 3) { if (cpt === 3) {
break; break;
} else { } else {
let shift_line_template = prepare_shift_line_template(shift.date_begin); let shift_line_template = prepare_shift_line_template(shift.date_begin);
$("#home_tile_my_services #home_incoming_services").append(shift_line_template.html()); $("#home_tile_my_services #home_incoming_services").append(shift_line_template.html());
cpt++; cpt++;
......
...@@ -5,7 +5,7 @@ const history_items_limit = 10; ...@@ -5,7 +5,7 @@ const history_items_limit = 10;
/** /**
* Load the partner points history * Load the partner points history
*/ */
function load_partner_history(offset = 0) { function load_partner_history(offset = 0) {
return new Promise((resolve) => { return new Promise((resolve) => {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
...@@ -52,6 +52,7 @@ function prepare_server_data(data) { ...@@ -52,6 +52,7 @@ function prepare_server_data(data) {
let datetime_shift_start = new Date(history_item.create_date); let datetime_shift_start = new Date(history_item.create_date);
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);
history_item.movement_date = f_date_shift_start + " - " + datetime_shift_start.toLocaleTimeString("fr-fr"); history_item.movement_date = f_date_shift_start + " - " + datetime_shift_start.toLocaleTimeString("fr-fr");
...@@ -90,7 +91,8 @@ function init_history() { ...@@ -90,7 +91,8 @@ function init_history() {
$("#history").show(); $("#history").show();
if (partner_history.length === 0) { if (partner_history.length === 0) {
$("#history").empty().text("Aucun historique... pour l'instant !") $("#history").empty()
.text("Aucun historique... pour l'instant !");
} else { } else {
let viewportWidth = $(window).width(); let viewportWidth = $(window).width();
...@@ -100,7 +102,7 @@ function init_history() { ...@@ -100,7 +102,7 @@ function init_history() {
{ {
data: "movement_date", data: "movement_date",
title: `Date`, title: `Date`,
responsivePriority: 1, responsivePriority: 1
}, },
{ {
data: "created_by", data: "created_by",
...@@ -110,20 +112,20 @@ function init_history() { ...@@ -110,20 +112,20 @@ function init_history() {
}, },
{ {
data: "shift_name", data: "shift_name",
title: "Service", title: "Service"
}, },
{ {
data: "name", data: "name",
title: "Détails", title: "Détails",
responsivePriority: 3, responsivePriority: 3
}, },
{ {
data: "point_qty", data: "point_qty",
title: (viewportWidth <= 768) ? "Mvmt de points" : "Mouvement de points", title: (viewportWidth <= 768) ? "Mvmt de points" : "Mouvement de points",
responsivePriority: 2, responsivePriority: 2,
width: "10%", width: "10%",
className: (viewportWidth <= 768) ? "dt-body-center" : '', className: (viewportWidth <= 768) ? "dt-body-center" : ''
}, }
], ],
iDisplayLength: -1, iDisplayLength: -1,
ordering: false, ordering: false,
...@@ -155,12 +157,13 @@ function init_incoming_shifts() { ...@@ -155,12 +157,13 @@ function init_incoming_shifts() {
$("#incoming_shifts").show(); $("#incoming_shifts").show();
if (incoming_shifts.length === 0) { if (incoming_shifts.length === 0) {
$("#incoming_shifts").text("Aucun service à venir...") $("#incoming_shifts").text("Aucun service à venir...");
} else { } else {
$("#incoming_shifts").empty(); $("#incoming_shifts").empty();
for (shift of incoming_shifts) { for (shift of incoming_shifts) {
let shift_line_template = prepare_shift_line_template(shift.date_begin); let shift_line_template = prepare_shift_line_template(shift.date_begin);
$("#incoming_shifts").append(shift_line_template.html()); $("#incoming_shifts").append(shift_line_template.html());
} }
} }
...@@ -197,7 +200,7 @@ function init_my_shifts() { ...@@ -197,7 +200,7 @@ function init_my_shifts() {
.then((data) => { .then((data) => {
partner_history = partner_history.concat(data); partner_history = partner_history.concat(data);
if (history_table) { if (history_table) {
history_table.rows.add( data ).draw( false ); history_table.rows.add(data).draw(false);
} }
$('.loading-more-history').hide(); $('.loading-more-history').hide();
......
...@@ -51,7 +51,7 @@ function load_partner_shifts(partner_id) { ...@@ -51,7 +51,7 @@ function load_partner_shifts(partner_id) {
* *
* @param {String} page home | mes-infos | mes-services | echange-de-services * @param {String} page home | mes-infos | mes-services | echange-de-services
*/ */
function goto(page) { function goto(page) {
if (window.location.pathname === base_location) { if (window.location.pathname === base_location) {
history.pushState({}, '', page); history.pushState({}, '', page);
} else { } else {
...@@ -68,29 +68,29 @@ function update_dom() { ...@@ -68,29 +68,29 @@ function update_dom() {
if (window.location.pathname === base_location || window.location.pathname === base_location + "home") { if (window.location.pathname === base_location || window.location.pathname === base_location + "home") {
current_location = "home"; current_location = "home";
$( "#main_content" ).load( "/members_space/homepage", update_content ); $("#main_content").load("/members_space/homepage", update_content);
$("#nav_home").addClass("active"); $("#nav_home").addClass("active");
} else if (window.location.pathname === base_location + "mes-infos") { } else if (window.location.pathname === base_location + "mes-infos") {
current_location = "my_info"; current_location = "my_info";
$( "#main_content" ).load( "/members_space/my_info", update_content ); $("#main_content").load("/members_space/my_info", update_content);
$("#nav_my_info").addClass("active"); $("#nav_my_info").addClass("active");
} else if (window.location.pathname === base_location + "mes-services") { } else if (window.location.pathname === base_location + "mes-services") {
current_location = "my_shifts"; current_location = "my_shifts";
$( "#main_content" ).load( "/members_space/my_shifts", update_content ); $("#main_content").load("/members_space/my_shifts", update_content);
$("#nav_my_shifts").addClass("active"); $("#nav_my_shifts").addClass("active");
} else if (window.location.pathname === base_location + "echange-de-services") { } else if (window.location.pathname === base_location + "echange-de-services") {
current_location = "shifts_exchange"; current_location = "shifts_exchange";
$( "#main_content" ).load( "/members_space/shifts_exchange", update_content ); $("#main_content").load("/members_space/shifts_exchange", update_content);
$("#nav_shifts_exchange").addClass("active"); $("#nav_shifts_exchange").addClass("active");
} else { } else {
$( "#main_content" ).load( "/members_space/no_content" ); $("#main_content").load("/members_space/no_content");
} }
} }
/** /**
* Update the data displayed depending on the current location (ex: insert personal data in the DOM when on the 'My Info' page) * Update the data displayed depending on the current location (ex: insert personal data in the DOM when on the 'My Info' page)
*/ */
function update_content() { function update_content() {
switch (current_location) { switch (current_location) {
case 'home': case 'home':
init_home(); init_home();
...@@ -123,6 +123,7 @@ function prepare_shift_line_template(date_begin) { ...@@ -123,6 +123,7 @@ function prepare_shift_line_template(date_begin) {
let datetime_shift_start = new Date(date_begin); let datetime_shift_start = new Date(date_begin);
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);
......
...@@ -42,6 +42,7 @@ function get_shift_name(s_data) { ...@@ -42,6 +42,7 @@ function get_shift_name(s_data) {
shift_name += ' - ' + s_data.place; shift_name += ' - ' + s_data.place;
} }
} }
return shift_name; return shift_name;
} }
......
...@@ -137,7 +137,7 @@ function changeShift(idOldRegister, idNewShift) { ...@@ -137,7 +137,7 @@ function changeShift(idOldRegister, idNewShift) {
closeModal(); closeModal();
if (error.status === 400) { if (error.status === 400) {
alert(`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. Il n'est plus possible de l'échanger.`) alert(`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. Il n'est plus possible de l'échanger.`);
} else { } else {
alert('Une erreur est survenue. Il est néanmoins possible que la requête ait abouti, veuillez patienter quelques secondes puis vérifier vos services enregistrés.'); alert('Une erreur est survenue. Il est néanmoins possible que la requête ait abouti, veuillez patienter quelques secondes puis vérifier vos services enregistrés.');
......
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