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
[42880] use cellNames hook for adding the non-working day classes
Oliver Günther7a8a5150410e
diff --git a/frontend/src/app/core/config/configuration.service.ts b/frontend/src/app/core/config/configuration.service.tsindex ceb148a222f..21ff2d98694 100644--- a/frontend/src/app/core/config/configuration.service.ts+++ b/frontend/src/app/core/config/configuration.service.ts@@ -30,6 +30,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';import { ConfigurationResource } from 'core-app/features/hal/resources/configuration-resource';import * as moment from 'moment';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';+import { WeekdayService } from 'core-app/core/days/weekday.service';@Injectable({ providedIn: 'root' })export class ConfigurationService {@@ -40,64 +41,73 @@ export class ConfigurationService {public initialized:Promise<boolean>;- public constructor(readonly I18n:I18nService,- readonly apiV3Service:ApiV3Service) {- this.initialized = this.loadConfiguration().then(() => true).catch(() => false);- }-- public commentsSortedInDescendingOrder() {+ public constructor(+ readonly I18n:I18nService,+ readonly apiV3Service:ApiV3Service,+ readonly weekdayService:WeekdayService,+ ) {+ this.initialized = Promise+ .all([+ this.loadConfiguration(),+ this.weekdayService.loadWeekdays().toPromise(),+ ])+ .then(() => true)+ .catch(() => false);+ }++ public commentsSortedInDescendingOrder():boolean {return this.userPreference('commentSortDescending');}- public warnOnLeavingUnsaved() {+ public warnOnLeavingUnsaved():boolean {return this.userPreference('warnOnLeavingUnsaved');}- public autoHidePopups() {+ public autoHidePopups():boolean {return this.userPreference('autoHidePopups');}- public isTimezoneSet() {+ public isTimezoneSet():boolean {return !!this.timezone();}public timezone():string {- return this.userPreference('timeZone') as string;+ return this.userPreference('timeZone');}- public isDirectUploads() {+ public isDirectUploads():boolean {return !!this.prepareAttachmentURL;}- public get prepareAttachmentURL() {- return _.get(this.configuration, ['prepareAttachment', 'href']);+ public get prepareAttachmentURL():string {+ return _.get(this.configuration, ['prepareAttachment', 'href']) as string;}- public get maximumAttachmentFileSize() {+ public get maximumAttachmentFileSize():number {return this.systemPreference('maximumAttachmentFileSize');}- public get perPageOptions() {+ public get perPageOptions():number[] {return this.systemPreference('perPageOptions');}- public dateFormatPresent() {+ public dateFormatPresent():boolean {return !!this.systemPreference('dateFormat');}- public dateFormat() {+ public dateFormat():string {return this.systemPreference('dateFormat');}- public timeFormatPresent() {+ public timeFormatPresent():boolean {return !!this.systemPreference('timeFormat');}- public timeFormat() {+ public timeFormat():string {return this.systemPreference('timeFormat');}- public startOfWeekPresent() {+ public startOfWeekPresent():boolean {return !!this.systemPreference('startOfWeek');}@@ -119,11 +129,11 @@ export class ConfigurationService {});}- private userPreference(pref:string) {- return _.get(this.configuration, ['userPreferences', pref]);+ private userPreference<T>(pref:string):T {+ return _.get(this.configuration, ['userPreferences', pref]) as T;}- private systemPreference(pref:string) {- return _.get(this.configuration, pref);+ private systemPreference<T>(pref:string):T {+ return _.get(this.configuration, pref) as T;}}diff --git a/frontend/src/app/features/calendar/op-calendar.service.ts b/frontend/src/app/features/calendar/op-calendar.service.tsindex 1b628792edf..08bee9c349a 100644--- a/frontend/src/app/features/calendar/op-calendar.service.ts+++ b/frontend/src/app/features/calendar/op-calendar.service.ts@@ -12,8 +12,6 @@ export class OpCalendarService extends UntilDestroyedMixin {resizeObs:ResizeObserver;- weekdaysPromise = this.weekdayService.loadWeekdays().toPromise();-constructor(readonly weekdayService:WeekdayService,) {@@ -32,12 +30,11 @@ export class OpCalendarService extends UntilDestroyedMixin {this.resizeObs.observe(v.nativeElement);}- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types- async applyNonWorkingDay(data:{ date?:Date, el:HTMLElement }) {- await this.weekdaysPromise;-- if (data.date && this.weekdayService.isNonWorkingDay(data.date)) {- data.el.classList.add('fc-non-working-day');+ applyNonWorkingDay({ date }:{ date?:Date }):string[] {+ if (date && this.weekdayService.isNonWorkingDay(date)) {+ return ['fc-non-working-day'];}++ return [];}}diff --git a/frontend/src/app/features/calendar/op-work-packages-calendar.service.ts b/frontend/src/app/features/calendar/op-work-packages-calendar.service.tsindex f22445e0e61..789964d97a9 100644--- a/frontend/src/app/features/calendar/op-work-packages-calendar.service.ts+++ b/frontend/src/app/features/calendar/op-work-packages-calendar.service.ts@@ -5,12 +5,13 @@ import {import {CalendarOptions,DatesSetArg,+ DayCellContentArg,DayCellMountArg,- DayHeaderMountArg,+ DayHeaderContentArg,EventApi,EventDropArg,- SlotLabelMountArg,- SlotLaneMountArg,+ SlotLabelContentArg,+ SlotLaneContentArg,} from '@fullcalendar/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { ConfigurationService } from 'core-app/core/config/configuration.service';@@ -59,7 +60,7 @@ export interface CalendarViewEvent {// The CalenderOptions typings are missing daygrid hooksinterface CalendarOptionsWithDayGrid extends CalendarOptions {- dayGridDidMount:(data:DayCellMountArg) => void;+ dayGridClassNames:(data:DayCellMountArg) => void;}@Injectable()@@ -122,7 +123,7 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {if (this.isMilestone(workPackage)) {return workPackage.date;}- return workPackage[`${type}Date`];+ return workPackage[`${type}Date`] as string;}isMilestone(workPackage:WorkPackageResource):boolean {@@ -325,11 +326,11 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {initialDate: this.initialDate,initialView: this.initialView,datesSet: (dates) => this.updateDateParam(dates),- dayHeaderDidMount: (data:DayHeaderMountArg) => this.calendarService.applyNonWorkingDay(data),- dayCellDidMount: (data:DayCellMountArg) => this.calendarService.applyNonWorkingDay(data),- dayGridDidMount: (data:DayCellMountArg) => this.calendarService.applyNonWorkingDay(data),- slotLaneDidMount: (data:SlotLaneMountArg) => this.calendarService.applyNonWorkingDay(data),- slotLabelDidMount: (data:SlotLabelMountArg) => this.calendarService.applyNonWorkingDay(data),+ dayHeaderClassNames: (data:DayHeaderContentArg) => this.calendarService.applyNonWorkingDay(data),+ dayCellClassNames: (data:DayCellContentArg) => this.calendarService.applyNonWorkingDay(data),+ dayGridClassNames: (data:DayCellContentArg) => this.calendarService.applyNonWorkingDay(data),+ slotLaneClassNames: (data:SlotLaneContentArg) => this.calendarService.applyNonWorkingDay(data),+ slotLabelClassNames: (data:SlotLabelContentArg) => this.calendarService.applyNonWorkingDay(data),};}diff --git a/frontend/src/app/features/hal/resources/work-package-resource.spec.ts b/frontend/src/app/features/hal/resources/work-package-resource.spec.tsindex abbfec081fa..902659f8507 100644--- a/frontend/src/app/features/hal/resources/work-package-resource.spec.ts+++ b/frontend/src/app/features/hal/resources/work-package-resource.spec.ts@@ -48,6 +48,8 @@ import { AttachmentCollectionResource } from 'core-app/features/hal/resources/atimport { OpenprojectHalModule } from 'core-app/features/hal/openproject-hal.module';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import isNewResource from 'core-app/features/hal/helpers/is-new-resource';+import { WeekdayService } from 'core-app/core/days/weekday.service';+import { of } from 'rxjs';describe('WorkPackage', () => {let halResourceService:HalResourceService;@@ -62,6 +64,10 @@ describe('WorkPackage', () => {workPackage = halResourceService.createHalResourceOfType('WorkPackage', { ...source });};+ const WeekdayServiceStub = {+ loadWeekdays: () => of(true),+ };+beforeEach(waitForAsync(() => {// noinspection JSIgnoredPromiseFromCallTestBed.configureTestingModule({@@ -73,6 +79,7 @@ describe('WorkPackage', () => {States,TimezoneService,WorkPackagesActivityService,+ { provide: WeekdayService, useValue: WeekdayServiceStub },ConfigurationService,OpenProjectFileUploadService,OpenProjectDirectFileUploadService,@@ -121,13 +128,13 @@ describe('WorkPackage', () => {expect(workPackage.canAddAttachments).toEqual(false);});- it('when the work work package has no `addAttachment` link and is not new', () => {+ it('when the work package has no `addAttachment` link and is not new', () => {workPackage.$source.id = 69;workPackage.$links.addAttachment = null as any;expect(workPackage.canAddAttachments).toEqual(false);});- it('when the work work package has an `addAttachment` link', () => {+ it('when the work package has an `addAttachment` link', () => {workPackage.$links.addAttachment = <any> _.noop;expect(workPackage.canAddAttachments).toEqual(true);});diff --git a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.spec.ts b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.spec.tsindex 4058936b63e..aed2b862dc2 100644--- a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.spec.ts+++ b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.spec.ts@@ -54,6 +54,8 @@ import { WorkPackageNotificationService } from 'core-app/features/work-packages/import { OpenProjectFileUploadService } from 'core-app/core/file-upload/op-file-upload.service';import { OpenProjectDirectFileUploadService } from 'core-app/core/file-upload/op-direct-file-upload.service';import { TimezoneService } from 'core-app/core/datetime/timezone.service';+import { WeekdayService } from 'core-app/core/days/weekday.service';+import { of } from 'rxjs';describe('WorkPackageFilterValues', () => {let resource:WorkPackageResource;@@ -65,6 +67,10 @@ describe('WorkPackageFilterValues', () => {let filters:any[];let source:any;+ const WeekdayServiceStub = {+ loadWeekdays: () => of(true),+ };+function setupTestBed() {// noinspection JSIgnoredPromiseFromCallvoid TestBed.configureTestingModule({@@ -74,6 +80,7 @@ describe('WorkPackageFilterValues', () => {],providers: [I18nService,+ { provide: WeekdayService, useValue: WeekdayServiceStub },States,IsolatedQuerySpace,HalEventsService,diff --git a/frontend/src/app/features/work-packages/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts b/frontend/src/app/features/work-packages/components/wp-table/table-pagination/wp-table-pagination.component.spec.tsindex 5aae7bbefd6..01f10f511fd 100644--- a/frontend/src/app/features/work-packages/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/table-pagination/wp-table-pagination.component.spec.ts@@ -41,6 +41,8 @@ import { OpIconComponent } from 'core-app/shared/components/icon/icon.component'import { IPaginationOptions, PaginationService } from 'core-app/shared/components/table-pagination/pagination-service';import { PaginationInstance } from 'core-app/shared/components/table-pagination/pagination-instance';import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';+import { of } from 'rxjs';+import { WeekdayService } from 'core-app/core/days/weekday.service';function setupMocks(paginationService:PaginationService) {const options:IPaginationOptions = {@@ -65,6 +67,10 @@ describe('wpTablePagination Directive', () => {beforeEach(waitForAsync(() => {window.OpenProject = new OpenProject();+ const WeekdayServiceStub = {+ loadWeekdays: () => of(true),+ };+// noinspection JSIgnoredPromiseFromCallTestBed.configureTestingModule({imports: [@@ -81,6 +87,7 @@ describe('wpTablePagination Directive', () => {PathHelperService,WorkPackageViewPaginationService,HalResourceService,+ { provide: WeekdayService, useValue: WeekdayServiceStub },ConfigurationService,IsolatedQuerySpace,I18nService,