Working build with a workaround for the date modal scheduling and relations services

feature/42358-standardise-date-pickers
Benjamin Bädorf 2 years ago
parent 9a923edc36
commit 050aa94c4d
No known key found for this signature in database
GPG Key ID: 069CA2D117AB5CCF
  1. 5
      frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
  2. 7
      frontend/src/app/shared/components/datepicker/services/date-modal-relations.service.ts
  3. 4
      frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.ts
  4. 1
      frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts

@ -80,6 +80,7 @@ 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';
export type DateKeys = 'start'|'end';
export type DateFields = DateKeys|'duration';
@ -253,6 +254,10 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
) {
super(locals, cdRef, elementRef);
this.changeset = locals.changeset as ResourceChangeset;
this.dateModalScheduling.setChangeset(this.changeset as WorkPackageChangeset);
this.dateModalRelations.setChangeset(this.changeset as WorkPackageChangeset);
this.htmlId = `wp-datepicker-${locals.fieldName as string}`;
this.scheduleManually = !!this.changeset.value('scheduleManually');

@ -47,6 +47,7 @@ import {
combineLatest,
Observable,
of,
Subject,
} from 'rxjs';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
@ -55,13 +56,15 @@ import { parseDate } from 'core-app/shared/components/datepicker/helpers/date-mo
@Injectable()
export class DateModalRelationsService {
private changeset$:Subject<WorkPackageChangeset> = new Subject();
private changeset:WorkPackageChangeset;
setChangeset(changeset:WorkPackageChangeset) {
this.changeset$.next(changeset);
this.changeset = changeset;
}
precedingWorkPackages$:Observable<{ id:string, dueDate?:string, date?:string }[]> = of(this.changeset)
precedingWorkPackages$:Observable<{ id:string, dueDate?:string, date?:string }[]> = this.changeset$
.pipe(
filter((changeset) => !isNewResource(changeset.pristineResource)),
switchMap((changeset) => this
@ -80,7 +83,7 @@ export class DateModalRelationsService {
shareReplay(1),
);
followingWorkPackages$:Observable<{ id:string }[]> = of(this.changeset)
followingWorkPackages$:Observable<{ id:string }[]> = this.changeset$
.pipe(
filter((changeset) => !isNewResource(changeset.pristineResource)),
switchMap((changeset) => this

@ -67,6 +67,7 @@ import {
} 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';
@Component({
selector: 'op-single-date-form',
@ -123,6 +124,9 @@ export class OpSingleDateFormComponent extends UntilDestroyedMixin implements Af
readonly deviceService:DeviceService,
) {
super();
dateModalRelations.setChangeset(this.changeset as WorkPackageChangeset);
dateModalScheduling.setChangeset(this.changeset as WorkPackageChangeset);
}
ngAfterViewInit():void {

@ -69,7 +69,6 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent im
}
public showDatePickerModal():void {
this.injector.set({ changeset: this.change, fieldName: this.name },
/*
const component = this.change.schema.isMilestone ? SingleDateModalComponent : MultiDateModalComponent;
this.opModalService.show<SingleDateModalComponent|MultiDateModalComponent>(

Loading…
Cancel
Save