Commit 236ebbfc by François C.

#4350: Add points data and next ftop service for committee members

parent 20c595bf
Pipeline #2744 passed with stage
in 1 minute 30 seconds
...@@ -87,6 +87,10 @@ body { ...@@ -87,6 +87,10 @@ body {
} }
} }
#comite_my_shifs_message {
min-width: 20em;
}
#home_incoming_services { #home_incoming_services {
min-height: 80px; min-height: 80px;
display: flex; display: flex;
......
...@@ -4,19 +4,36 @@ function init_my_shifts_tile() { ...@@ -4,19 +4,36 @@ 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();
if (partner_data.comite === "True") {
let cpt = 0; let message = $('#comite_my_shifs_message').clone()
message.find('[data-type="nb_of_shifs_state"] [data-type="shifts_nb"]').text(partner_data.final_ftop_point)
if (Math.abs(partner_data.final_ftop_point) > 1) {
message.find('[data-type="nb_of_shifs_state"] [data-type="service_txt"]').text("services")
}
// let's get next ftop shift (incoming_shifts is ordered)
if (incoming_shifts.length > 0) {
const next_shift = incoming_shifts[0]
let ns_date = new Date(next_shift.date_begin)
const date_options = {dateStyle: "short"}
message.find('[data-type="next_ftop_shift_date"]').text(ns_date.toLocaleDateString('fr-FR', date_options))
}
$("#home_tile_my_services .tile_content").html(message)
} else {
$("#home_tile_my_services #home_incoming_services").empty();
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++;
}
} }
} }
} }
......
...@@ -177,40 +177,56 @@ function init_history() { ...@@ -177,40 +177,56 @@ function init_history() {
function init_incoming_shifts() { function init_incoming_shifts() {
$(".loading-incoming-shifts").hide(); $(".loading-incoming-shifts").hide();
$("#incoming_shifts").show(); $("#incoming_shifts").show();
if (partner_data.comite === "True") {
if (incoming_shifts.length === 0) { let message = $('#comite_my_shifs_message').clone()
$("#incoming_shifts").text("Aucun service à venir..."); message.find('[data-type="nb_of_shifs_state"] [data-type="shifts_nb"]').text(partner_data.final_ftop_point)
if (Math.abs(partner_data.final_ftop_point) > 1) {
message.find('[data-type="nb_of_shifs_state"] [data-type="service_txt"]').text("services")
}
// let's get next ftop shift (incoming_shifts is ordered)
if (incoming_shifts.length > 0) {
const next_shift = incoming_shifts[0]
let ns_date = new Date(next_shift.date_begin)
const date_options = {dateStyle: "short"}
message.find('[data-type="next_ftop_shift_date"]').text(ns_date.toLocaleDateString('fr-FR', date_options))
}
$("#incoming_shifts_area").html(message)
} else { } else {
$("#incoming_shifts").empty(); if (incoming_shifts.length === 0) {
$("#incoming_shifts").text("Aucun service à venir...");
} else {
$("#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);
if (partner_data.associated_partner_id != "False") { if (partner_data.associated_partner_id != "False") {
if (shift.associate_registered==="partner") { if (shift.associate_registered==="partner") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+''); shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+'');
} else if (shift.associate_registered==="associate") { } else if (shift.associate_registered==="associate") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.associated_partner_name+''); shift_line_template.find(".shift_line_associate").text(' - '+partner_data.associated_partner_name+'');
} else if (shift.associate_registered==="both") { } else if (shift.associate_registered==="both") {
shift_line_template.find(".shift_line_associate").text(' - Les deux'); shift_line_template.find(".shift_line_associate").text(' - Les deux');
} else { } else {
shift_line_template.find(".shift_line_associate").text('A définir'); shift_line_template.find(".shift_line_associate").text('A définir');
} }
} else if (partner_data.parent_id != "False") { } else if (partner_data.parent_id != "False") {
if (shift.associate_registered==="partner") { if (shift.associate_registered==="partner") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.parent_name+''); shift_line_template.find(".shift_line_associate").text(' - '+partner_data.parent_name+'');
} else if (shift.associate_registered==="associate") { } else if (shift.associate_registered==="associate") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+''); shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+'');
} else if (shift.associate_registered==="both") { } else if (shift.associate_registered==="both") {
shift_line_template.find(".shift_line_associate").text(' - Les deux'); shift_line_template.find(".shift_line_associate").text(' - Les deux');
} else { } else {
shift_line_template.find(".shift_line_associate").text('A définir'); shift_line_template.find(".shift_line_associate").text('A définir');
}
} }
}
$("#incoming_shifts").append(shift_line_template.html()); $("#incoming_shifts").append(shift_line_template.html());
}
} }
} }
} }
function init_my_shifts() { function init_my_shifts() {
......
...@@ -556,7 +556,7 @@ function init_calendar_page() { ...@@ -556,7 +556,7 @@ function init_calendar_page() {
contentHeight: "auto", contentHeight: "auto",
eventDisplay: "block", eventDisplay: "block",
hiddenDays: hidden_days, hiddenDays: hidden_days,
events: '/shifts/get_list_shift_calendar/' + partner_data.concerned_partner_id, events: event_src,
eventClick: function(info) { eventClick: function(info) {
if (!$(info.el).hasClass("shift_booked") && !$(info.el).hasClass("shift_booked_makeup")) { if (!$(info.el).hasClass("shift_booked") && !$(info.el).hasClass("shift_booked_makeup")) {
const new_shift_id = info.event.id; const new_shift_id = info.event.id;
...@@ -656,7 +656,7 @@ function init_calendar_page() { ...@@ -656,7 +656,7 @@ function init_calendar_page() {
calendar.render(); calendar.render();
} }
function init_read_only_calendar_page() { async function init_read_only_calendar_page() {
let template_explanations = $("#calendar_explaination_template"); let template_explanations = $("#calendar_explaination_template");
if (vw <= 992) { if (vw <= 992) {
...@@ -680,8 +680,8 @@ function init_read_only_calendar_page() { ...@@ -680,8 +680,8 @@ function init_read_only_calendar_page() {
if (incoming_shifts !== null) { if (incoming_shifts !== null) {
init_shifts_list(); init_shifts_list();
} else { } else {
load_partner_shifts(partner_data.concerned_partner_id) await load_partner_shifts(partner_data.concerned_partner_id)
.then(init_shifts_list); init_shifts_list();
} }
if (should_select_makeup()) { if (should_select_makeup()) {
...@@ -718,7 +718,16 @@ function init_read_only_calendar_page() { ...@@ -718,7 +718,16 @@ function init_read_only_calendar_page() {
const hidden_days = days_to_hide.length > 0 ? $.map(days_to_hide.split(", "), Number) : []; const hidden_days = days_to_hide.length > 0 ? $.map(days_to_hide.split(", "), Number) : [];
const calendarEl = document.getElementById('read_only_calendar'); const calendarEl = document.getElementById('read_only_calendar');
let event_src = '/shifts/get_list_shift_calendar/' + partner_data.concerned_partner_id;
if (partner_data.comite === "True") {
let next_evts = []
if (incoming_shifts.length > 0) {
incoming_shifts.forEach((s) => {
next_evts.push({id: s.id, title: 'Prélèvement 1 point', allDay: true, start: s.date_begin})
});
}
event_src = next_evts
}
calendar = new FullCalendar.Calendar(calendarEl, { calendar = new FullCalendar.Calendar(calendarEl, {
locale: 'fr', locale: 'fr',
initialView: default_initial_view, initialView: default_initial_view,
...@@ -734,7 +743,7 @@ function init_read_only_calendar_page() { ...@@ -734,7 +743,7 @@ function init_read_only_calendar_page() {
contentHeight: "auto", contentHeight: "auto",
eventDisplay: "block", eventDisplay: "block",
hiddenDays: hidden_days, hiddenDays: hidden_days,
events: '/shifts/get_list_shift_calendar/' + partner_data.concerned_partner_id, events: event_src,
eventDidMount: function() { eventDidMount: function() {
// Calendar is hidden at first on mobile to hide header change when data is loaded // Calendar is hidden at first on mobile to hide header change when data is loaded
$(".loading-calendar").hide(); $(".loading-calendar").hide();
......
...@@ -123,7 +123,6 @@ class CagetteShift(models.Model): ...@@ -123,7 +123,6 @@ class CagetteShift(models.Model):
'street', 'street2', 'zip', 'city', 'mobile', 'phone', 'email', 'street', 'street2', 'zip', 'city', 'mobile', 'phone', 'email',
'is_associated_people', 'parent_id', 'extra_shift_done'] 'is_associated_people', 'parent_id', 'extra_shift_done']
partnerData = self.o_api.search_read('res.partner', cond, fields, 1) partnerData = self.o_api.search_read('res.partner', cond, fields, 1)
if partnerData: if partnerData:
partnerData = partnerData[0] partnerData = partnerData[0]
if partnerData['is_associated_people']: if partnerData['is_associated_people']:
......
...@@ -179,14 +179,11 @@ def get_list_shift_calendar(request, partner_id): ...@@ -179,14 +179,11 @@ def get_list_shift_calendar(request, partner_id):
def get_list_shift_partner(request, partner_id): def get_list_shift_partner(request, partner_id):
cs = CagetteShift() cs = CagetteShift()
shiftData = cs.get_shift_partner(partner_id) shiftData = cs.get_shift_partner(partner_id)
empty_data = False
for value in shiftData: for value in shiftData:
value['date_begin'] = value['date_begin'] + "Z" value['date_begin'] = value['date_begin'] + "Z"
value['date_end'] = value['date_end'] + "Z" value['date_end'] = value['date_end'] + "Z"
if "Services des comités" in value['shift_id'][1]:
empty_data = True
if empty_data is True:
shiftData = []
return JsonResponse(shiftData, safe=False) return JsonResponse(shiftData, safe=False)
def change_shift(request): def change_shift(request):
......
...@@ -101,6 +101,17 @@ ...@@ -101,6 +101,17 @@
<h3>Vous êtes inscrit.e dans le service des comités, vous n'avez pas accès au calendrier d'échange des services car vous vous organisez directement avec le responsable du comité. Si vous avez des rattrapages à réaliser, merci de contacter le responsable du comité qui vous aidera à planifier les rattrapages ou trouver une solution.</h3> <h3>Vous êtes inscrit.e dans le service des comités, vous n'avez pas accès au calendrier d'échange des services car vous vous organisez directement avec le responsable du comité. Si vous avez des rattrapages à réaliser, merci de contacter le responsable du comité qui vous aidera à planifier les rattrapages ou trouver une solution.</h3>
<h3>Le calendrier ci-dessous est en lecture seule</h3> <h3>Le calendrier ci-dessous est en lecture seule</h3>
</div> </div>
<div id="comite_my_shifs_message">
<p data-type="nb_of_shifs_state">
Vous avez actuellement <span data-type="shifts_nb"></span> <span data-type="service_txt">service</span> d'avance.
</p>
<p data-type="next_ftop_shift">
Le système informatique viendra prélever un service sur votre compteur le <span data-type="next_ftop_shift_date"></span>.
</p>
<p>
Veillez à faire au moins 1 service d'ici là !
</p>
</div>
</div> </div>
</div> </div>
...@@ -129,6 +140,8 @@ ...@@ -129,6 +140,8 @@
"partner_id":"{{partnerData.id}}", "partner_id":"{{partnerData.id}}",
"name":"{{partnerData.display_name|safe}}", "name":"{{partnerData.display_name|safe}}",
"shift_type":"{{partnerData.shift_type}}", "shift_type":"{{partnerData.shift_type}}",
"final_ftop_point":{{partnerData.final_ftop_point}},
"final_standard_point":{{partnerData.final_standard_point}},
"date_delay_stop":"{{partnerData.date_delay_stop}}", "date_delay_stop":"{{partnerData.date_delay_stop}}",
"cooperative_state":"{{partnerData.cooperative_state}}", "cooperative_state":"{{partnerData.cooperative_state}}",
"regular_shift_name":"{{partnerData.regular_shift_name}}", "regular_shift_name":"{{partnerData.regular_shift_name}}",
......
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