From 908c29d67c5a6cd3392d56f5f33ddb476cf58b6d Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 21 Sep 2016 15:04:09 -0400 Subject: [PATCH] (js) Improve display of dragging ghost in Calendar --- UI/Scheduler/NSArray+Scheduler.h | 33 ++++++------ UI/Scheduler/UIxCalListingActions.m | 52 ++++++++++++------- .../js/Scheduler/Component.service.js | 1 + .../js/Scheduler/sgCalendarGhost.directive.js | 11 ++-- .../sgCalendarMonthEvent.directive.js | 2 +- 5 files changed, 60 insertions(+), 39 deletions(-) diff --git a/UI/Scheduler/NSArray+Scheduler.h b/UI/Scheduler/NSArray+Scheduler.h index 12c05e586..c96045435 100644 --- a/UI/Scheduler/NSArray+Scheduler.h +++ b/UI/Scheduler/NSArray+Scheduler.h @@ -30,22 +30,23 @@ #define eventIsOpaqueIndex 4 #define eventTitleIndex 5 #define eventStartDateIndex 6 -#define eventEndDateIndex 7 -#define eventLocationIndex 8 -#define eventIsAllDayIndex 9 -#define eventClassificationIndex 10 -#define eventCategoryIndex 11 -#define eventPriorityIndex 12 -#define eventPartMailsIndex 13 -#define eventPartStatesIndex 14 -#define eventOwnerIndex 15 -#define eventIsCycleIndex 16 -#define eventNextAlarmIndex 17 -#define eventRecurrenceIdIndex 18 -#define eventIsExceptionIndex 19 -#define eventEditableIndex 20 -#define eventErasableIndex 21 -#define eventOwnerIsOrganizerIndex 22 +#define eventStartHourIndex 7 +#define eventEndDateIndex 8 +#define eventLocationIndex 9 +#define eventIsAllDayIndex 10 +#define eventClassificationIndex 11 +#define eventCategoryIndex 12 +#define eventPriorityIndex 13 +#define eventPartMailsIndex 14 +#define eventPartStatesIndex 15 +#define eventOwnerIndex 16 +#define eventIsCycleIndex 17 +#define eventNextAlarmIndex 18 +#define eventRecurrenceIdIndex 19 +#define eventIsExceptionIndex 20 +#define eventEditableIndex 21 +#define eventErasableIndex 22 +#define eventOwnerIsOrganizerIndex 23 // See [UIxCalListingActions initialize] #define taskNameIndex 0 diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index 96b715057..d646674a3 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -77,7 +77,7 @@ static NSArray *tasksFields = nil; { eventsFields = [NSArray arrayWithObjects: @"c_name", @"c_folder", @"calendarName", - @"c_status", @"c_isopaque", @"c_title", @"c_startdate", + @"c_status", @"c_isopaque", @"c_title", @"c_startdate", @"startHour", @"c_enddate", @"c_location", @"c_isallday", @"c_classification", @"c_category", @"c_priority", @"c_partmails", @"c_partstates", @"c_owner", @@ -541,6 +541,9 @@ static NSArray *tasksFields = nil; [newInfo setObject: [NSString stringWithFormat: @"occurence%@", recurrenceTime] forKey: @"c_recurrence_id"]; + // Add the formatted starting hour + [self _addStartHour: newInfo]; + // Possible improvement: only call _fixDates if event is recurrent // or the view range span a daylight saving time change [self _fixDates: newInfo]; @@ -866,19 +869,32 @@ static inline void _feedBlockWithDayBasedData (NSMutableDictionary *block, unsig forKey: @"length"]; } -static inline void _feedBlockWithMonthBasedData (NSMutableDictionary *block, unsigned int start, - NSTimeZone *userTimeZone, - SOGoDateFormatter *dateFormatter) +// static inline void _feedBlockWithMonthBasedData (NSMutableDictionary *block, unsigned int start, +// NSTimeZone *userTimeZone, +// SOGoDateFormatter *dateFormatter) +// { +// NSCalendarDate *eventStartDate; +// NSString *startHour; + +// eventStartDate = [NSCalendarDate dateWithTimeIntervalSince1970: start]; +// [eventStartDate setTimeZone: userTimeZone]; +// startHour = [dateFormatter formattedTime: eventStartDate]; +// [block setObject: startHour forKey: @"starthour"]; +// [block setObject: [NSNumber numberWithUnsignedInt: start] +// forKey: @"start"]; +// } + +- (void) _addStartHour: (NSMutableDictionary *) theRecord { NSCalendarDate *eventStartDate; NSString *startHour; - - eventStartDate = [NSCalendarDate dateWithTimeIntervalSince1970: start]; - [eventStartDate setTimeZone: userTimeZone]; - startHour = [dateFormatter formattedTime: eventStartDate]; - [block setObject: startHour forKey: @"starthour"]; - [block setObject: [NSNumber numberWithUnsignedInt: start] - forKey: @"start"]; + + eventStartDate = [theRecord objectForKey: @"startDate"]; + if (eventStartDate) + { + startHour = [dateFormatter formattedTime: eventStartDate]; + [theRecord setObject: startHour forKey: @"startHour"]; + } } - (NSMutableDictionary *) _eventBlockWithStart: (unsigned int) start @@ -894,8 +910,8 @@ static inline void _feedBlockWithMonthBasedData (NSMutableDictionary *block, uns if (dayBasedView) _feedBlockWithDayBasedData (block, start, end, dayStart); - else - _feedBlockWithMonthBasedData (block, start, userTimeZone, dateFormatter); + // else + // _feedBlockWithMonthBasedData (block, start, userTimeZone, dateFormatter); [block setObject: number forKey: @"nbr"]; if (recurrenceTime) [block setObject: [NSNumber numberWithInt: recurrenceTime] @@ -1312,11 +1328,11 @@ _computeBlocksPosition (NSArray *blocks) * @apiSuccess (Success 200) {Number} events.ownerIsOrganizer 1 if owner is also the organizer * @apiSuccess (Success 200) {Object[]} blocks * @apiSuccess (Success 200) {Number} blocks.nbr - * @apiSuccess (Success 200) {Number} blocks.start - * @apiSuccess (Success 200) {Number} blocks.position - * @apiSuccess (Success 200) {Number} blocks.length - * @apiSuccess (Success 200) {Number} blocks.siblings - * @apiSuccess (Success 200) {Number} blocks.realSiblings + * @apiSuccess (Success 200) {Number} [blocks.start] Day-based views only + * @apiSuccess (Success 200) {Number} [blocks.position] Day-based views only + * @apiSuccess (Success 200) {Number} [blocks.length] Day-based views only + * @apiSuccess (Success 200) {Number} [blocks.siblings] Day-based views only + * @apiSuccess (Success 200) {Number} [blocks.realSiblings] Day-based views only * @apiSuccess (Success 200) {Object[]} allDayBlocks * @apiSuccess (Success 200) {Number} allDayBlocks.nbr * @apiSuccess (Success 200) {Number} allDayBlocks.start diff --git a/UI/WebServerResources/js/Scheduler/Component.service.js b/UI/WebServerResources/js/Scheduler/Component.service.js index 2557ebf3f..2c0a3a9b9 100644 --- a/UI/WebServerResources/js/Scheduler/Component.service.js +++ b/UI/WebServerResources/js/Scheduler/Component.service.js @@ -325,6 +325,7 @@ associateComponent = function(block) { this[block.nbr].blocks.push(block); // Associate block to component block.component = this[block.nbr]; // Associate component to block + block.isFirst = (this[block.nbr].blocks.length == 1); }; Component.$views = []; diff --git a/UI/WebServerResources/js/Scheduler/sgCalendarGhost.directive.js b/UI/WebServerResources/js/Scheduler/sgCalendarGhost.directive.js index 58bf09cf0..180408d40 100644 --- a/UI/WebServerResources/js/Scheduler/sgCalendarGhost.directive.js +++ b/UI/WebServerResources/js/Scheduler/sgCalendarGhost.directive.js @@ -83,7 +83,7 @@ function updateGhost() { // From SOGoEventDragGhostController._updateGhosts - var showGhost, isRelative, currentDay, + var showGhost, isRelative, isAllDay, currentDay, start, duration, durationLeft, maxDuration; showGhost = false; @@ -92,6 +92,7 @@ // The view of the dragging block is the scrolling view of this ghost block isRelative = scrollViewCtrl.type === 'multiday-allday'; + isAllDay = scope.block.component.c_isallday; currentDay = scope.block.pointerHandler.currentEventCoordinates.dayNumber; start = scope.block.pointerHandler.currentEventCoordinates.start; durationLeft = scope.block.pointerHandler.currentEventCoordinates.duration; @@ -114,8 +115,9 @@ // This ghost block (day) is the first of the dragging event showGhost = true; if (!isRelative) { - // Show start hour and set the vertical position - scope.block.startHour = getStartTime(start); + if (!isAllDay) + // Show start hour and set the vertical position + scope.block.startHour = getStartTime(start); // Set the height if (Calendar.$view.quarterHeight) { iElement.css('top', (start * Calendar.$view.quarterHeight) + 'px'); @@ -127,6 +129,7 @@ iElement.removeClass('fg-folder' + scope.block.component.pid); iElement.removeClass('sg-event--ghost--last'); iElement.addClass('sg-event--ghost--first'); + scope.block.isFirst = true; } durationLeft -= duration; @@ -161,7 +164,7 @@ if (isRelative) { iElement.addClass('sg-event--ghost--last'); } - else { + else if (!isAllDay) { // Set the end date scope.block.endHour = getEndTime(start, duration); } diff --git a/UI/WebServerResources/js/Scheduler/sgCalendarMonthEvent.directive.js b/UI/WebServerResources/js/Scheduler/sgCalendarMonthEvent.directive.js index d771fede4..c01e50115 100644 --- a/UI/WebServerResources/js/Scheduler/sgCalendarMonthEvent.directive.js +++ b/UI/WebServerResources/js/Scheduler/sgCalendarMonthEvent.directive.js @@ -35,7 +35,7 @@ // Add a class while dragging ' ng-class="{\'sg-event--dragging\': block.dragging}"', ' ng-click="clickBlock({clickEvent: $event, clickComponent: block.component})">', - ' {{ '+p+'block.starthour }}', + ' {{ '+p+'block.component.startHour }}', // Priority ' {{'+p+'block.component.c_priority}}', // Summary