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
Merge branch 'dev' into feature/42358-standardise-date-pickers-2
Benjamin Bädorf48420dc4b8a6
diff --cc frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.tsindex 1fca9847331,036d9ad1deb..c56c74d6cf8--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts@@@ -74,12 -77,7 +73,13 @@@ importimport { WeekdayService } from 'core-app/core/days/weekday.service';import { FocusHelperService } from 'core-app/shared/directives/focus/focus-helper';import { DeviceService } from 'core-app/core/browser/device.service';+import { DatePicker } from '../datepicker';+import DateOption = flatpickr.Options.DateOption;+import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset';+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import isNewResource from 'core-app/features/hal/helpers/is-new-resource';++import { DateModalSchedulingService } from '../services/date-modal-scheduling.service';export type DateKeys = 'start'|'end';export type DateFields = DateKeys|'duration';@@@ -108,28 -102,27 +108,28 @@@ export type FieldUpdateschangeDetection: ChangeDetectionStrategy.OnPush,encapsulation: ViewEncapsulation.None,providers: [- DateModalSchedulingService,DateModalRelationsService,++ DateModalSchedulingService,],})-export class MultiDateModalComponent extends OpModalComponent implements AfterViewInit {- @InjectField() I18n!:I18nService;+export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements AfterViewInit, OnInit {+ @HostBinding('class.op-datepicker-modal') className = true;- @InjectField() timezoneService:TimezoneService;+ @HostBinding('class.op-datepicker-modal_wide') classNameWide = true;- @InjectField() halEditing:HalResourceEditingService;+ @ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;- @InjectField() dateModalRelations:DateModalRelationsService;+ @ViewChild('durationField', { read: ElementRef }) durationField:ElementRef<HTMLElement>;- @InjectField() deviceService:DeviceService;+ @ViewChild('flatpickrTarget') flatpickrTarget:ElementRef;- @InjectField() weekdayService:WeekdayService;+ @Input() changeset:ResourceChangeset;- @InjectField() focusHelper:FocusHelperService;+ @Input() fieldName:string = '';- @ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;+ @Output() cancel = new EventEmitter();- @ViewChild('durationField', { read: ElementRef }) durationField:ElementRef<HTMLElement>;+ @Output() save = new EventEmitter();text = {save: this.I18n.t('js.button_save'),@@@ -304,15 -286,13 +304,12 @@@}changeSchedulingMode():void {- console.log('change scheduling');- this.initializeDatepicker();-// If removing manual scheduling on parent, reset ignoreNWD to original valueif (this.scheduleManually === false && !this.ignoreNonWorkingDaysWritable) {this.ignoreNonWorkingDays = !!this.changeset.value('ignoreNonWorkingDays');- console.log(this.ignoreNonWorkingDays, this.scheduleManually);}-+ this.initializeDatepicker();this.cdRef.detectChanges();}diff --cc frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.htmlindex a5f367a1da1,00000000000..f956236efe2mode 100644,000000..100644--- a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html+++ b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html@@@ -1,70 -1,0 +1,74 @@@+<form+ class="spot-container"+ data-qa-selector="op-datepicker-modal"+ [attr.id]="htmlId"+ #modalContainer+ data-indicator-name="modal"+ (submit)="doSave($event)"+ tabindex="0"+ cdkFocusInitial+ cdkTrapFocus+ [cdkTrapFocusAutoCapture]="true"+>+ <op-datepicker-banner></op-datepicker-banner>++ <div class="spot-container">- <div class="op-datepicker-modal--toggle-actions-container">- <op-datepicker-working-days-toggle- name="ignoreNonWorkingDays"- [(ngModel)]="ignoreNonWorkingDays"- (ngModelChange)="changeNonWorkingDays()"- ></op-datepicker-working-days-toggle>- </div>++ <op-datepicker-scheduling-toggle++ name="scheduleManually"++ [(ngModel)]="scheduleManually"++ (ngModelChange)="changeSchedulingMode()"++ ></op-datepicker-scheduling-toggle>++++ <op-datepicker-working-days-toggle++ name="ignoreNonWorkingDays"++ [(ngModel)]="ignoreNonWorkingDays"++ (ngModelChange)="changeNonWorkingDays()"++ ></op-datepicker-working-days-toggle>++ <spot-form-field+ [label]="text.date"+ >+ <spot-text-field+ slot="input"+ name="date"+ class="op-datepicker-modal--date-field"- [ngClass]="{ 'op-datepicker-modal--date-field_current': this.dateModalScheduling.isSchedulable }"++ [ngClass]="{ 'op-datepicker-modal--date-field_current': isSchedulable }"+ [(ngModel)]="date"+ (ngModelChange)="dateChangedManually$.next()"+ [showClearButton]="true"+ ></spot-text-field>+ <button+ slot="action"+ type="button"+ class="spot-link"- [ngClass]="{ 'op-datepicker-modal--hidden-link': !dateModalScheduling.isSchedulable }"++ [ngClass]="{ 'op-datepicker-modal--hidden-link': !isSchedulable }"+ (click)="setToday()"+ [textContent]="text.today">+ </button>+ </spot-form-field>++ <input+ #flatpickrTarget+ id="flatpickr-input"+ hidden+ >+ </div>++ <div class="spot-action-bar">+ <div class="spot-action-bar--right">+ <button+ type="button"+ (click)="doCancel()"+ class="op-datepicker-modal--action spot-modal--cancel-button button button_no-margin spot-action-bar--action"+ data-qa-selector="op-datepicker-modal--action"+ [textContent]="text.cancel"+ ></button>+ <button+ type="submit"+ class="op-datepicker-modal--action button button_no-margin -highlight spot-action-bar--action"+ data-qa-selector="op-datepicker-modal--action"+ [textContent]="text.save"+ ></button>+ </div>+ </div>+</form>diff --cc frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.tsindex 9cfb602055e,4ae08a58ebe..b0fba98612c--- a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts+++ b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts@@@ -65,36 -70,27 +64,37 @@@ importsetDates,validDate,} from 'core-app/shared/components/datepicker/helpers/date-modal.helpers';-import { DeviceService } from 'core-app/core/browser/device.service';+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset';+import isNewResource from 'core-app/features/hal/helpers/is-new-resource';++import { DateModalSchedulingService } from '../services/date-modal-scheduling.service';@Component({- templateUrl: './single-date.modal.html',- styleUrls: ['../styles/datepicker.modal.sass', '../styles/datepicker_mobile.modal.sass'],+ selector: 'op-wp-single-date-form',+ templateUrl: './wp-single-date-form.component.html',+ styleUrls: [+ '../styles/datepicker.modal.sass',+ '../styles/datepicker_mobile.modal.sass',+ ],changeDetection: ChangeDetectionStrategy.OnPush,encapsulation: ViewEncapsulation.None,providers: [- DateModalSchedulingService,DateModalRelationsService,++ DateModalSchedulingService,],})-export class SingleDateModalComponent extends OpModalComponent implements AfterViewInit {- @InjectField() I18n!:I18nService;+export class OpWpSingleDateFormComponent extends UntilDestroyedMixin implements AfterViewInit, OnInit {+ @HostBinding('class.op-datepicker-modal') className = true;- @InjectField() timezoneService:TimezoneService;+ @Input('value') value = '';- @InjectField() halEditing:HalResourceEditingService;+ @Input() changeset:ResourceChangeset;- @InjectField() dateModalRelations:DateModalRelationsService;+ @Output() cancel = new EventEmitter();- @InjectField() deviceService:DeviceService;+ @Output() save = new EventEmitter();++ @ViewChild('flatpickrTarget') flatpickrTarget:ElementRef;@ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;@@@ -106,6 -102,10 +106,8 @@@today: this.I18n.t('js.label_today'),};- onDataUpdated = new EventEmitter<string>();-+ scheduleManually = false;+ignoreNonWorkingDays = false;htmlId = '';@@@ -177,8 -187,31 +179,24 @@@});}+ changeSchedulingMode():void {+ this.initializeDatepicker();+ this.cdRef.detectChanges();+ }++ /**+ * Returns whether the user can alter the dates of the work package.+ */+ get isSchedulable():boolean {+ return this.scheduleManually || !this.dateModalRelations.isParent;+ }++ isDayDisabled(dayElement:DayElement, minimalDate?:Date|null):boolean {+ return !this.isSchedulable || (!this.scheduleManually && !!minimalDate && dayElement.dateObj <= minimalDate);+ }+changeNonWorkingDays():void {this.initializeDatepicker();-- // If we're single date, update the date- if (!this.ignoreNonWorkingDays && this.date) {- // Resent the current start and end dates so duration can be calculated again.- this.dateUpdates$.next(this.date);- }-this.cdRef.detectChanges();}@@@ -242,7 -294,8 +260,7 @@@dayElem,this.ignoreNonWorkingDays,await this.datePickerInstance?.isNonWorkingDay(dayElem.dateObj),- this.dateModalScheduling.isDayDisabled(dayElem, minimalDate),- minimalDate,+ this.isDayDisabled(dayElem, minimalDate),);},},