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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fade out event title to bottom
ulferts96db3e0638c7
diff --git a/frontend/src/app/components/user/user-avatar/user-avatar.component.ts b/frontend/src/app/components/user/user-avatar/user-avatar.component.tsindex a2a9f771c9d..989458f4748 100644--- a/frontend/src/app/components/user/user-avatar/user-avatar.component.ts+++ b/frontend/src/app/components/user/user-avatar/user-avatar.component.ts@@ -89,7 +89,7 @@ export class UserAvatarComponent implements AfterViewInit {this.useFallback = element.dataset.useFallback!;this.userAvatarUrl = this.pathHelper.api.v3.users.id(this.userId).avatar.toString();this.userInitials = this.getInitials(this.userName);- this.colorCode = this.colors.forString(this.userName);+ this.colorCode = this.colors.toHsl(this.userName);this.ref.detectChanges();}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.sassindex ba9da12244a..63774bf9fd2 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass@@ -61,6 +61,20 @@font-weight: normalfont-size: 1.5rem+ .te-calendar--time-entry+ .fc-content+ height: 100%++ .fc-fadeout+ position: relative+ bottom: 2em+ height: 2em+ z-index: 5++ &.fc-short+ .fc-fadeout+ display: none+.fc-durationborder-right: 1px solid whiteborder-bottom: 1px solid whitediff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.tsindex e02728f5b0c..c4c24c87452 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@@ -24,17 +24,12 @@ import {TimeEntryEditService} from "core-app/modules/time_entries/edit/edit.servimport {TimeEntryCreateService} from "core-app/modules/time_entries/create/create.service";import {ColorsService} from "core-app/modules/common/colors/colors.service";-interface CalendarViewEvent {el:HTMLElement;event:EventApi;jsEvent:MouseEvent;}-interface CalendarDateClickEvent {- date:Date;-}-interface CalendarMoveEvent {el:HTMLElement;event:EventApi;@@ -176,7 +171,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIhoursDistribution[entry.spentOn] = start;- const color = this.colors.forString(this.entryName(entry));+ const color = this.colors.toHsl(this.entryName(entry));return this.timeEntry(entry, hours, start, end);}) as EventInput[];@@ -211,7 +206,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI}protected timeEntry(entry:TimeEntryResource, hours:number, start:Moment, end:Moment) {- const color = this.colors.forString(this.entryName(entry));+ const color = this.colors.toHsl(this.entryName(entry));return {title: hours < 0.5 ? '' : this.entryName(entry),@@ -357,6 +352,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIthis.addTooltip(event);this.prependDuration(event);+ this.appendFadeout(event);}private addTooltip(event:CalendarViewEvent) {@@ -380,6 +376,38 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI.prepend(`<div class="fc-duration">${formattedDuration}</div>`);}+ /* Fade out event text to the bottom to avoid it being cut of weirdly.+ * Multiline ellipsis with an unknown height is not possible, hence we blur the text.+ * The gradient needs to take the background color of the element into account (hashed over the event+ * title) which is why the style is set in code.+ *+ * We do not print anything on short entries (< 0.5 hours),+ * which leads to the fc-short class not being applied by full calendar. For other short events, the css rules+ * need to deactivate the fc-fadeout.+ */+ private appendFadeout(event:CalendarViewEvent) {+ let timeEntry = event.event.extendedProps.entry;++ if (this.timezone.toHours(timeEntry.hours) < 0.5) {+ return;+ }++ let $element = jQuery(event.el);+ let fadeout = jQuery(`<div class="fc-fadeout"></div>`);++ let hslaStart = this.colors.toHsla(this.entryName(timeEntry), 0);+ let hslaEnd = this.colors.toHsla(this.entryName(timeEntry), 100);++ fadeout.css('background', `-webkit-linear-gradient(${hslaStart} 0%, ${hslaEnd} 100%`);++ ['-moz-linear-gradient', '-o-linear-gradient', 'linear-gradient', '-ms-linear-gradient'].forEach((style => {+ fadeout.css('background-image', `${style}(${hslaStart} 0%, ${hslaEnd} 100%`);+ }));++ $element+ .append(fadeout);+ }+private beforeEventRemove(event:CalendarViewEvent) {if (!event.event.extendedProps.entry) {return;diff --git a/frontend/src/app/modules/common/colors/colors.service.ts b/frontend/src/app/modules/common/colors/colors.service.tsindex e1414f05fe5..9a76d244e41 100644--- a/frontend/src/app/modules/common/colors/colors.service.ts+++ b/frontend/src/app/modules/common/colors/colors.service.ts@@ -2,14 +2,20 @@ import { Injectable } from '@angular/core';@Injectable()export class ColorsService {- public forString(value:string) {+ public toHsl(value:string) {+ return `hsl(${this.valueHash(value)}, 50%, 50%)`;+ }++ public toHsla(value:string, opacity:number) {+ return `hsla(${this.valueHash(value)}, 50%, 50%, ${opacity}%)`;+ }++ protected valueHash(value:string) {let hash = 0;- for (var i = 0; i < value.length; i++) {+ for (let i = 0; i < value.length; i++) {hash = value.charCodeAt(i) + ((hash << 5) - hash);}- let h = hash % 360;-- return 'hsl(' + h + ', 50%, 50%)';+ return hash % 360;}}\ No newline at end of file