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 | 1x 1x 1x 1x 1x 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 { 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-create-page',
templateUrl: './cost-center-create-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CostCenterCreatePageComponent implements OnInit {
loading$: Observable<boolean>;
private submitted = false;
form = new UntypedFormGroup({});
constructor(private organizationManagementFacade: OrganizationManagementFacade) {}
ngOnInit() {
this.loading$ = this.organizationManagementFacade.costCentersLoading$;
}
submitForm() {
if (this.form.invalid) {
this.submitted = true;
markAsDirtyRecursive(this.form);
return;
}
const formValue = this.form.value;
const costCenter: CostCenterBase = {
id: undefined,
costCenterId: formValue.costCenterId,
name: formValue.name,
budget: { value: formValue.budgetValue, currency: formValue.currency, type: 'Money' },
budgetPeriod: formValue.budgetPeriod,
costCenterOwner: { login: formValue.costCenterManager },
active: formValue.active,
};
this.organizationManagementFacade.addCostCenter(costCenter);
}
get formDisabled() {
return this.form.invalid && this.submitted;
}
}
|