Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

display daily sum

ulferts38c6cd3d70eb
diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass
new file mode 100644
index 00000000000..b18c691ce1b
--- /dev/null
+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass
@@ -0,0 +1,19 @@
+.fc-view-container
+ .fc-head-container
+ border-color: white
+
+ .fc-widget-content
+ border-left-color: white
+
+ .fc-timeGrid-view .fc-day-grid .fc-row
+ min-height: 1em
+
+ .fc-timeGrid-view .fc-day-grid .fc-row .fc-content-skeleton
+ padding-bottom: 0
+
+ .te-calendar--day-sum
+ border: none
+ background-color: initial
+ color: #000000
+ text-align: center
+ font-size: 1em
diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts
index acb3a796558..d776d3c756b 100644
--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts
+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts
@@ -1,4 +1,4 @@
-import {Component, ElementRef, Input, OnDestroy, OnInit, SecurityContext, ViewChild, AfterViewInit, Output, EventEmitter, Injector} from "@angular/core";
+import {Component, ElementRef, Input, OnDestroy, OnInit, SecurityContext, ViewChild, AfterViewInit, Output, EventEmitter, Injector, ViewEncapsulation} from "@angular/core";
import {FullCalendarComponent} from '@fullcalendar/angular';
import {States} from "core-components/states.service";
import * as moment from "moment";
@@ -28,7 +28,9 @@ interface CalendarViewEvent {
@Component({
templateUrl: './te-calendar.template.html',
+ styleUrls: ['./te-calendar.component.sass'],
selector: 'te-calendar',
+ encapsulation: ViewEncapsulation.None,
})
export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild(FullCalendarComponent, { static: false }) ucCalendar:FullCalendarComponent;
@@ -45,8 +47,9 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
};
public calendarSlotLabelFormat = (info:any) => 24 - info.date.hour;
public calendarScrollTime = '24:00:00';
- public calendarContentHeight = 618;
- public calendarAllDaySlot = false;
+ public calendarContentHeight = 545;
+ public calendarAllDaySlot = true;
+ public calendarAllDayText = '';
public calendarDisplayEventTime = false;
public calendarSlotEventOverlap = false;
public calendarEditable = false;
@@ -90,7 +93,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
.then((collection) => {
this.entries.emit(collection);
- successCallback(this.buildEntries(collection.elements));
+ successCallback(this.buildEntries(collection.elements, fetchInfo));
});
}
@@ -113,10 +116,14 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
return this.memoizedTimeEntries.entries;
}
-private buildEntries(entries:TimeEntryResource[]) {
- let calendarEntries = [];
+ private buildEntries(entries:TimeEntryResource[], fetchInfo:{ start:Date, end:Date }) {
+ return this.buildTimeEntryEntries(entries)
+ .concat(this.buildSumEntries(entries, fetchInfo));
+ }
+ private buildTimeEntryEntries(entries:TimeEntryResource[]) {
let hoursDistribution:{ [key:string]:Moment } = {};
+ let dateSums:{ [key:string]:number } = {};
return entries.map((entry) => {
let start:Moment;
@@ -139,7 +146,37 @@ private buildEntries(entries:TimeEntryResource[]) {
end: end.format(),
entry: entry
};
+ }) as EventInput[];
+ }
+
+ private buildSumEntries(entries:TimeEntryResource[], fetchInfo:{ start:Date, end:Date }) {
+ let dateSums:{ [key:string]:number } = {};
+
+ entries.forEach((entry) => {
+ let hours = this.timezone.toHours(entry.hours);
+
+ if (dateSums[entry.spentOn]) {
+ dateSums[entry.spentOn] += hours;
+ } else {
+ dateSums[entry.spentOn] = hours;
+ }
});
+
+ let calendarEntries:EventInput[] = [];
+
+ for (let m = moment(fetchInfo.start); m.diff(fetchInfo.end, 'days') <= 0; m.add(1, 'days')) {
+ let duration = dateSums[m.format('YYYY-MM-DD')] || 0;
+
+ calendarEntries.push({
+ title: this.i18n.t('js.units.hour', { count: this.formatNumber(duration) }),
+ allDay: true,
+ start: m.format(),
+ classNames: 'te-calendar--day-sum',
+ end: m.format()
+ });
+ }
+
+ return calendarEntries;
}
protected dmFilters(start:Date, end:Date):Array<[string, FilterOperator, string[]]> {
@@ -205,6 +242,10 @@ private buildEntries(entries:TimeEntryResource[]) {
}
private addTooltip(event:CalendarViewEvent) {
+ if (!event.event.extendedProps.entry) {
+ return;
+ }
+
jQuery(event.el).tooltip({
content: this.tooltipContentString(event.event.extendedProps.entry),
items: '.fc-event',
@@ -255,4 +296,8 @@ private buildEntries(entries:TimeEntryResource[]) {
private sanitizedValue(value:string) {
return this.sanitizer.sanitize(SecurityContext.HTML, value);
}
+
+ protected formatNumber(value:number):string {
+ return this.i18n.toNumber(value, { precision: 2 });
+ }
}
diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.template.html b/frontend/src/app/modules/calendar/te-calendar/te-calendar.template.html
index e70c6396ecb..272195d1f01 100644
--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.template.html
+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.template.html
@@ -14,6 +14,7 @@
[slotLabelFormat]="calendarSlotLabelFormat"
[slotEventOverlap]="calendarSlotEventOverlap"
[allDaySlot]="calendarAllDaySlot"
+ [allDayText]="calendarAllDayText"
[displayEventTime]="calendarDisplayEventTime"
[scrollTime]="calendarScrollTime"
[events]="calendarEvents"