2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sgCalendarDayBlock - An event block to be displayed in a week
|
2015-11-06 21:12:24 +01:00
|
|
|
* @memberof SOGo.SchedulerUI
|
2015-05-06 04:06:13 +02:00
|
|
|
* @restrict element
|
|
|
|
* @param {object} sgBlock - the event block definition
|
2015-07-29 02:45:46 +02:00
|
|
|
* @param {function} sgClick - the function to call when clicking on a block.
|
|
|
|
* Two variables are available: clickEvent (the event that triggered the mouse click),
|
|
|
|
* and clickComponent (a Component object)
|
|
|
|
*
|
2015-05-06 04:06:13 +02:00
|
|
|
* @example:
|
|
|
|
|
|
|
|
<sg-calendar-day-block
|
2015-07-29 02:45:46 +02:00
|
|
|
ng-repeat="block in blocks[day]"
|
|
|
|
sg-block="block"
|
|
|
|
sg-click="open(clickEvent, clickComponent)" />
|
2015-05-06 04:06:13 +02:00
|
|
|
*/
|
2019-03-15 21:57:16 +01:00
|
|
|
sgCalendarDayBlock.$inject = ['Calendar'];
|
|
|
|
function sgCalendarDayBlock(Calendar) {
|
2015-05-06 04:06:13 +02:00
|
|
|
return {
|
|
|
|
restrict: 'E',
|
|
|
|
scope: {
|
2015-07-29 02:45:46 +02:00
|
|
|
block: '=sgBlock',
|
|
|
|
clickBlock: '&sgClick'
|
2015-05-06 04:06:13 +02:00
|
|
|
},
|
|
|
|
replace: true,
|
2016-04-22 16:50:19 +02:00
|
|
|
template: template,
|
|
|
|
link: link
|
|
|
|
};
|
|
|
|
|
|
|
|
function template(tElem, tAttrs) {
|
|
|
|
var p = _.has(tAttrs, 'sgCalendarGhost')? '' : '::';
|
|
|
|
|
|
|
|
return [
|
2015-11-20 19:30:26 +01:00
|
|
|
'<div class="sg-event"',
|
2015-11-06 21:12:24 +01:00
|
|
|
// Add a class while dragging
|
|
|
|
' ng-class="{\'sg-event--dragging\': block.dragging}">',
|
2015-11-20 19:30:26 +01:00
|
|
|
' <div class="eventInside"',
|
|
|
|
' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">',
|
2015-11-14 20:29:21 +01:00
|
|
|
// Categories color stripes
|
2016-04-22 16:50:19 +02:00
|
|
|
' <div class="sg-category" ng-repeat="category in '+p+'block.component.categories"',
|
2016-09-21 21:08:10 +02:00
|
|
|
' ng-class="'+p+'(\'bg-category\' + category)"',
|
2021-04-21 20:12:14 +02:00
|
|
|
' ng-style="'+p+'{ right: ($index * 10) + \'%\' }"></div>',
|
2016-04-21 23:02:07 +02:00
|
|
|
' <div class="text">',
|
2016-04-22 16:50:19 +02:00
|
|
|
// Priority
|
|
|
|
' <span ng-show="'+p+'block.component.c_priority" class="sg-priority">{{'+p+'block.component.c_priority}}</span>',
|
|
|
|
// Summary
|
|
|
|
' {{ '+p+'block.component.summary }}',
|
2019-03-27 14:48:00 +01:00
|
|
|
// Icons
|
2021-04-21 20:12:14 +02:00
|
|
|
' <span class="sg-icons">',
|
2015-11-13 16:48:27 +01:00
|
|
|
// Component is reccurent
|
2019-07-05 22:35:20 +02:00
|
|
|
' <md-icon ng-if="'+p+'block.component.occurrenceId">repeat</md-icon>',
|
2015-11-06 21:12:24 +01:00
|
|
|
// Component has an alarm
|
2019-07-05 22:35:20 +02:00
|
|
|
' <md-icon ng-if="'+p+'block.component.c_nextalarm">alarm</md-icon>',
|
2015-11-06 21:12:24 +01:00
|
|
|
// Component is confidential
|
2019-07-05 22:35:20 +02:00
|
|
|
' <md-icon ng-if="'+p+'block.component.c_classification == 2">visibility_off</md-icon>',
|
2015-11-06 21:12:24 +01:00
|
|
|
// Component is private
|
2019-07-05 22:35:20 +02:00
|
|
|
' <md-icon ng-if="'+p+'block.component.c_classification == 1">vpn_key</md-icon>',
|
2015-11-06 21:12:24 +01:00
|
|
|
' </span>',
|
2015-11-14 20:29:21 +01:00
|
|
|
// Location
|
2016-04-22 16:50:19 +02:00
|
|
|
' <div class="secondary" ng-if="'+p+'block.component.c_location">',
|
2017-10-16 16:26:08 +02:00
|
|
|
' <md-icon>place</md-icon> <span ng-bind="'+p+'block.component.c_location"></span>',
|
2015-11-14 20:29:21 +01:00
|
|
|
' </div>',
|
2019-03-27 14:48:00 +01:00
|
|
|
// Calendar name
|
|
|
|
' <div class="secondary md-truncate" ng-if="'+p+'showCalendarName"',
|
|
|
|
' ng-bind="'+p+'block.component.calendarName"></div>',
|
2015-05-06 04:06:13 +02:00
|
|
|
' </div>',
|
2015-11-06 21:12:24 +01:00
|
|
|
' </div>',
|
2016-01-22 02:46:04 +01:00
|
|
|
' <div class="ghostStartHour" ng-if="block.startHour">{{ block.startHour }}</div>',
|
|
|
|
' <div class="ghostEndHour" ng-if="block.endHour">{{ block.endHour }}</div>',
|
2015-05-06 04:06:13 +02:00
|
|
|
'</div>'
|
2016-04-22 16:50:19 +02:00
|
|
|
].join('');
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
|
|
|
|
function link(scope, iElement, attrs) {
|
2015-11-06 21:12:24 +01:00
|
|
|
var pc, left, right;
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2019-03-15 21:57:16 +01:00
|
|
|
|
2016-04-22 16:50:19 +02:00
|
|
|
if (!_.has(attrs, 'sgCalendarGhost')) {
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2018-02-06 20:13:40 +01:00
|
|
|
// Compute position
|
2020-05-08 15:51:55 +02:00
|
|
|
// Add right margin (10%) for easier creation of events by mouse dragging
|
|
|
|
pc = 90 / scope.block.siblings;
|
2016-04-22 16:50:19 +02:00
|
|
|
left = scope.block.position * pc;
|
|
|
|
right = 100 - (scope.block.position + 1) * pc;
|
2015-09-19 03:08:01 +02:00
|
|
|
|
2016-04-22 16:50:19 +02:00
|
|
|
// Set position
|
|
|
|
iElement.css('left', left + '%');
|
|
|
|
iElement.css('right', right + '%');
|
|
|
|
if (!scope.block.component || !scope.block.component.c_isallday) {
|
|
|
|
iElement.addClass('starts' + scope.block.start);
|
|
|
|
iElement.addClass('lasts' + scope.block.length);
|
|
|
|
}
|
2015-11-06 21:12:24 +01:00
|
|
|
|
2016-04-22 16:50:19 +02:00
|
|
|
// Add class for user's participation state
|
|
|
|
if (scope.block.userState)
|
|
|
|
iElement.addClass('sg-event--' + scope.block.userState);
|
|
|
|
|
|
|
|
if (scope.block.component) {
|
2019-03-15 21:57:16 +01:00
|
|
|
// Show calendar name for subscriptions only
|
|
|
|
scope.showCalendarName = Calendar.activeUser.login !== scope.block.component.c_owner;
|
|
|
|
|
2016-04-22 18:22:02 +02:00
|
|
|
// Set background color
|
2016-04-22 16:50:19 +02:00
|
|
|
iElement.addClass('bg-folder' + scope.block.component.pid);
|
|
|
|
iElement.addClass('contrast-bdr-folder' + scope.block.component.pid);
|
2016-04-22 18:22:02 +02:00
|
|
|
|
|
|
|
// Add class for transparency
|
|
|
|
if (scope.block.component.c_isopaque === 0)
|
|
|
|
iElement.addClass('sg-event--transparent');
|
2016-07-05 15:08:51 +02:00
|
|
|
|
|
|
|
// Add class for cancelled event
|
|
|
|
if (scope.block.component.c_status === 0)
|
|
|
|
iElement.addClass('sg-event--cancelled');
|
2016-04-22 16:50:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('SOGo.SchedulerUI')
|
|
|
|
.directive('sgCalendarDayBlock', sgCalendarDayBlock);
|
|
|
|
})();
|