Skip to content

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

Don't output onChange when using writeValue

Oliver Günther03c465c0e73d
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index e9e19d56ca8..7411a48bd53 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -174,9 +174,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
private dateUpdates$ = new Subject<FieldUpdates>();
- // We're loading relations and don't want anything to fire beforehand
- private initialized = false;
-
private dateUpdateRequests$ = this
.dateUpdates$
.pipe(
@@ -223,7 +220,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
.subscribe((date) => {
this.initializeDatepicker(date);
this.onDataChange();
- this.initialized = true;
});
this
@@ -284,11 +280,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
}
changeNonWorkingDays():void {
- // The spot-toggle fires on initializing
- if (!this.initialized) {
- return;
- }
-
this.initializeDatepicker();
// Resent the current start and duration so that the end date is calculated
diff --git a/frontend/src/app/spot/components/toggle/toggle.component.html b/frontend/src/app/spot/components/toggle/toggle.component.html
index 54244706aaa..3d21dd369cf 100644
--- a/frontend/src/app/spot/components/toggle/toggle.component.html
+++ b/frontend/src/app/spot/components/toggle/toggle.component.html
@@ -9,7 +9,8 @@
type="radio"
[name]="name"
[value]="option.value"
- [(ngModel)]="value"
+ [ngModel]="value"
+ (ngModelChange)="onToggle($event)"
/>
{{ option.title }}
</label>
diff --git a/frontend/src/app/spot/components/toggle/toggle.component.ts b/frontend/src/app/spot/components/toggle/toggle.component.ts
index f00e700e129..faf86ae4ef6 100644
--- a/frontend/src/app/spot/components/toggle/toggle.component.ts
+++ b/frontend/src/app/spot/components/toggle/toggle.component.ts
@@ -34,22 +34,18 @@ export class SpotToggleComponent<T> implements ControlValueAccessor {
@Input() name = `spot-toggle-${+(new Date())}`;
- @Input('value') public _value:T;
+ @Input() public value:T;
- public get value():T {
- return this._value;
+ writeValue(value:T):void {
+ this.value = value;
}
- public set value(value:T) {
- this._value = value;
+ onToggle(value:T):void {
+ this.writeValue(value);
this.onChange(value);
this.onTouched(value);
}
- writeValue(value:T):void {
- this.value = value;
- }
-
onChange = (_:T):void => {};
onTouched = (_:T):void => {};