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
[#54378] show calendar widget date in configured format
Tobias Dillmann7fc67f7ea2d8
diff --git a/frontend/src/app/features/calendar/op-calendar.service.ts b/frontend/src/app/features/calendar/op-calendar.service.tsindex a9f58521b61..1c4337f1a06 100644--- a/frontend/src/app/features/calendar/op-calendar.service.ts+++ b/frontend/src/app/features/calendar/op-calendar.service.ts@@ -8,6 +8,7 @@ import { WeekdayService } from 'core-app/core/days/weekday.service';import { DayResourceService } from 'core-app/core/state/days/day.service';import { IDay } from 'core-app/core/state/days/day.model';import * as moment from 'moment-timezone';+import { ConfigurationService } from 'core-app/core/config/configuration.service';@Injectable()export class OpCalendarService extends UntilDestroyedMixin {@@ -18,6 +19,7 @@ export class OpCalendarService extends UntilDestroyedMixin {constructor(readonly weekdayService:WeekdayService,readonly dayService:DayResourceService,+ readonly configurationService:ConfigurationService,) {super();}@@ -31,7 +33,7 @@ export class OpCalendarService extends UntilDestroyedMixin {this.resizeObs = new ResizeObserver(() => this.resize$.next());}- this.resizeObs.observe(v.nativeElement);+ this.resizeObs.observe(v.nativeElement as Element);}applyNonWorkingDay({ date }:{ date?:Date }, nonWorkingDays:IDay[]):string[] {@@ -42,4 +44,14 @@ export class OpCalendarService extends UntilDestroyedMixin {}return [];}++ dayHeaderContent({ date }:{ date?:Date }):string {+ const utcDate = moment(date).utc();++ // If no date format is configured, use a very unambiguous one as default+ const configuredDateFormat = this.configurationService.dateFormatPresent()+ ? this.configurationService.dateFormat() : 'YYYY-MM-DD';++ return utcDate.format(`ddd ${configuredDateFormat}`);+ }}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 c8569e0e911..96988c58df0 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@@ -124,7 +124,7 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {if (this.isMilestone(workPackage)) {return workPackage.date;}- return workPackage[`${type}Date`] as string;+ return workPackage[`${type}Date`];}isMilestone(workPackage:WorkPackageResource):boolean {@@ -133,11 +133,13 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {warnOnTooManyResults(collection:WorkPackageCollectionResource, isStatic = false):void {if (collection.count < collection.total) {- this.tooManyResultsText = this.I18n.t('js.calendar.too_many',+ this.tooManyResultsText = this.I18n.t(+ 'js.calendar.too_many',{count: collection.total,max: OpWorkPackagesCalendarService.MAX_DISPLAYED,- });+ },+ );} else {this.tooManyResultsText = null;}@@ -180,7 +182,6 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {// 3. We are already loaded and are refetching data (for changed dates, e.g.)let queryProps:string|undefined;-if (this.initializingWithQuery) {// This is the case on initially loading the calendar with a query_id present in the url params but no// query props to overwrite the query settings.@@ -201,7 +202,7 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {// There might also be a query_id but the settings persisted in it are overwritten by the props.if (this.urlParams.query_props) {// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment- const oldQueryProps:{ [key:string]:unknown } = JSON.parse(this.urlParams.query_props);+ const oldQueryProps:{ [key:string]:unknown } = JSON.parse(this.urlParams.query_props as string);// Update the date period of the calendar in the filterconst newQueryProps = {@@ -231,9 +232,9 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {return Promise.all([this.wpListService- .fromQueryParams({ query_id: queryId, query_props: queryProps, }, projectIdentifier || undefined)+ .fromQueryParams({ query_id: queryId, query_props: queryProps }, projectIdentifier || undefined).toPromise(),- ])+ ]);}public generateQueryProps(@@ -360,6 +361,7 @@ export class OpWorkPackagesCalendarService extends UntilDestroyedMixin {dayGridClassNames: (data:DayCellContentArg) => this.calendarService.applyNonWorkingDay(data, this.nonWorkingDays),slotLaneClassNames: (data:SlotLaneContentArg) => this.calendarService.applyNonWorkingDay(data, this.nonWorkingDays),slotLabelClassNames: (data:SlotLabelContentArg) => this.calendarService.applyNonWorkingDay(data, this.nonWorkingDays),+ dayHeaderContent: (data:DayHeaderContentArg) => this.calendarService.dayHeaderContent(data),};}