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 { BackendErrorValidator } from '@common/forms/validation/custom-validator';
|
||||||
import { CostModel } from '@app/core/model/dmp/cost';
|
import { CostModel } from '@app/core/model/dmp/cost';
|
||||||
import { isNullOrUndefined } from 'util';
|
import { isNullOrUndefined } from 'util';
|
||||||
|
import { CostEditorModel } from '../cost-editor/add-cost/add-cost.model';
|
||||||
|
|
||||||
export class ExtraPropertiesFormModel {
|
export class ExtraPropertiesFormModel {
|
||||||
public language: string;
|
public language: string;
|
||||||
|
@ -10,7 +11,7 @@ export class ExtraPropertiesFormModel {
|
||||||
public visible: boolean;
|
public visible: boolean;
|
||||||
public publicDate: Date;
|
public publicDate: Date;
|
||||||
public contact: string;
|
public contact: string;
|
||||||
public costs: CostModel[] = [];
|
public costs: CostEditorModel[] = [];
|
||||||
|
|
||||||
fromModel(item: any): ExtraPropertiesFormModel {
|
fromModel(item: any): ExtraPropertiesFormModel {
|
||||||
this.language = item.language;
|
this.language = item.language;
|
||||||
|
@ -26,15 +27,25 @@ export class ExtraPropertiesFormModel {
|
||||||
|
|
||||||
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||||
if (context == null) { context = this.createValidationContext(); }
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
const formBuilder = new FormBuilder();
|
||||||
const formGroup = new FormBuilder().group({
|
const formGroup = new FormBuilder().group({
|
||||||
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
|
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
|
||||||
license: [{ value: this.license, disabled: disabled }, context.getValidation('license').validators],
|
license: [{ value: this.license, disabled: disabled }, context.getValidation('license').validators],
|
||||||
visible: [{ value: this.visible, disabled: disabled }, context.getValidation('visible').validators],
|
visible: [{ value: this.visible, disabled: disabled }, context.getValidation('visible').validators],
|
||||||
publicDate: [{ value: this.publicDate, disabled: disabled }, context.getValidation('publicDate').validators],
|
publicDate: [{ value: this.publicDate, disabled: disabled }, context.getValidation('publicDate').validators],
|
||||||
contact: [{ value: this.contact, disabled: disabled }, context.getValidation('contact').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;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
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 { MatDialog } from '@angular/material/dialog';
|
||||||
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
||||||
import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile';
|
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 { LanguageInfo } from '@app/core/model/language-info';
|
||||||
import { LicenseCriteria } from '@app/core/query/license/license-criteria';
|
import { LicenseCriteria } from '@app/core/query/license/license-criteria';
|
||||||
import { AddCostComponent } from '../cost-editor/add-cost/add-cost.component';
|
import { AddCostComponent } from '../cost-editor/add-cost/add-cost.component';
|
||||||
|
import { CostEditorModel } from '../cost-editor/add-cost/add-cost.model';
|
||||||
|
|
||||||
interface Visible {
|
interface Visible {
|
||||||
value: boolean;
|
value: boolean;
|
||||||
|
@ -271,7 +272,9 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
if (result) {
|
if (result) {
|
||||||
const costsArray = this.formGroup.get('extraProperties').get('costs').value || [];
|
const costsArray = this.formGroup.get('extraProperties').get('costs').value || [];
|
||||||
costsArray.push(result);
|
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