Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

# Conflicts:
#	dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html
#	dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html
#	dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.ts
#	dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts
#	dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html
#	dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.ts
#	dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.html
#	dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.component.ts
#	dmp-frontend/src/app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service.ts
This commit is contained in:
Diamantis Tziotzios 2019-01-28 15:51:33 +02:00
commit 196435d069
18 changed files with 183 additions and 27 deletions

View File

@ -74,8 +74,8 @@ public class DatasetProfileController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) throws XPathExpressionException {
eu.eudat.data.entities.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(dataset.getProfile().getDefinition(), lookupItem.getCriteria().getFieldID());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID());
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
List<Tuple<String, String>> items = DatasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
return ResponseEntity.status(HttpStatus.OK).body(items);

View File

@ -31,7 +31,8 @@ public class Field implements ViewStyleDefinition<eu.eudat.models.data.entities.
case 1:
return REQUIRED;
default:
throw new RuntimeException("Unsupported Project Status");
return NONE;
}
}

View File

@ -5,7 +5,7 @@ export interface FieldData {
}
export interface AutoCompleteFieldData extends FieldData {
type: string;
type: DatasetProfileComboBoxType;
url: string;
optionsRoot: string;
autoCompleteOptions: FieldDataOption;

View File

@ -1,11 +1,12 @@
import { FormGroup } from '@angular/forms';
import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type';
import { AutoCompleteFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data';
import { FieldDataEditorModel } from './field-data-editor-model';
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
export class AutoCompleteFieldDataEditorModel extends FieldDataEditorModel<AutoCompleteFieldDataEditorModel> {
public type: string;
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.Autocomplete;
public url: string;
public optionsRoot: string;
public autoCompleteOptions: FieldDataOptionEditorModel = new FieldDataOptionEditorModel();

View File

@ -0,0 +1,34 @@
import { FormGroup } from '@angular/forms';
import { DatasetProfileComboBoxType } from '../../../../../core/common/enum/dataset-profile-combo-box-type';
import { WordListFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data';
import { FieldDataEditorModel } from './field-data-editor-model';
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListFieldDataEditorModel> {
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList;
public options: Array<FieldDataOptionEditorModel>;
buildForm(): FormGroup {
const formGroup = this.formBuilder.group({
type: [this.type],
label: [this.label]
});
const optionsFormArray = new Array<FormGroup>();
if (this.options) {
this.options.forEach(item => {
const form: FormGroup = item.buildForm();
optionsFormArray.push(form);
});
}
formGroup.addControl('options', this.formBuilder.array(optionsFormArray));
return formGroup;
}
fromModel(item: WordListFieldData): WordListFieldDataEditorModel {
this.type = item.type;
if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); }
this.label = item.label;
return this;
}
}

View File

@ -5,7 +5,7 @@ import { FieldDataEditorModel } from './field-data-editor-model';
import { FieldDataOptionEditorModel } from './field-data-option-editor-model';
export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListFieldDataEditorModel> {
public type: DatasetProfileComboBoxType;
public type: DatasetProfileComboBoxType = DatasetProfileComboBoxType.WordList;
public options: Array<FieldDataOptionEditorModel>;
buildForm(): FormGroup {
@ -27,7 +27,7 @@ export class WordListFieldDataEditorModel extends FieldDataEditorModel<WordListF
fromModel(item: WordListFieldData): WordListFieldDataEditorModel {
this.type = item.type;
if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); }
if (item.options) { this.options = item.options.map(x => new FieldDataOptionEditorModel().fromModel(x)); }
this.label = item.label;
return this;
}

View File

@ -24,7 +24,7 @@ export class FieldEditorModel extends BaseFormModel {
public ordinal: number;
public visible: VisibilityEditorModel = new VisibilityEditorModel();
public data: FieldDataEditorModel<any>;
public validations: ValidationType[];
public validations: ValidationType[] = [];
fromModel(item: Field): FieldEditorModel {
this.id = item.id;
@ -70,6 +70,7 @@ export class FieldEditorModel extends BaseFormModel {
formGroup.addControl('visible', this.visible.buildForm());
//formGroup.addControl("data",this.data? this.data.buildForm():this.formBuilder.group({}));
if (this.data) { formGroup.addControl('data', this.data.buildForm()); }
else { formGroup.addControl('data', new WordListFieldDataEditorModel().buildForm()); }
return formGroup;
}

View File

@ -1,9 +1,9 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type';
import { EnumUtils } from '../../../../../../../core/services/utilities/enum-utils.service';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../../../../core/common/base/base.component';
import { DatasetProfileComboBoxType } from '../../../../../../../core/common/enum/dataset-profile-combo-box-type';
import { EnumUtils } from '../../../../../../../core/services/utilities/enum-utils.service';
@Component({
selector: 'app-dataset-profile-editor-combo-box-field-component',
@ -20,10 +20,41 @@ export class DatasetProfileEditorComboBoxFieldComponent extends BaseComponent im
) { super(); }
ngOnInit() {
// this.form.get('data').get('type').valueChanges
// .pipe(takeUntil(this._destroyed))
// .subscribe(x => {
// if (x === "autocomplete") {
// //if(!this.form.get('data').get('url')) this.form.addControl('data', new AutoCompleteFieldDataEditorModel().buildForm());
// //delete
// if (this.form.get('data').get('options')) (<FormGroup>this.form.get('data')).removeControl('options');
// //add
// if (!this.form.get('data').get('url')) (<FormGroup>this.form.get('data')).addControl('url', new FormControl(''));
// if (!this.form.get('data').get('optionsRoot')) (<FormGroup>this.form.get('data')).addControl('optionsRoot', new FormControl(''));
// if (!this.form.get('data').get('autoCompleteOptions')) (<FormGroup>this.form.get('data')).addControl('autoCompleteOptions', new FormControl(''));
// } else if (x === "wordlist") {
// //this.form.addControl('data', new WordListFieldDataEditorModel().buildForm());
// //delete
// if (this.form.get('data').get('url')) (<FormGroup>this.form.get('data')).removeControl('url');
// if (this.form.get('data').get('optionsRoot')) (<FormGroup>this.form.get('data')).removeControl('optionsRoot');
// if (this.form.get('data').get('autoCompleteOptions')) (<FormGroup>this.form.get('data')).removeControl('autoCompleteOptions');
// //add
// if (!this.form.get('data').get('options')) (<FormGroup>this.form.get('data')).addControl('options', new FormControl);
// }
// });
this.form.get('data').get('type').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
if (this.form.get('data')) { this.form.removeControl('data'); }
if (this.form.get('data')) {
this.form.removeControl('data');
if(x==="autocomplete"){
this.form.addControl('data',new AutoCompleteFieldDataEditorModel().buildForm());
}else if(x==="wordlist"){
this.form.addControl('data',new WordListFieldDataEditorModel().buildForm());
}
}
})
}
}

View File

@ -4,7 +4,7 @@
</mat-form-field>
<mat-form-field class="col">
<mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.VIEW-STYLE' | translate}}" [formControl]="this.form.get('viewStyle').get('renderStyle')" (change)="onchangeCombo()">
<mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.VIEW-STYLE' | translate}}" [formControl]="this.form.get('viewStyle').get('renderStyle')">
<mat-option [value]="viewStyleEnum.BooleanDecision">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.BooleanDecision)}}</mat-option>
<mat-option [value]="viewStyleEnum.CheckBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.CheckBox)}}</mat-option>
<mat-option [value]="viewStyleEnum.ComboBox">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.ComboBox)}}</mat-option>
@ -21,7 +21,7 @@
</mat-form-field>
<mat-form-field class="col">
<mat-select placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.VALIDATION' | translate}}" [formControl]="this.form.get('validations')" multiple>
<mat-option *ngFor="let option of validationsOptions" [value]="option">{{enumUtils.toDatasetProfileFieldValidationTypeString(option)}}</mat-option>
<mat-option [value]="validationTypeEnum.Required">{{enumUtils.toDatasetProfileFieldValidationTypeString(validationTypeEnum.Required)}}</mat-option>
</mat-select>
</mat-form-field>
</div>

View File

@ -1,30 +1,40 @@

import { Component, Input, OnInit } from '@angular/core';
import { FormArray, FormControl, FormGroup } from '@angular/forms';
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators, FormArray } from '@angular/forms';
import { ValidationType } from '../../../../../../core/common/enum/validation-type';
import { EnumUtils } from '../../../../../../core/services/utilities/enum-utils.service';
import { RuleEditorModel } from '../../../admin/rule-editor-model';
import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style';
import { RadioBoxFieldDataEditorModel } from '../../../admin/field-data/radio-box-field-data-editor-model';
import { DatasetProfileEditorComboBoxFieldComponent } from '../field-type/combo-box/dataset-profile-editor-combo-box-field.component';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../../../core/common/base/base.component';
import { ViewStyleEditorModel } from '../../../admin/view-style-editor-model';
import { TextAreaFieldDataEditorModel } from '../../../admin/field-data/text-area-field-data-editor-model';
import { BooleanDecisionFieldDataEditorModel } from '../../../admin/field-data/boolean-decision-field-data-editor-model';
import { CheckBoxFieldDataEditorModel } from '../../../admin/field-data/check-box-field-data-editor-model';
import { FreeTextFieldDataEditorModel } from '../../../admin/field-data/free-text-field-data-editor-model';
import { WordListFieldDataEditorModel } from '../../../admin/field-data/word-list-field-data-editor-model';
import { AutoCompleteFieldDataEditorModel } from '../../../admin/field-data/auto-complete-field-data-editor-model';
@Component({
selector: 'app-dataset-profile-editor-field-component',
templateUrl: './dataset-profile-editor-field.component.html',
styleUrls: ['./dataset-profile-editor-field.component.scss']
})
export class DatasetProfileEditorFieldComponent implements OnInit {
export class DatasetProfileEditorFieldComponent extends BaseComponent implements OnInit {
@Input() form: FormGroup;
@Input() showMultiplicity = true;
@Input() showOrdinal = true;
@Input() indexPath: string;
validationsOptions: ValidationType[] = this.enumUtils.getEnumValues(ValidationType);
validationTypeEnum = ValidationType;
viewStyleEnum = DatasetProfileFieldViewStyle;
isFieldMultiplicityEnabled = false;
constructor(
public enumUtils: EnumUtils
) {
}
) { super(); }
ngOnInit() {
if (this.form.get('multiplicity')) {
@ -33,6 +43,46 @@ export class DatasetProfileEditorFieldComponent implements OnInit {
}
}
// this.addNewRule();
this.form.get('viewStyle').get('renderStyle').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
if (this.form.get('data')) {
this.form.removeControl('data');
switch (x) {
case DatasetProfileFieldViewStyle.BooleanDecision:
this.form.addControl('data', new BooleanDecisionFieldDataEditorModel().buildForm());
break;
case DatasetProfileFieldViewStyle.CheckBox:
this.form.addControl('data', new CheckBoxFieldDataEditorModel().buildForm());
break;
case DatasetProfileFieldViewStyle.ComboBox:
//this.form.removeControl('data');
this.form.addControl('data', new FormGroup({}));
(<FormGroup>this.form.get('data')).addControl('type', new FormControl(''));
(<FormGroup>this.form.get('data')).addControl('label', new FormControl(''));
//this.form.get('data').get('type').setValue("autocomplete");
break;
case DatasetProfileFieldViewStyle.FreeText:
this.form.addControl('data', new FreeTextFieldDataEditorModel().buildForm());
break;
case DatasetProfileFieldViewStyle.RadioBox:
this.form.addControl('data', new RadioBoxFieldDataEditorModel().buildForm());
break;
case DatasetProfileFieldViewStyle.TextArea:
this.form.addControl('data', new TextAreaFieldDataEditorModel().buildForm());
break;
}
}
});
}
onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) {
@ -46,8 +96,4 @@ export class DatasetProfileEditorFieldComponent implements OnInit {
const rule: RuleEditorModel = new RuleEditorModel();
(<FormArray>this.form.get('visible').get('rules')).push(rule.buildForm());
}
onchangeCombo() {
if (this.form.get('data')) { this.form.removeControl('data'); }
}
}

View File

@ -43,7 +43,7 @@
<mat-expansion-panel-header>
<div class="row">
<span class="col">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</span>
<button mat-icon-button type="button" class="col-auto" (click)="deleteFieldSet(i);">
<button mat-icon-button type="button" class="col-auto" (click)="DeleteSectionInSection(i);">
<mat-icon>delete</mat-icon>
</button>
</div>

View File

@ -68,7 +68,11 @@
<mat-step class="step-container">
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
<div *ngIf="this.isActiveStep(2)" class="row">
<<<<<<< HEAD
<app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules"></app-dataset-description-form>
=======
<app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')" [dataModel]="datasetWizardModel.datasetProfileDefinition" [datasetProfileId]="formGroup.get('profile').value"></app-dataset-description-form>
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
<div class="col-12 description-action-row">
<div class="row">
<div class="col-auto"><button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button></div>

View File

@ -11,7 +11,11 @@
<h6 *ngIf="form.get('extendedDescription').value" class="col-12">
<i>{{form.get('extendedDescription').value}}</i>
</h6>
<<<<<<< HEAD
<app-form-field class="col-12" [form]="form.get('fields')['controls'][0]"></app-form-field>
=======
<app-form-field class="col-12" [field]="compositeField.fields[0]" [datasetProfileId]="datasetProfileId"></app-form-field>
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
</div>
</div>
<div *ngIf="form.get('fields').length > 1" class="col-12">
@ -31,10 +35,17 @@
</div>
<div class="row">
<<<<<<< HEAD
<app-form-field [form]="fieldFormGroup" class="col-12"></app-form-field>
<div *ngIf="fieldFormGroup" class="col-12">
<div *ngFor="let multipleField of fieldFormGroup.get('multiplicityItems')['controls']; let j = index" class="row">
<app-form-field class="col-12" [form]="multipleField"></app-form-field>
=======
<app-form-field [field]="field" class="col-12" [datasetProfileId]="datasetProfileId"></app-form-field>
<div *ngIf="field" class="col-12">
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn" class="row">
<app-form-field class="col-12" [field]="multipleField" [datasetProfileId]="datasetProfileId"></app-form-field>
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
</div>
</div>
</div>

View File

@ -16,8 +16,10 @@ import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.
styleUrls: ['./form-field.component.scss']
})
export class FormFieldComponent extends BaseComponent implements OnInit {
// @Input() field: Field;
@Input() form: FormGroup;
@Input() datasetProfileId: String;
// change: Subscription;
// trackByFn = (index, item) => item ? item['id'] : null;
@ -56,9 +58,9 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
searchFromAutocomplete(query: string) {
const autocompleteRequestItem: RequestItem<DatasetExternalAutocompleteCriteria> = new RequestItem();
autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria();
autocompleteRequestItem.criteria.fieldID = this.form.get('id').value;
//TODO: why do we need dataset id?
//autocompleteRequestItem.criteria.profileID = this.datasetId;
autocompleteRequestItem.criteria.profileID = this.datasetProfileId;
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
}

View File

@ -19,11 +19,20 @@
Add one more fieldset +
</button> -->
</div>
<<<<<<< HEAD
<app-form-composite-field class="col-12" [form]="compositeFieldFormGroup"></app-form-composite-field>
<div *ngIf="compositeField" class="col-12">
<div class="row">
<app-form-composite-field class="col-12" *ngFor="let multipleCompositeFieldFormGroup of compositeFieldFormGroup.get('multiplicityItems')['controls']; let j = index" [form]="multipleCompositeFieldFormGroup"></app-form-composite-field>
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12" [formGroup]="compositeFieldFormGroup">
=======
<app-form-composite-field class="col-12" [compositeField]="compositeField" [datasetProfileId]="datasetProfileId"></app-form-composite-field>
<div *ngIf="compositeField" class="col-12">
<div class="row">
<app-form-composite-field class="col-12" *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn"
[compositeField]="multipleCompositeField" [datasetProfileId]="datasetProfileId"></app-form-composite-field>
<mat-form-field *ngIf="compositeField.hasCommentField" class="col-12" [formGroup]="form.get('compositeFields').get(''+i)">
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
<input matInput formControlName="commentFieldValue" placeholder="comment">
</mat-form-field>
<div class="col"></div>
@ -34,11 +43,17 @@
</div>
</div>
</div>
<<<<<<< HEAD
<div *ngIf="form.get('sections')" class="col-12">
<div *ngFor="let subSectionFormGroup of form.get('sections')['controls']; let j = index;" class="row">
<app-form-section class="col-12" [form]="subSectionFormGroup" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></app-form-section>
=======
<div *ngIf="section?.sections" class="col-12">
<div *ngFor="let itemsection of section.sections; let j = index;" class="row">
<app-form-section class="col-12" [section]="itemsection" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j" [datasetProfileId]="datasetProfileId"></app-form-section>
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
</div>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>

View File

@ -9,7 +9,11 @@
<mat-step [stepControl]="sectionFormGroup">
<ng-template matStepLabel>{{pageFormGroup.get('title').value}}</ng-template>
<div *ngIf="stepper.selectedIndex == z" class="row">
<<<<<<< HEAD
<app-form-section class="col-12" [form]="sectionFormGroup" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></app-form-section>
=======
<app-form-section class="col-12" [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i" [datasetProfileId]="datasetProfileId"></app-form-section>
>>>>>>> df51afe83344e5ee398f54d9a0a0b48f41588e16
</div>
</mat-step>
</div>

View File

@ -36,6 +36,8 @@ export class DatasetDescriptionFormComponent extends BaseComponent implements On
// id: string;
// trackByFn = (index, item) => item ? item['id'] : null;
// pageTrackByFn = (index, item) => item['id'];
@Input() datasetProfileId: String;
constructor(
private router: Router,

View File

@ -179,6 +179,10 @@ export class DatasetDescriptionCompositeFieldEditorModel extends BaseFormModel {
this.fields.forEach(field => {
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + '_'));
});
// put on new item only the first (Fields) value and the last (Fields) value
// the first is on "fields":[{},{}]
// and the New is on "multiplicityItem":[{ fields":[{},{}] },{ fields":[{},{}] }]
newItem.ordinal = this.ordinal;
return newItem;