Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 2x 1x 1x 1x 1x 1x 1x 8x | import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { Observable } from 'rxjs';
import { CostCenter, CostCenterBase } from 'ish-core/models/cost-center/cost-center.model';
import { markAsDirtyRecursive } from 'ish-shared/forms/utils/form-utils';
import { OrganizationManagementFacade } from '../../facades/organization-management.facade';
@Component({
selector: 'ish-cost-center-edit-page',
templateUrl: './cost-center-edit-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CostCenterEditPageComponent implements OnInit {
loading$: Observable<boolean>;
costCenter$: Observable<CostCenter>;
private submitted = false;
form = new UntypedFormGroup({});
constructor(private organizationManagementFacade: OrganizationManagementFacade) {}
ngOnInit() {
this.loading$ = this.organizationManagementFacade.costCentersLoading$;
this.costCenter$ = this.organizationManagementFacade.selectedCostCenter$;
}
submitForm(cc: CostCenter) {
if (this.form.invalid) {
this.submitted = true;
markAsDirtyRecursive(this.form);
return;
}
const formValue = this.form.value;
const costCenter: CostCenterBase = {
id: cc.id,
costCenterId: formValue.costCenterId,
name: formValue.name,
budget: { value: formValue.budgetValue, currency: cc.budget.currency, type: 'Money' },
budgetPeriod: formValue.budgetPeriod,
costCenterOwner: { login: formValue.costCenterManager },
active: formValue.active,
};
this.organizationManagementFacade.updateCostCenter(costCenter);
}
get formDisabled() {
return this.form.invalid && this.submitted;
}
}
|