Commit 00efdbef by François C.

#7591 : calendar bugs

parent e65cfd55
Pipeline #4104 failed with stage
...@@ -267,19 +267,19 @@ function draw_shift_templates(params) { ...@@ -267,19 +267,19 @@ function draw_shift_templates(params) {
if (type == 2) { if (type == 2) {
//Shift templates are gathered (places and weeks) //Shift templates are gathered (places and weeks)
//a profile is defined (useful for assigning it a color) //a profile is defined (useful for assigning it a color)
profile = 'more_than_50pc'; /*profile = 'more_than_50pc';
if (e.data.reserved / e.data.max <= .25) { if (e.data.reserved / e.data.max <= .25) {
profile = 'less_than_25pc'; profile = 'less_than_25pc';
} else if (e.data.reserved / e.data.max <= .5) { } else if (e.data.reserved / e.data.max <= .5) {
profile = 'less_than_50pc'; profile = 'less_than_50pc';
} }*/
//Compile data for each box, including profil //Compile data for each box, including profil
if (typeof boxes[e.data.day+'_'+e.data.begin] == "undefined") { if (typeof boxes[e.data.day+'_'+e.data.begin] == "undefined") {
boxes[e.data.day+'_'+e.data.begin] = {'reserved': e.data.reserved, 'max':e.data.max, 'profil': profile}; boxes[e.data.day+'_'+e.data.begin] = {'reserved': e.data.reserved, 'max':e.data.max};
} else { } else {
boxes[e.data.day+'_'+e.data.begin]['reserved'] +=e.data.reserved; boxes[e.data.day+'_'+e.data.begin]['reserved'] +=e.data.reserved;
boxes[e.data.day+'_'+e.data.begin]['max'] +=e.data.max; boxes[e.data.day+'_'+e.data.begin]['max'] +=e.data.max;
var existing_profil = boxes[e.data.day+'_'+e.data.begin]['profil']; /* var existing_profil = boxes[e.data.day+'_'+e.data.begin]['profil'];
if (existing_profil == 'more_than_50pc' && profile != 'more_than_50pc') { if (existing_profil == 'more_than_50pc' && profile != 'more_than_50pc') {
boxes[e.data.day+'_'+e.data.begin]['profil'] = profile; boxes[e.data.day+'_'+e.data.begin]['profil'] = profile;
...@@ -287,6 +287,7 @@ function draw_shift_templates(params) { ...@@ -287,6 +287,7 @@ function draw_shift_templates(params) {
if (existing_profil == 'less_than_50pc' && profile == 'less_than_25pc') { if (existing_profil == 'less_than_50pc' && profile == 'less_than_25pc') {
boxes[e.data.day+'_'+e.data.begin]['profil'] = profile; boxes[e.data.day+'_'+e.data.begin]['profil'] = profile;
} }
*/
} }
} }
} }
...@@ -311,10 +312,16 @@ function draw_shift_templates(params) { ...@@ -311,10 +312,16 @@ function draw_shift_templates(params) {
if (target.length > 0) { if (target.length > 0) {
max += boxes[k].max; max += boxes[k].max;
dispo += (boxes[k].max - boxes[k].reserved); dispo += (boxes[k].max - boxes[k].reserved);
let profile = 'more_than_50pc';
if (boxes[k].reserved / boxes[k].max <= .25) {
profile = 'less_than_25pc';
} else if (boxes[k].reserved / boxes[k].max <= .5) {
profile = 'less_than_50pc';
}
var box = $('<div/>').attr('data-type', 'compact'); var box = $('<div/>').attr('data-type', 'compact');
box.addClass('shift'); box.addClass('shift');
box.addClass('b_'+boxes[k].profil); box.addClass('b_'+profile);
if (boxes[k].max <=boxes[k].reserved) { if (boxes[k].max <=boxes[k].reserved) {
box.addClass('full'); box.addClass('full');
} }
...@@ -396,13 +403,15 @@ function retrieve_and_draw_shift_tempates(params) { ...@@ -396,13 +403,15 @@ function retrieve_and_draw_shift_tempates(params) {
function filter_weeks(params) { function filter_weeks(params) {
var clicked = $(this); var clicked = $(this);
if (typeof params.triggered_by !== "undefined") {
clicked = $(params.triggered_by.target);
}
var week_types = $('#week_types'); var week_types = $('#week_types');
var parent_div = clicked.closest('div'); var parent_div = clicked.closest('div');
var w1 = week_types.find('#dw1'); var w1 = week_types.find('#dw1');
var w2 = week_types.find('#dw2'); var w2 = week_types.find('#dw2');
var w3 = week_types.find('#dw3'); var w3 = week_types.find('#dw3');
var w4 = week_types.find('#dw4'); var w4 = week_types.find('#dw4');
if (parent_div.hasClass('oddeven_selector')) { if (parent_div.hasClass('oddeven_selector')) {
// Paires ou impaires has been clicked // Paires ou impaires has been clicked
if (clicked.is(':checked')) { if (clicked.is(':checked')) {
...@@ -462,6 +471,6 @@ function shift_loc_selection() { ...@@ -462,6 +471,6 @@ function shift_loc_selection() {
st_loc_buttons.click(shift_loc_selection); st_loc_buttons.click(shift_loc_selection);
week_types.find('input').change(() => { week_types.find('input').change((elt) => {
filter_weeks({shift_listener: true}); filter_weeks({shift_listener: true, triggered_by: elt});
}); });
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