Fix issue with RDA Common Standards

This commit is contained in:
George Kalampokis 2021-10-12 18:05:38 +03:00
parent 29919f981a
commit 6de12fd0e8
2 changed files with 82 additions and 83 deletions

View File

@ -18,7 +18,7 @@
</ul>
</div>
</div>
<div class="row">
<!-- <mat-form-field class="col">
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.ID' | translate}}" type="text" [formControl]="this.form.get('id')"
@ -36,15 +36,15 @@
<mat-option [value]="viewStyleEnum.BooleanDecision">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.BooleanDecision)}}</mat-option>
<mat-option [value]="viewStyleEnum.RadioBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.RadioBox)}}</mat-option>
<mat-option [value]="viewStyleEnum.CheckBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.CheckBox)}}</mat-option>
<mat-option [value]="viewStyleEnum.ComboBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.ComboBox)}}</mat-option>
<mat-divider></mat-divider>
<mat-option [value]="viewStyleEnum.DatePicker">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.DatePicker)}}</mat-option>
<mat-option [value]="viewStyleEnum.Currency">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.Currency)}}</mat-option>
<mat-divider></mat-divider>
<mat-optgroup label="APIs">
<mat-option [value]="viewStyleEnum.Registries">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.Registries)}}</mat-option>
@ -54,7 +54,7 @@
<mat-option [value]="viewStyleEnum.ExternalDatasets">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.ExternalDatasets)}}</mat-option>
<mat-option [value]="viewStyleEnum.DataRepositories">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.DataRepositories)}}</mat-option>
</mat-optgroup>
<mat-divider></mat-divider>
<mat-optgroup label="Argos Entities">
<mat-option [value]="viewStyleEnum.InternalDmpEntities">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.InternalDmpEntities)}}</mat-option>
@ -99,7 +99,7 @@
</mat-option>
<!-- TODO -->
<mat-divider></mat-divider>
<mat-option [value]="viewTypeEnum.DatePicker">
<img src="/assets/images/editor/icons/date_picker.svg" class="input_icon" alt="DatePicker icon">
{{enumUtils.toDatasetProfileViewTypeString(viewTypeEnum.DatePicker)}}
@ -167,7 +167,7 @@
<!-- <mat-error *ngIf="this.form.get('viewStyle').get('renderStyle').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> -->
<mat-error >{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<!-- <mat-error *ngIf="this.form.hasError('inputTypeNotValid')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> -->
</mat-form-field>
<!-- Combo Box -->
@ -187,7 +187,7 @@
<mat-label>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.RDA-COMMON-STANDARDS' | translate}}</mat-label>
<mat-select [formControl]="this.form.get('rdaCommonStandard')">
<mat-option>--</mat-option>
<mat-option *ngFor="let property of rdaCommonStandards" [value]="property">
<mat-option *ngFor="let property of datasetProfileService.getRDACommonStandards()" [value]="property">
{{property}}
</mat-option>
</mat-select>
@ -253,28 +253,28 @@
<div class="col-12" *ngIf="expandView && previewForm">
<span style="font-weight: bold">{{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.PREVIEW' | translate}}</span>
</div> -->
<!-- <div class="col-12">
<!-- <div class="col-12">
<mat-radio-group [(ngModel)]="showPreview">
<mat-radio-button [value]="true">Yes</mat-radio-button>
<mat-radio-button [value]="false">No</mat-radio-button>
</mat-radio-group>
</div> -->
<!--
<!--
<div class="col-12" *ngIf="showPreview">
<ng-container *ngIf="viewType === viewTypeEnum.Other else regularField">
<app-form-field [form]="previewForm" *ngIf="previewForm" [autocompleteOptions]="form.get('data').get('autoCompleteSingleDataList').getRawValue()">
</app-form-field>
</ng-container>
<ng-template #regularField>
<app-form-field [form]="previewForm" *ngIf="previewForm">
</app-form-field>
</ng-template>
</div>
<div class="col-12" *ngIf="!this.form.get('viewStyle').get('renderStyle').value">
<div class="col-12" *ngIf="!this.form.get('viewStyle').get('renderStyle').value">
<em>
{{'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.NOT-INITIALIZED' | translate}}
</em>

View File

@ -35,7 +35,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
viewType: ViewStyleType;
viewTypeEnum = ViewStyleType;
// private subject$:Subject<DatasetDescriptionFieldEditorModel> = new Subject<DatasetDescriptionFieldEditorModel>();
@Input() expandView: boolean = true;
@ -44,21 +44,21 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
@Output() delete = new EventEmitter<void>();
rdaCommonStandards = this.datasetProfileService.getRDACommonStandards();
//rdaCommonStandards = this.datasetProfileService.getRDACommonStandards(); //GK: Don't do that again. The service has a weird async behaviour.
constructor(
public enumUtils: EnumUtils,
public datasetProfileService: DatasetProfileService,
private dialog: MatDialog
) { super();
) { super();
}
isErrorState(control: FormControl, form: FormGroupDirective | NgForm): boolean {
if(this.form.get('viewStyle').untouched) return false;
return this.form.get('viewStyle').invalid;
}
@ -70,7 +70,6 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// if (this.form.get('multiplicity')) {
// if (this.form.get('multiplicity').value.min > 1 && this.form.get('multiplicity').value.max > 1) {
// this.isFieldMultiplicityEnabled = true;
@ -82,7 +81,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// this.matcher.setReference(this.form);
const type = this.form.get('viewStyle').get('renderStyle').value;
switch(type){
case DatasetProfileFieldViewStyle.BooleanDecision:
this.viewType = this.viewTypeEnum.BooleanDecision;
@ -145,7 +144,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
this.viewType = this.viewTypeEnum.Validation;
break;
}
}
// this.showPreview = true;
@ -309,7 +308,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// });
// }
// this._showPreview = value;
// }
// previewForm: FormGroup;
@ -321,18 +320,18 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// }
// this.previewForm = null;
// const fieldEditorModel = new DatasetDescriptionFieldEditorModel();
// fieldEditorModel.viewStyle= {
// renderStyle: this.form.get('viewStyle').get('renderStyle').value,
// cssClass: null
// };
// fieldEditorModel.data = (this.form.get('data') as FormGroup).getRawValue();
// fieldEditorModel.data = (this.form.get('data') as FormGroup).getRawValue();
// fieldEditorModel.value = this.form.get('defaultValue').get('value').value;
// fieldEditorModel.validationRequired = (this.form.get('validations').value as Array<ValidationType>).includes(ValidationType.Required);
// if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.CheckBox){
// fieldEditorModel.value = this.form.get('defaultValue').get('value').value === 'true';
// fieldEditorModel.value = this.form.get('defaultValue').get('value').value === 'true';
// }
// // if(this.form.get('viewStyle').get('renderStyle').value == DatasetProfileFieldViewStyle.Researchers){
// // fieldEditorModel.data = new ResearchersAutoCompleteFieldDataEditorModel().buildForm().getRawValue();
@ -362,7 +361,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
get canApplyVisibility():boolean{
switch(this.viewType){
case this.viewTypeEnum.TextArea:
case this.viewTypeEnum.FreeText:
@ -383,7 +382,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// validTicket:string;
// generatePreview(){
// const fieldEditorModel = new DatasetDescriptionFieldEditorModel();
// fieldEditorModel.viewStyle= {
// renderStyle: this.form.get('viewStyle').get('renderStyle').value,
// cssClass: null
@ -391,11 +390,11 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// fieldEditorModel.defaultValue = this.form.get('defaultValue').value;
// switch (this.form.get('viewStyle').get('renderStyle').value) {
// case DatasetProfileFieldViewStyle.TextArea:
// fieldEditorModel.data = {
// fieldEditorModel.data = {
// label: this.form.get('data').get('label').value
// };
// break;
// default:
// break;
// }
@ -405,13 +404,13 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// }
onInputTypeChange(){
const x = this.viewType;
// this.showPreview = false;
const field: Field = this.form.getRawValue();
// field.defaultValue = {type:null, value: null};
@ -425,7 +424,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// if (this.form.get('data')) {
// this.form.removeControl('data');
// }
// this.form.removeControl('defaultValue');
// const defaultValueModel = new DefaultValueEditorModel();
// this.form.addControl('defaultValue',defaultValueModel.buildForm());
@ -433,7 +432,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
switch (x) {
case this.viewTypeEnum.BooleanDecision:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.BooleanDecision)
// this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm());
@ -441,14 +440,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:""
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision;
field.data = data;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.BooleanDecision;
field.data = data;
break;
}
case this.viewTypeEnum.CheckBox:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.CheckBox)
// this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm());
@ -456,21 +455,21 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:''
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.CheckBox;
field.data = data;
break;
}
case this.viewTypeEnum.Select:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox)
// this.form.addControl('data', new WordListFieldDataEditorModel().buildForm());
// this.form.get('data').setValidators(EditorCustomValidators.atLeastOneElementListValidator('options'));
// this.form.get('data').updateValueAndValidity();
const option1 = {label:'', value:''} as FieldDataOption;
const data:WordListFieldData = {
label:'',
multiList:false,
@ -479,14 +478,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox;
field.data = data;
break;
}
case this.viewTypeEnum.Other:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.ComboBox)
// this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm()); //TODO SEE
@ -500,14 +499,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
type: DatasetProfileComboBoxType.Autocomplete
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ComboBox;
field.data = data;
break;
}
case this.viewTypeEnum.InternalDmpEntities:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.InternalDmpEntities)
// this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());//TODO TO SEE
@ -517,14 +516,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
type: DatasetProfileInternalDmpEntitiesType.Dmps
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.InternalDmpEntities;
field.data = data;
break;
}
case this.viewTypeEnum.FreeText:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.FreeText)
// this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm());
@ -532,14 +531,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:''
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.FreeText;
field.data = data;
break;
}
case this.viewTypeEnum.RadioBox:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.RadioBox)
// this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm());
@ -552,14 +551,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.RadioBox;
field.data = data;
break;
}
case this.viewTypeEnum.TextArea:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.TextArea)
// this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm());
@ -568,21 +567,21 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.TextArea;
field.data = data;
break;
}
case this.viewTypeEnum.DatePicker:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatePicker)
// this.form.addControl('data', new DatePickerDataEditorModel().buildForm());
const data: DatePickerFieldData = {
label:''
}
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatePicker;
field.data = data;
break;
@ -597,14 +596,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.ExternalDatasets;
field.data = data;
break;
}
case this.viewTypeEnum.DataRepositories:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DataRepositories)
// this.form.addControl('data', new DataRepositoriesDataEditorModel().buildForm());
@ -613,14 +612,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
multiAutoComplete: false
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DataRepositories;
field.data = data;
break;
}
case this.viewTypeEnum.Registries:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Registries)
// this.form.addControl('data', new RegistriesDataEditorModel().buildForm());
@ -629,14 +628,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
multiAutoComplete: false
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Registries;
field.data = data;
break;
}
case this.viewTypeEnum.Services:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Services)
// this.form.addControl('data', new ServicesDataEditorModel().buildForm());
@ -645,7 +644,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
multiAutoComplete: false
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Services;
field.data = data;
break;
@ -658,20 +657,20 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:''
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags;
field.data = data;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Tags;
field.data = data;
break;
}
case this.viewTypeEnum.Researchers:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Researchers)
// // this.form.addControl('data', new ResearchersDataEditorModel().buildForm()); //TODO TO ASK
// this.form.addControl('data', new ResearchersAutoCompleteFieldDataEditorModel().buildForm());
// field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers;
// field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Researchers;
const data : ResearchersAutoCompleteFieldData = {
label:'',
multiAutoComplete: false,
@ -687,7 +686,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
}
case this.viewTypeEnum.Organizations:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Organizations)
// this.form.addControl('data', new OrganizationsDataEditorModel().buildForm());
@ -695,17 +694,17 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
autoCompleteSingleDataList:[],
label:'',
multiAutoComplete: false,
} as OrganizationsFieldData; //TODO
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations;
} as OrganizationsFieldData; //TODO
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Organizations;
field.data = data;
break;
}
case this.viewTypeEnum.DatasetIdentifier:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.DatasetIdentifier)
// this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm());
@ -713,14 +712,14 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:''
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier;
field.data = data;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.DatasetIdentifier;
field.data = data;
break;
}
case this.viewTypeEnum.Currency:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Currency)
// this.form.addControl('data', new CurrencyDataEditorModel().buildForm());
@ -728,13 +727,13 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
label:''
}
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency;
field.viewStyle.renderStyle = DatasetProfileFieldViewStyle.Currency;
field.data = data;
break;
}
case this.viewTypeEnum.Validation:{
// this.form.get('viewStyle').get('renderStyle').setValue(DatasetProfileFieldViewStyle.Validation)
// this.form.addControl('data', new ValidationDataEditorModel().buildForm());
@ -753,7 +752,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
// this.form.get('viewStyle').get('renderStyle').updateValueAndValidity();
// this.form.updateValueAndValidity();
const form = (new FieldEditorModel).fromModel(field).buildForm();
@ -770,7 +769,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
fields.insert(index, form);
this.form = form;
}
// setTimeout(() => { //TODO
@ -780,7 +779,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
toggleRequired(event:MatSlideToggleChange){
let validationsControl = this.form.get('validations') as FormControl;
let validations: Array<ValidationType> = validationsControl.value;
@ -802,16 +801,16 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
get isRequired(){
let validationsControl = this.form.get('validations') as FormControl;
let validations: Array<ValidationType> = validationsControl.value;
if(validations.includes(ValidationType.Required)){
return true;
}
return false;
}
onDelete(){
this.delete.emit();
}
}
}