Update cost listing
This commit is contained in:
parent
bfb9eaf87c
commit
747ad60fb1
|
@ -3,6 +3,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|||
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
|
||||
import { CostModel } from '@app/core/model/dmp/cost';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { CostEditorModel } from '../cost-editor/add-cost/add-cost.model';
|
||||
|
||||
export class ExtraPropertiesFormModel {
|
||||
public language: string;
|
||||
|
@ -10,7 +11,7 @@ export class ExtraPropertiesFormModel {
|
|||
public visible: boolean;
|
||||
public publicDate: Date;
|
||||
public contact: string;
|
||||
public costs: CostModel[] = [];
|
||||
public costs: CostEditorModel[] = [];
|
||||
|
||||
fromModel(item: any): ExtraPropertiesFormModel {
|
||||
this.language = item.language;
|
||||
|
@ -26,15 +27,25 @@ export class ExtraPropertiesFormModel {
|
|||
|
||||
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||
if (context == null) { context = this.createValidationContext(); }
|
||||
|
||||
const formBuilder = new FormBuilder();
|
||||
const formGroup = new FormBuilder().group({
|
||||
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
|
||||
license: [{ value: this.license, disabled: disabled }, context.getValidation('license').validators],
|
||||
visible: [{ value: this.visible, disabled: disabled }, context.getValidation('visible').validators],
|
||||
publicDate: [{ value: this.publicDate, disabled: disabled }, context.getValidation('publicDate').validators],
|
||||
contact: [{ value: this.contact, disabled: disabled }, context.getValidation('contact').validators],
|
||||
costs: [{ value: this.costs, disabled: disabled }, context.getValidation('costs').validators]
|
||||
// costs: [{ value: this.costs, disabled: disabled }, context.getValidation('costs').validators]
|
||||
});
|
||||
|
||||
const costArray = new Array<FormGroup>();
|
||||
//if (this.externalDatasets && this.externalDatasets.length > 0) {
|
||||
this.costs.forEach(item => {
|
||||
costArray.push(item.buildForm(context.getValidation('externalDatasets').descendantValidations, disabled));
|
||||
});
|
||||
// } else {
|
||||
// //externalDatasetsFormArray.push(new ExternalDatasetModel().buildForm(context.getValidation('externalDatasets').descendantValidations, disabled));
|
||||
// }
|
||||
formGroup.addControl('costs', formBuilder.array(costArray));
|
||||
return formGroup;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { FormGroup, FormArray } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
||||
|
@ -27,6 +27,7 @@ import { LanguageInfoService } from '@app/core/services/culture/language-info-se
|
|||
import { LanguageInfo } from '@app/core/model/language-info';
|
||||
import { LicenseCriteria } from '@app/core/query/license/license-criteria';
|
||||
import { AddCostComponent } from '../cost-editor/add-cost/add-cost.component';
|
||||
import { CostEditorModel } from '../cost-editor/add-cost/add-cost.model';
|
||||
|
||||
interface Visible {
|
||||
value: boolean;
|
||||
|
@ -271,7 +272,9 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
|||
if (result) {
|
||||
const costsArray = this.formGroup.get('extraProperties').get('costs').value || [];
|
||||
costsArray.push(result);
|
||||
this.formGroup.get('extraProperties').get('costs').setValue(costsArray);
|
||||
let costeditModel: CostEditorModel = new CostEditorModel();
|
||||
costeditModel = costeditModel.fromModel(result);
|
||||
(<FormArray>this.formGroup.get('extraProperties').get('costs')).push(costeditModel.buildForm(null, true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue