Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/opf/openproject into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
birthe committed Feb 11, 2020
2 parents 87852be + 5963855 commit 237558a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
Expand Up @@ -24,7 +24,6 @@
text-align: right
display: block
float: left
margin-left: 5px
padding-right: 8px
height: 1rem
// width calculation done in js code
Expand Down
8 changes: 4 additions & 4 deletions app/views/forums/index.html.erb
Expand Up @@ -30,10 +30,10 @@ See docs/COPYRIGHT.rdoc for more details.
<%= toolbar title: t(:label_forum_plural) do %>
<% if User.current.allowed_to?(:manage_forums, @project) %>
<li class="toolbar-item">
<%= link_to({ controller: '/forums', action: 'new', project_id: @project },
{ aria: { label: t(:label_forum_new) },
title: t(:label_forum_new),
class: 'button -highlight' }) do %>
<%= link_to(new_project_forum_path(@project),
{ aria: { label: t(:label_forum_new) },
title: t(:label_forum_new),
class: 'button -alt-highlight' }) do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= t('activerecord.models.forum') %></span>
<% end %>
Expand Down
Expand Up @@ -7,7 +7,7 @@
.fc-head
display: table-footer-group

.fc-event
.fc-event, .fc-bgevent
border-radius: 0
margin-right: 8px
margin-left: 8px
Expand Down Expand Up @@ -39,12 +39,10 @@
background-color: initial
color: #000000
text-align: center
font-size: 1em
font-size: 0.875em
font-weight: bold

.fc-title
// as this is the height of the day sum element
line-height: 22px
line-height: 22px
opacity: 1

.te-calendar--add-entry
text-align: center
Expand All @@ -60,7 +58,7 @@
transition: opacity 1s ease
background: #EAEAEA

.fc-content
.te-calendar--add-icon
color: black
width: 100%
font-weight: normal
Expand All @@ -69,6 +67,9 @@
&.-prohibited
cursor: not-allowed

.te-calendar--add-icon
display: none

.te-calendar--time-entry
.fc-content
height: 100%
Expand Down
Expand Up @@ -5,7 +5,6 @@ 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, Duration, View } from '@fullcalendar/core';
Expand All @@ -24,6 +23,7 @@ import {TimeEntryEditService} from "core-app/modules/time_entries/edit/edit.serv
import {TimeEntryCreateService} from "core-app/modules/time_entries/create/create.service";
import {ColorsService} from "core-app/modules/common/colors/colors.service";
import {BrowserDetector} from "core-app/modules/common/browser/browser-detector.service";
import { HalResourceNotificationService } from 'core-app/modules/hal/services/hal-resource-notification.service';

interface CalendarViewEvent {
el:HTMLElement;
Expand All @@ -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_ICON_CLASS_NAME = 'te-calendar--add-icon';
const ADD_ENTRY_PROHIBITED_CLASS_NAME = '-prohibited';

@Component({
Expand Down Expand Up @@ -101,7 +102,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
private element:ElementRef,
readonly i18n:I18nService,
readonly injector:Injector,
readonly notificationsService:NotificationsService,
readonly notifications:HalResourceNotificationService,
private sanitizer:DomSanitizer,
private configuration:ConfigurationService,
private timezone:TimezoneService,
Expand Down Expand Up @@ -270,26 +271,25 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI

protected sumEntry(date:Moment, duration:number) {
return {
title: this.i18n.t('js.units.hour', { count: this.formatNumber(duration) }),
start: date.clone().add(this.maxHour - Math.min(duration * this.scaleRatio, this.maxHour - 0.5) - 0.5, 'h').format(),
end: date.clone().add(this.maxHour - Math.min(((duration + 0.05) * this.scaleRatio), this.maxHour - 0.5), 'h').format(),
classNames: DAY_SUM_CLASS_NAME
classNames: DAY_SUM_CLASS_NAME,
rendering: 'background' as 'background',
sum: this.i18n.t('js.units.hour', { count: this.formatNumber(duration) })
};
}

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,
start: date.clone().format(),
end: date.clone().add(this.maxHour - Math.min(duration * this.scaleRatio, this.maxHour - 1) - 0.5, 'h').format(),
rendering: "background" as 'background',
classNames: classNames
};
}
Expand Down Expand Up @@ -352,15 +352,18 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
private moveEvent(event:CalendarMoveEvent) {
let entry = event.event.extendedProps.entry;

entry.spentOn = moment(event.event.start!).format('YYYY-MM-DD');
// Use end instead of start as when dragging, the event might be too long and would thus be start
// on the day before by fullcalendar.
entry.spentOn = moment(event.event.end!).format('YYYY-MM-DD');

this
.timeEntryDm
.update(entry, entry.schema)
.then(event => {
this.updateEventSet(event, 'update');
})
.catch(() => {
.catch((e) => {
this.notifications.handleRawError(e);
event.revert();
});
}
Expand Down Expand Up @@ -407,6 +410,9 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
}

private alterEventEntry(event:CalendarViewEvent) {
this.appendAddIcon(event);
this.appendSum(event);

if (!event.event.extendedProps.entry) {
return;
}
Expand All @@ -416,6 +422,23 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI
this.appendFadeout(event);
}

private appendAddIcon(event:CalendarViewEvent) {
if (!event.el.classList.contains(ADD_ENTRY_CLASS_NAME)) {
return;
}

let addIcon = document.createElement('div');
addIcon.classList.add(ADD_ICON_CLASS_NAME);
addIcon.innerText = '+';
event.el.append(addIcon);
}

private appendSum(event:CalendarViewEvent) {
if (event.event.extendedProps.sum) {
event.el.append(event.event.extendedProps.sum);
}
}

private addTooltip(event:CalendarViewEvent) {
if (this.browserDetector.isMobile) {
return;
Expand Down
Expand Up @@ -167,7 +167,7 @@

# The add time entry event is invisible
within entries_area.area do
find(".fc-content-skeleton td:nth-of-type(5) .fc-event-container .te-calendar--add-entry", visible: false).click
find(".fc-content-skeleton td:nth-of-type(5) .te-calendar--add-entry", visible: false).click
end

expect(page)
Expand Down

0 comments on commit 237558a

Please sign in to comment.