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

always show add addEntry event but display as prohibit eventually

ulferts6de786bd6292
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
index 308fa3d064d..fbdc99f68a1 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
@@ -66,6 +66,9 @@
font-weight: normal
font-size: 1.5rem
+ &.-prohibited
+ cursor: not-allowed
+
.te-calendar--time-entry
.fc-content
height: 100%
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 3afe648e12a..7926a9bb039 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
@@ -44,6 +44,7 @@ interface CalendarMoveEvent {
const TIME_ENTRY_CLASS_NAME = 'te-calendar--time-entry';
const DAY_SUM_CLASS_NAME = 'te-calendar--day-sum';
const ADD_ENTRY_CLASS_NAME = 'te-calendar--add-entry';
+const ADD_ENTRY_PROHIBITED_CLASS_NAME = '-prohibited';
@Component({
templateUrl: './te-calendar.template.html',
@@ -76,9 +77,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
center: 'title',
left: 'prev,next today'
};
- public calendarSlotLabelFormat = (info:any) => {
- return (this.maxHour - info.date.hour) / this.scaleRatio;
- }
+ public calendarSlotLabelFormat = (info:any) => (this.maxHour - info.date.hour) / this.scaleRatio;
public calendarSlotLabelInterval = `${this.labelIntervalHours}:00:00`;
public calendarContentHeight = 605;
public calendarAllDaySlot = false;
@@ -218,7 +217,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
calendarEntries.push(this.sumEntry(m, duration));
- if (this.memoizedCreateAllowed && duration < 24) {
+ if (this.memoizedCreateAllowed) {
calendarEntries.push(this.addEntry(m, duration));
}
}
@@ -275,11 +274,19 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
}
protected addEntry(date:Moment, duration:number) {
+ let classNames = [ADD_ENTRY_CLASS_NAME];
+ let title = '+';
+
+ if (duration >= 24) {
+ classNames.push(ADD_ENTRY_PROHIBITED_CLASS_NAME);
+ title = '';
+ }
+
return {
- title: '+',
+ title: title,
start: date.clone().format(),
end: date.clone().add(this.maxHour - Math.min(duration * this.scaleRatio, this.maxHour - 1) - 0.5, 'h').format(),
- classNames: ADD_ENTRY_CLASS_NAME
+ classNames: classNames
};
}
@@ -321,8 +328,8 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
private dispatchEventClick(event:CalendarViewEvent) {
if (event.event.extendedProps.entry) {
this.editEvent(event.event.extendedProps.entry);
- } else if (event.event.start) {
- this.addEvent(moment(event.event.start));
+ } else if (event.el.classList.contains(ADD_ENTRY_CLASS_NAME) && !event.el.classList.contains(ADD_ENTRY_PROHIBITED_CLASS_NAME)) {
+ this.addEvent(moment(event.event.start!));
}
}