diff --git a/db/changes/10070-coffee/01-calendar_state.sql b/db/changes/10070-coffee/01-calendar_state.sql new file mode 100644 index 000000000..93960a41f --- /dev/null +++ b/db/changes/10070-coffee/01-calendar_state.sql @@ -0,0 +1,5 @@ +ALTER TABLE `postgresql`.`calendar_state` + ADD COLUMN `code` VARCHAR(45) NULL AFTER `permissionRate`; + +UPDATE `postgresql`.`calendar_state` SET `code` = 'holiday' WHERE `calendar_state_id` = 1; +UPDATE `postgresql`.`calendar_state` SET `code` = 'halfHoliday' WHERE `calendar_state_id` = 6; diff --git a/db/changes/10070-coffee/02-absenceType.sql b/db/changes/10070-coffee/02-absenceType.sql new file mode 100644 index 000000000..f91e2b5df --- /dev/null +++ b/db/changes/10070-coffee/02-absenceType.sql @@ -0,0 +1,12 @@ +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`absenceType` AS + SELECT + `cs`.`calendar_state_id` AS `id`, + `cs`.`type` AS `name`, + `cs`.`rgb` AS `rgb`, + `cs`.`code` AS `code` + FROM + `postgresql`.`calendar_state` `cs`; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 90834cf97..3fecb432e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1514,10 +1514,11 @@ INSERT INTO `vn2008`.`workcenter_holiday` (`workcenter_id`, `day`, `year`) ('1', '24.5', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))), ('5', '23', YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR))); -INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`) +INSERT INTO `postgresql`.`calendar_state` (`calendar_state_id`, `type`, `rgb`, `code`) VALUES - ('1', 'Holidays', '#FF4444'), - ('2', 'Leave of absence', '#C71585'); + (1, 'Holidays', '#FF4444', 'holiday'), + (2, 'Leave of absence', '#C71585', 'absence'), + (6, 'Half holiday', '#E65F00', 'halfHoliday'); INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) VALUES diff --git a/front/core/components/calendar/index.html b/front/core/components/calendar/index.html index 189e9b4eb..ec2ad820d 100644 --- a/front/core/components/calendar/index.html +++ b/front/core/components/calendar/index.html @@ -60,8 +60,8 @@ ng-class="{'primary': day.events.length > 0}">
{{::day.dated | date: 'd'}}
diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index 5289d1d8d..372ed280d 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -190,8 +190,7 @@ export default class Calendar extends Component { return event.dated >= dated && event.dated <= dated; }); - const params = {dated, events}; - + const params = {dated: dated, events: events, style: {}}; const isSaturday = dated.getDay() === 6; const isSunday = dated.getDay() === 0; const isCurrentMonth = dated.getMonth() === this.currentMonth.getMonth(); @@ -203,8 +202,17 @@ export default class Calendar extends Component { if (isCurrentMonth && isSaturday && !hasEvents) params.style = {color: '#666666'}; - if (!isCurrentMonth && !hasEvents) - params.style = {color: '#9b9b9b'}; + if (!isCurrentMonth) + params.style = {opacity: '0.5'}; + + if (events.length > 0) { + const eventStyle = events[0].style; + const eventName = events[0].description || events[0].name; + if (eventStyle) + Object.assign(params.style, eventStyle); + if (eventName) + params.eventName = eventName; + } this.days.push(params); } @@ -310,6 +318,7 @@ export default class Calendar extends Component { return { 'background-color': style.backgroundColor, 'font-weight': style.fontWeight, + 'opacity': style.opacity, 'color': style.color }; } diff --git a/modules/worker/back/methods/worker-calendar/absences.js b/modules/worker/back/methods/worker-calendar/absences.js index 72e75f227..e822291b7 100644 --- a/modules/worker/back/methods/worker-calendar/absences.js +++ b/modules/worker/back/methods/worker-calendar/absences.js @@ -57,8 +57,13 @@ module.exports = Self => { }); absences.forEach(absence => { - if (absence.absenceType().id === 1) - calendar.holidaysEnjoyed++; + const isHoliday = absence.absenceType().code === 'holiday'; + const isHalfHoliday = absence.absenceType().code === 'halfHoliday'; + + if (isHoliday) + calendar.holidaysEnjoyed += 1; + if (isHalfHoliday) + calendar.holidaysEnjoyed += 0.5; absence.dated = new Date(absence.dated); absence.dated.setHours(0, 0, 0, 0); diff --git a/modules/worker/back/models/absence-type.json b/modules/worker/back/models/absence-type.json index 578a7b21a..a2fc2469d 100644 --- a/modules/worker/back/models/absence-type.json +++ b/modules/worker/back/models/absence-type.json @@ -16,6 +16,9 @@ }, "rgb": { "type": "String" + }, + "code": { + "type": "String" } }, "acls": [ diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 9427ca9e8..da43bde55 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -3,7 +3,7 @@ data="$ctrl.absenceTypes" auto-load="true">
- +