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 timelogs in calendar

ulfertsd9b92e638224
diff --git a/app/assets/stylesheets/content/_calendars.sass b/app/assets/stylesheets/content/_calendars.sass
index 7281b1f2b00..51c24316e3e 100644
--- a/app/assets/stylesheets/content/_calendars.sass
+++ b/app/assets/stylesheets/content/_calendars.sass
@@ -21,6 +21,11 @@ full-calendar
.fc-button-active
@extend .button.-active
+ .fc-title
+ max-width: 100%
+ overflow: hidden
+ text-overflow: ellipsis
+
.fc-header-toolbar
h2
@extend h2
diff --git a/app/assets/stylesheets/content/_tooltip.sass b/app/assets/stylesheets/content/_tooltip.sass
index 9eff9527d9d..17f6c9b1026 100644
--- a/app/assets/stylesheets/content/_tooltip.sass
+++ b/app/assets/stylesheets/content/_tooltip.sass
@@ -43,6 +43,9 @@
margin-left: 0
font-size: 13.6px
+ &:first-child
+ margin-top: 0
+
.tooltip--map--key
font-weight: bold
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 4c1255360c0..147fc1bcf56 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -503,8 +503,11 @@ en:
settings: "Settings"
time_entry:
+ project: 'Project'
+ work_package: 'Work package'
activity: 'Activity'
comment: 'Comment'
+ duration: 'Duration'
hours: 'Hours'
two_factor_authentication:
diff --git a/frontend/angular.json b/frontend/angular.json
index 454b48afd59..dc222e02ddc 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -28,7 +28,8 @@
"node_modules/jquery-ui/themes/base/datepicker.css",
"node_modules/jquery-ui/themes/base/dialog.css",
"node_modules/@fullcalendar/core/main.css",
- "node_modules/@fullcalendar/daygrid/main.css"
+ "node_modules/@fullcalendar/daygrid/main.css",
+ "node_modules/@fullcalendar/timegrid/main.css"
],
"stylePreprocessorOptions": {
"includePaths": [
diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.json
index 614c71af05c..d93db2b6262 100644
--- a/frontend/npm-shrinkwrap.json
+++ b/frontend/npm-shrinkwrap.json
@@ -3355,6 +3355,14 @@
"resolved": "https://registry.npmjs.org/@fullcalendar/daygrid/-/daygrid-4.3.0.tgz",
"integrity": "sha512-OrGaRIGbELESOXOCXtoQVY4cOxnxmN7OrjDGbMoVITdoXWuIZ6sFNO84WcBQoRaIbkmqVM0SAU2MENwy+eEwqQ=="
},
+ "@fullcalendar/timegrid": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/@fullcalendar/timegrid/-/timegrid-4.3.0.tgz",
+ "integrity": "sha512-9JCSZbzw2Hi+X893l5X9ViZaWjxh+sDy59o6nKx0gYKwSfs/vKpmk73GBQfKyUv8orkjpnTdPFfeLDZqlzBP4Q==",
+ "requires": {
+ "@fullcalendar/daygrid": "~4.3.0"
+ }
+ },
"@istanbuljs/schema": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 79833474e23..7c058aaf496 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -45,6 +45,7 @@
"@fullcalendar/angular": "4.3.1",
"@fullcalendar/core": "4.3.1",
"@fullcalendar/daygrid": "4.3.0",
+ "@fullcalendar/timegrid": "4.3.0",
"@ng-select/ng-option-highlight": "0.0.2",
"@ng-select/ng-select": "^3.0.6",
"@sentry/browser": "^5.7.1",
diff --git a/frontend/src/app/modules/calendar/openproject-calendar.module.ts b/frontend/src/app/modules/calendar/openproject-calendar.module.ts
index f4139553683..e909ff09107 100644
--- a/frontend/src/app/modules/calendar/openproject-calendar.module.ts
+++ b/frontend/src/app/modules/calendar/openproject-calendar.module.ts
@@ -33,6 +33,7 @@ import {WorkPackagesCalendarEntryComponent} from "core-app/modules/calendar/wp-c
import {WorkPackagesCalendarController} from "core-app/modules/calendar/wp-calendar/wp-calendar.component";
import {OpenprojectWorkPackagesModule} from "core-app/modules/work_packages/openproject-work-packages.module";
import {Ng2StateDeclaration, UIRouterModule} from "@uirouter/angular";
+import {TimeEntryCalendarComponent} from "core-app/modules/calendar/te-calendar/te-calendar.component";
const menuItemClass = 'calendar-menu-item';
@@ -68,13 +69,16 @@ export const CALENDAR_ROUTES:Ng2StateDeclaration[] = [
// Work package calendars
WorkPackagesCalendarEntryComponent,
WorkPackagesCalendarController,
+ TimeEntryCalendarComponent
],
entryComponents: [
WorkPackagesCalendarController,
WorkPackagesCalendarEntryComponent,
+ TimeEntryCalendarComponent,
],
exports: [
- WorkPackagesCalendarController
+ WorkPackagesCalendarController,
+ TimeEntryCalendarComponent,
]
})
export class OpenprojectCalendarModule {
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
new file mode 100644
index 00000000000..c00950159f9
--- /dev/null
+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts
@@ -0,0 +1,206 @@
+import {Component, ElementRef, Input, OnDestroy, OnInit, SecurityContext, ViewChild, AfterViewInit, Output, EventEmitter} from "@angular/core";
+import {FullCalendarComponent} from '@fullcalendar/angular';
+import {States} from "core-components/states.service";
+import * as moment from "moment";
+import { Moment } from 'moment';
+import {StateService} from "@uirouter/core";
+import {I18nService} from "core-app/modules/common/i18n/i18n.service";
+import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";
+import {DomSanitizer} from "@angular/platform-browser";
+import timeGrid from '@fullcalendar/timegrid';
+import { EventInput, EventApi } from '@fullcalendar/core';
+import { EventSourceError } from '@fullcalendar/core/structs/event-source';
+import { ToolbarInput } from '@fullcalendar/core/types/input-types';
+import {ConfigurationService} from "core-app/modules/common/config/configuration.service";
+import {TimeEntryDmService} from "core-app/modules/hal/dm-services/time-entry-dm.service";
+import {FilterOperator} from "core-components/api/api-v3/api-v3-filter-builder";
+import {TimeEntryResource} from "core-app/modules/hal/resources/time-entry-resource";
+import {TimezoneService} from "core-components/datetime/timezone.service";
+import {CollectionResource} from "core-app/modules/hal/resources/collection-resource";
+
+interface CalendarViewEvent {
+ el:HTMLElement;
+ event:EventApi;
+ jsEvent:MouseEvent;
+}
+
+@Component({
+ templateUrl: './te-calendar.template.html',
+ selector: 'te-calendar',
+})
+export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewInit {
+ @ViewChild(FullCalendarComponent, { static: false }) ucCalendar:FullCalendarComponent;
+ @Input() projectIdentifier:string;
+ @Input() static:boolean = false;
+ @Output() entries = new EventEmitter<CollectionResource<TimeEntryResource>>();
+
+ public calendarPlugins = [timeGrid];
+ public calendarEvents:Function;
+ public calendarHeader:ToolbarInput|boolean = {
+ right: '',
+ center: 'title',
+ left: 'prev,next today'
+ };
+ public calendarSlotLabelFormat = (info:any) => 24 - info.date.hour;
+ public calendarScrollTime = '24:00:00';
+ public calendarContentHeight = 618;
+ public calendarAllDaySlot = false;
+ public calendarDisplayEventTime = false;
+ public calendarSlotEventOverlap = false;
+
+ constructor(readonly states:States,
+ readonly timeEntryDm:TimeEntryDmService,
+ readonly $state:StateService,
+ private element:ElementRef,
+ readonly i18n:I18nService,
+ readonly notificationsService:NotificationsService,
+ private sanitizer:DomSanitizer,
+ private configuration:ConfigurationService,
+ private timezone:TimezoneService) { }
+
+ ngOnInit() {
+ this.initializeCalendar();
+ }
+
+ ngOnDestroy() {
+ // nothing to do
+ }
+
+ ngAfterViewInit() {
+ // The full-calendar component's outputs do not seem to work
+ // see: https://github.com/fullcalendar/fullcalendar-angular/issues/228#issuecomment-523505044
+ // Therefore, setting the outputs via the underlying API
+ this.ucCalendar.getApi().setOption('eventRender', (event:CalendarViewEvent) => { this.addTooltip(event); });
+ }
+
+ public calendarEventsFunction(fetchInfo:{ start:Date, end:Date, timeZone:string },
+ successCallback:(events:EventInput[]) => void,
+ failureCallback:(error:EventSourceError) => void ):void | PromiseLike<EventInput[]> {
+
+ this.timeEntryDm.list({ filters: this.dmFilters(fetchInfo) })
+ .then((collection) => {
+ this.entries.emit(collection);
+ successCallback(this.buildEntries(collection.elements));
+ });
+ }
+
+ private buildEntries(entries:TimeEntryResource[]) {
+ let calendarEntries = [];
+
+ let hoursDistribution:{ [key:string]:Moment } = {};
+
+ return entries.map((entry) => {
+ let start:Moment;
+ let end:Moment;
+ let hours = this.timezone.toHours(entry.hours);
+
+ if (hoursDistribution[entry.spentOn]) {
+ start = hoursDistribution[entry.spentOn].clone().subtract(hours, 'h');
+ end = hoursDistribution[entry.spentOn].clone();
+ } else {
+ start = moment(entry.spentOn).add(24 - hours, 'h');
+ end = moment(entry.spentOn).add(24, 'h');
+ }
+
+ hoursDistribution[entry.spentOn] = start;
+
+ return {
+ title: hours < 0.5 ? '' : this.entryName(entry),
+ start: start.format(),
+ end: end.format(),
+ entry: entry
+ };
+ });
+ }
+
+ protected dmFilters(fetchInfo:{ start:Date, end:Date, timeZone:string }):Array<[string, FilterOperator, string[]]> {
+ let startDate = moment(fetchInfo.start).format('YYYY-MM-DD');
+ let endDate = moment(fetchInfo.end).subtract(1, 'd').format('YYYY-MM-DD');
+ return [['spentOn', '<>d', [startDate, endDate]] as [string, FilterOperator, string[]],
+ ['user_id', '=', ['me']] as [string, FilterOperator, [string]]];
+ }
+
+ private initializeCalendar() {
+ this.calendarEvents = this.calendarEventsFunction.bind(this);
+ }
+
+ public get calendarEditable() {
+ return false;
+ }
+
+ public get calendarEventLimit() {
+ return false;
+ }
+
+ public get calendarLocale() {
+ return this.i18n.locale;
+ }
+
+ public get calendarFixedWeekCount() {
+ return false;
+ }
+
+ public get calendarDefaultView() {
+ return 'timeGridWeek';
+ }
+
+ public get calendarFirstDay() {
+ return this.configuration.startOfWeek();
+ }
+
+ private get calendarElement() {
+ return jQuery(this.element.nativeElement).find('.fc-view-container');
+ }
+
+ private addTooltip(event:CalendarViewEvent) {
+ jQuery(event.el).tooltip({
+ content: this.tooltipContentString(event.event.extendedProps.entry),
+ items: '.fc-event',
+ close: function () { jQuery(".ui-helper-hidden-accessible").remove(); },
+ track: true
+ });
+ }
+
+ private entryName(entry:TimeEntryResource) {
+ let name = entry.project.name;
+ if (entry.workPackage) {
+ name += ` - ${this.workPackageName(entry)}`;
+ }
+
+ return this.sanitizedValue(name) || '-';
+ }
+
+ private workPackageName(entry:TimeEntryResource) {
+ return `#${entry.workPackage.idFromLink}: ${entry.workPackage.name}`;
+ }
+
+ private tooltipContentString(entry:TimeEntryResource) {
+ return `
+ <ul class="tooltip--map">
+ <li class="tooltip--map--item">
+ <span class="tooltip--map--key">${this.i18n.t('js.time_entry.project')}:</span>
+ <span class="tooltip--map--value">${this.sanitizedValue(entry.project.name)}</span>
+ </li>
+ <li class="tooltip--map--item">
+ <span class="tooltip--map--key">${this.i18n.t('js.time_entry.work_package')}:</span>
+ <span class="tooltip--map--value">${entry.workPackage ? this.sanitizedValue(this.workPackageName(entry)) : this.i18n.t('js.placeholders.default')}</span>
+ </li>
+ <li class="tooltip--map--item">
+ <span class="tooltip--map--key">${this.i18n.t('js.time_entry.activity')}:</span>
+ <span class="tooltip--map--value">${this.sanitizedValue(entry.activity.name)}</span>
+ </li>
+ <li class="tooltip--map--item">
+ <span class="tooltip--map--key">${this.i18n.t('js.time_entry.duration')}:</span>
+ <span class="tooltip--map--value">${this.timezone.formattedDuration(entry.hours)}</span>
+ </li>
+ <li class="tooltip--map--item">
+ <span class="tooltip--map--key">${this.i18n.t('js.time_entry.comment')}:</span>
+ <span class="tooltip--map--value">${entry.comment.html || this.i18n.t('js.placeholders.default')}</span>
+ </li>
+ `;
+ }
+
+ private sanitizedValue(value:string) {
+ return this.sanitizer.sanitize(SecurityContext.HTML, value);
+ }
+}
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
new file mode 100644
index 00000000000..e70c6396ecb
--- /dev/null
+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.template.html
@@ -0,0 +1,22 @@
+<!-- position: relative added in order for the loading indicator to be positioned correctly -->
+<div class="te-calendar--container loading-indicator--location"
+ [attr.data-indicator-name]="'table'"
+ style="position: relative">
+ <full-calendar #ucCalendar
+ [editable]="calendarEditable"
+ [eventLimit]="calendarEventLimit"
+ [locale]="calendarLocale"
+ [fixedWeekCount]="calendarFixedWeekCount"
+ [header]="calendarHeader"
+ [defaultView]="calendarDefaultView"
+ [firstDay]="calendarFirstDay"
+ [contentHeight]="calendarContentHeight"
+ [slotLabelFormat]="calendarSlotLabelFormat"
+ [slotEventOverlap]="calendarSlotEventOverlap"
+ [allDaySlot]="calendarAllDaySlot"
+ [displayEventTime]="calendarDisplayEventTime"
+ [scrollTime]="calendarScrollTime"
+ [events]="calendarEvents"
+ [plugins]="calendarPlugins">
+ </full-calendar>
+</div>
diff --git a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
index 8e9da09ab69..8363fb5f318 100644
--- a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
+++ b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
@@ -139,7 +139,7 @@ export class WorkPackagesCalendarController implements OnInit, OnDestroy, AfterV
public addTooltip(event:CalendarViewEvent) {
jQuery(event.el).tooltip({
content: this.tooltipContentString(event.event.extendedProps.workPackage),
- items: '.fc-content',
+ items: '.fc-event',
close: function () { jQuery(".ui-helper-hidden-accessible").remove(); },
track: true
});
diff --git a/frontend/src/app/modules/grids/openproject-grids.module.ts b/frontend/src/app/modules/grids/openproject-grids.module.ts
index 2b392e07a92..5bbef3ae5e3 100644
--- a/frontend/src/app/modules/grids/openproject-grids.module.ts
+++ b/frontend/src/app/modules/grids/openproject-grids.module.ts
@@ -35,7 +35,7 @@ import {FormsModule} from '@angular/forms';
import {DragDropModule} from '@angular/cdk/drag-drop';
import {OpenprojectWorkPackagesModule} from "core-app/modules/work_packages/openproject-work-packages.module";
import {WidgetWpCalendarComponent} from "core-app/modules/grids/widgets/wp-calendar/wp-calendar.component.ts";
-import {WidgetTimeEntriesCurrentUserComponent} from "core-app/modules/grids/widgets/time-entries-current-user/current-user/time-entries-current-user.component";
+import {WidgetTimeEntriesCurrentUserComponent} from "core-app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component";
import {GridWidgetsService} from "core-app/modules/grids/widgets/widgets.service";
import {GridComponent} from "core-app/modules/grids/grid/grid.component";
import {AddGridWidgetModal} from "core-app/modules/grids/widgets/add/add.modal";
@@ -59,7 +59,7 @@ import {WidgetWpOverviewComponent} from "core-app/modules/grids/widgets/wp-overv
import {WidgetCustomTextComponent} from "core-app/modules/grids/widgets/custom-text/custom-text.component";
import {OpenprojectFieldsModule} from "core-app/modules/fields/openproject-fields.module";
import {WidgetProjectDetailsComponent} from "core-app/modules/grids/widgets/project-details/project-details.component";
-import {WidgetTimeEntriesProjectComponent} from "core-app/modules/grids/widgets/time-entries-current-user/project/time-entries-project.component";
+import {WidgetTimeEntriesProjectComponent} from "core-app/modules/grids/widgets/time-entries/project/time-entries-project.component";
import {WidgetSubprojectsComponent} from "core-app/modules/grids/widgets/subprojects/subprojects.component";
import {OpenprojectAttachmentsModule} from "core-app/modules/attachments/openproject-attachments.module";
import {WidgetMembersComponent} from "core-app/modules/grids/widgets/members/members.component";
diff --git a/frontend/src/app/modules/grids/widgets/time-entries-current-user/current-user/time-entries-current-user.component.ts b/frontend/src/app/modules/grids/widgets/time-entries-current-user/current-user/time-entries-current-user.component.ts
deleted file mode 100644
index cebc823079d..00000000000
--- a/frontend/src/app/modules/grids/widgets/time-entries-current-user/current-user/time-entries-current-user.component.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import {Component, OnInit} from "@angular/core";
-import {FilterOperator} from "core-components/api/api-v3/api-v3-filter-builder";
-import {WidgetTimeEntriesListComponent} from "core-app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component";
-
-@Component({
- templateUrl: '../list/time-entries-list.component.html',
-})
-export class WidgetTimeEntriesCurrentUserComponent extends WidgetTimeEntriesListComponent implements OnInit {
- protected dmFilters():Array<[string, FilterOperator, [string]]> {
- return [['spentOn', '>t-', ['7']] as [string, FilterOperator, [string]],
- ['user_id', '=', ['me']] as [string, FilterOperator, [string]]];
- }
-}
diff --git a/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.html b/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.html
new file mode 100644
index 00000000000..92e9bf66ef3
--- /dev/null
+++ b/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.html
@@ -0,0 +1,18 @@
+<widget-header
+ [name]="widgetName"
+ (onRenamed)="renameWidget($event)">
+
+ <widget-menu
+ [resource]="resource">
+ </widget-menu>
+</widget-header>
+
+<te-calendar
+ (entries)="updateEntries($event)"
+></te-calendar>
+
+<ng-container>
+ <div class="total-hours">
+ <p>Total: <span [textContent]="total"></span></p>
+ </div>
+</ng-container>
diff --git a/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.ts b/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.ts
new file mode 100644
index 00000000000..e2dc33bb5fa
--- /dev/null
+++ b/frontend/src/app/modules/grids/widgets/time-entries/current-user/time-entries-current-user.component.ts
@@ -0,0 +1,45 @@
+import {Component, Injector, ChangeDetectionStrategy, ChangeDetectorRef} from "@angular/core";
+import { TimeEntryResource } from 'core-app/modules/hal/resources/time-entry-resource';
+import {CollectionResource} from "core-app/modules/hal/resources/collection-resource";
+import {TimezoneService} from "core-components/datetime/timezone.service";
+import {I18nService} from "core-app/modules/common/i18n/i18n.service";
+import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
+import {AbstractWidgetComponent} from "core-app/modules/grids/widgets/abstract-widget.component";
+
+@Component({
+ templateUrl: './time-entries-current-user.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class WidgetTimeEntriesCurrentUserComponent extends AbstractWidgetComponent {
+ public entries:TimeEntryResource[] = [];
+
+ constructor(protected readonly injector:Injector,
+ readonly timezone:TimezoneService,
+ readonly i18n:I18nService,
+ readonly pathHelper:PathHelperService,
+ protected readonly cdr:ChangeDetectorRef) {
+ super(i18n, injector);
+ }
+
+ public updateEntries(entries:CollectionResource<TimeEntryResource>) {
+ this.entries = entries.elements;
+
+ this.cdr.detectChanges();
+ }
+
+ public get total() {
+ let duration = this.entries.reduce((current, entry) => {
+ return current + this.timezone.toHours(entry.hours);
+ }, 0);
+
+ if (duration > 0) {
+ return this.i18n.t('js.units.hour', { count: this.formatNumber(duration) });
+ } else {
+ return this.i18n.t('js.placeholders.default');
+ }
+ }
+
+ protected formatNumber(value:number):string {
+ return this.i18n.toNumber(value, { precision: 2 });
+ }
+}
diff --git a/frontend/src/app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component.html b/frontend/src/app/modules/grids/widgets/time-entries/list/time-entries-list.component.html
similarity index 100%
rename from frontend/src/app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component.html
rename to frontend/src/app/modules/grids/widgets/time-entries/list/time-entries-list.component.html
diff --git a/frontend/src/app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component.ts b/frontend/src/app/modules/grids/widgets/time-entries/list/time-entries-list.component.ts
similarity index 99%
rename from frontend/src/app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component.ts
rename to frontend/src/app/modules/grids/widgets/time-entries/list/time-entries-list.component.ts
index cdfa67798f7..33c72b0e857 100644
--- a/frontend/src/app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component.ts
+++ b/frontend/src/app/modules/grids/widgets/time-entries/list/time-entries-list.component.ts
@@ -149,7 +149,7 @@ export abstract class WidgetTimeEntriesListComponent extends AbstractWidgetCompo
//entries
}
- private formatNumber(value:number):string {
+ protected formatNumber(value:number):string {
return this.i18n.toNumber(value, { precision: 2 });
}
diff --git a/frontend/src/app/modules/grids/widgets/time-entries-current-user/project/time-entries-project.component.ts b/frontend/src/app/modules/grids/widgets/time-entries/project/time-entries-project.component.ts
similarity index 95%
rename from frontend/src/app/modules/grids/widgets/time-entries-current-user/project/time-entries-project.component.ts
rename to frontend/src/app/modules/grids/widgets/time-entries/project/time-entries-project.component.ts
index 6f65c3c6b91..efe5fc5ab2d 100644
--- a/frontend/src/app/modules/grids/widgets/time-entries-current-user/project/time-entries-project.component.ts
+++ b/frontend/src/app/modules/grids/widgets/time-entries/project/time-entries-project.component.ts
@@ -1,6 +1,6 @@
import {Component, OnInit, Injector, ChangeDetectorRef} from "@angular/core";
import {FilterOperator} from "core-components/api/api-v3/api-v3-filter-builder";
-import {WidgetTimeEntriesListComponent} from "core-app/modules/grids/widgets/time-entries-current-user/list/time-entries-list.component";
+import {WidgetTimeEntriesListComponent} from "core-app/modules/grids/widgets/time-entries/list/time-entries-list.component";
import {TimeEntryDmService} from "core-app/modules/hal/dm-services/time-entry-dm.service";
import {TimezoneService} from "core-components/datetime/timezone.service";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
diff --git a/frontend/src/app/modules/grids/widgets/wp-graph/wp-graph.component.ts b/frontend/src/app/modules/grids/widgets/wp-graph/wp-graph.component.ts
index bb9272f88bf..6650ea95ae8 100644
--- a/frontend/src/app/modules/grids/widgets/wp-graph/wp-graph.component.ts
+++ b/frontend/src/app/modules/grids/widgets/wp-graph/wp-graph.component.ts
@@ -20,7 +20,6 @@ export class WidgetWpGraphComponent extends AbstractWidgetComponent implements O
constructor(protected i18n:I18nService,
protected injector:Injector,
protected cdr:ChangeDetectorRef,
- protected urlParamsHelper:UrlParamsHelperService,
protected readonly graphConfiguration:WpGraphConfigurationService) {
super(i18n, injector);
}
diff --git a/modules/grids/config/locales/js-en.yml b/modules/grids/config/locales/js-en.yml
index ded27f5e40f..f162bb56239 100644
--- a/modules/grids/config/locales/js-en.yml
+++ b/modules/grids/config/locales/js-en.yml
@@ -38,8 +38,7 @@ en:
title: 'Subprojects'
no_results: 'No subprojects.'
time_entries_list:
- title: 'Spent time (last 7 days)'
- no_results: 'No time entries for the last 7 days.'
+ title: 'Spent time'
work_packages_accountable:
title: "Work packages I am accountable for"
work_packages_assigned:
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index 894015bb916..1170419751d 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -45,7 +45,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
project: project,
user: user,
spent_on: Date.today,
- hours: 6,
+ hours: 3,
comments: 'My comment'
end
let!(:other_visible_time_entry) do
@@ -53,10 +53,20 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
work_package: work_package,
project: project,
user: user,
- spent_on: Date.today - 1.day,
- hours: 5,
+ # limit the date to ensure that it is on the current calendar sheet
+ spent_on: Date.today - [1, Date.today.wday].min.days,
+ hours: 2,
comments: 'My other comment'
end
+ let!(:last_week_visible_time_entry) do
+ FactoryBot.create :time_entry,
+ work_package: work_package,
+ project: project,
+ user: user,
+ spent_on: Date.today - (Date.today.wday + 3).days,
+ hours: 8,
+ comments: 'My last week comment'
+ end
let!(:invisible_time_entry) do
FactoryBot.create :time_entry,
work_package: work_package,
@@ -84,35 +94,51 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
it 'adds the widget and checks the displayed entries' do
# within top-right area, add an additional widget
- my_page.add_widget(1, 1, :within, 'Spent time \(last 7 days\)')
+ my_page.add_widget(1, 1, :within, 'Spent time')
entries_area = Components::Grids::GridArea.new('.grid--area.-widgeted:nth-of-type(1)')
entries_area.expect_to_span(1, 1, 2, 2)
expect(page)
- .to have_content "Total: 11.00"
+ .to have_content "Total: 5.00"
expect(page)
- .to have_content Date.today.strftime('%m/%d/%Y')
- expect(page)
- .to have_selector('.activity', text: visible_time_entry.activity.name)
+ .to have_content visible_time_entry.spent_on.strftime('%m/%d')
expect(page)
- .to have_selector('.subject', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")
+ .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")
+
expect(page)
- .to have_selector('.comments', text: visible_time_entry.comments)
+ .to have_content(other_visible_time_entry.spent_on.strftime('%m/%d'))
expect(page)
- .to have_selector('.hours', text: visible_time_entry.hours)
+ .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")
+
+ # go to last week
+ within entries_area.area do
+ find('.fc-toolbar .fc-prev-button').click
+ end
expect(page)
- .to have_content((Date.today - 1.day).strftime('%m/%d/%Y'))
+ .to have_content "Total: 8.00"
+
expect(page)
- .to have_selector('.activity', text: other_visible_time_entry.activity.name)
+ .to have_content(last_week_visible_time_entry.spent_on.strftime('%m/%d'))
expect(page)
- .to have_selector('.subject', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")
+ .to have_selector('.fc-event .fc-title', text: "#{project.name} - ##{work_package.id}: #{work_package.subject}")
+
+ # go to today again
+ within entries_area.area do
+ find('.fc-toolbar .fc-today-button').click
+ end
+
expect(page)
- .to have_selector('.comments', text: other_visible_time_entry.comments)
+ .to have_content "Total: 5.00"
+
+ within entries_area.area do
+ find(".fc-content-skeleton td:nth-of-type(#{Date.today.wday + 1}) .fc-event-container .fc-event").hover
+ end
+
expect(page)
- .to have_selector('.hours', text: other_visible_time_entry.hours)
+ .to have_selector('.ui-tooltip', text: "Project: #{project.name}")
entries_area.remove