From 427c04f631c5c11c7b11a5a3c192d888491ccc0a Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Mon, 22 Mar 2021 15:47:45 +0200 Subject: [PATCH] Dataset Profile Editor. Individual preview (needs backend support). Replace static text with language translation. Fix scrolling behaviour. Clean up some code in table of contents. Patch drag and drop (instant drag) issue. UI enhancements: validate button and marking on table of contents(Pages when dont have children) --- .../daatset-external-autocomplete-criteria.ts | 3 +- .../dataset-external-autocomplete.service.ts | 15 +- ...ataset-profile-editor-field.component.html | 14 +- ...ile-editor-section-fieldset.component.html | 4 +- ...ofile-editor-section-fieldset.component.ts | 49 +++-- .../dataset-profile-editor.component.html | 65 ++++++- .../dataset-profile-editor.component.ts | 14 +- .../table-of-contents-internal-section.html | 2 +- .../table-of-contents-internal-section.ts | 15 +- .../table-of-contents/table-of-contents.html | 15 +- .../table-of-contents/table-of-contents.ts | 169 ++++-------------- .../form-field/form-field.component.ts | 7 +- dmp-frontend/src/assets/i18n/de.json | 17 ++ dmp-frontend/src/assets/i18n/en.json | 17 ++ dmp-frontend/src/assets/i18n/es.json | 17 ++ dmp-frontend/src/assets/i18n/gr.json | 17 ++ dmp-frontend/src/assets/i18n/pt.json | 17 ++ dmp-frontend/src/assets/i18n/sk.json | 17 ++ dmp-frontend/src/assets/i18n/sr.json | 17 ++ dmp-frontend/src/assets/i18n/tr.json | 17 ++ 20 files changed, 320 insertions(+), 188 deletions(-) diff --git a/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts b/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts index ffb5034ce..d511e9432 100644 --- a/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts +++ b/dmp-frontend/src/app/core/query/dataset/daatset-external-autocomplete-criteria.ts @@ -1,7 +1,8 @@ +import { AutoCompleteSingleData } from "@app/core/model/dataset-profile-definition/field-data/field-data"; import { BaseCriteria } from "../base-criteria"; export class DatasetExternalAutocompleteCriteria extends BaseCriteria { public profileID: String; public fieldID: String; - public autocompleteOptions: any; + public autocompleteOptions: AutoCompleteSingleData; } \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts index 35ee12a6f..bcbfd2630 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts @@ -1,11 +1,12 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { environment } from '../../../../environments/environment'; import { DatasetExternalAutocompleteCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria'; import { RequestItem } from '../../query/request-item'; import { DatasetProfileService } from '../dataset-profile/dataset-profile.service'; import { ConfigurationService } from '../configuration/configuration.service'; +import { map } from 'rxjs/operators'; @Injectable() export class DatasetExternalAutocompleteService { @@ -27,4 +28,14 @@ export class DatasetExternalAutocompleteService { return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem); } -} + queryApi(requestItem: RequestItem):Observable{ //TODO + + return of([ + { + label:'Preview not supported yet', + source:'' + } + ]); + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html index d221f961b..755b9a78e 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.html @@ -203,9 +203,17 @@ -->
- - - + + + + + + + + + + +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html index 887fe5c06..6bfb1454d 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.html @@ -1,4 +1,5 @@ -
+
+
@@ -58,7 +59,6 @@
- diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts index a7005e339..51bc04cb7 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section-fieldset/dataset-profile-editor-section-fieldset.component.ts @@ -105,11 +105,8 @@ export class DatasetProfileEditorSectionFieldSetComponent extends BaseComponent this.form = this.tocentry.form; this.numbering = this.tocentry.numbering; this._selectedFieldSetId = null; - - let el = this.myElement.nativeElement.querySelector("#"+this.idprefix+this.tocentry.id); - if(el){ - el.scrollIntoView({behavior: "smooth"}); - } + + this._scrollToElement(this.tocentry.id); }else if(this.tocentry.type === ToCEntryType.FieldSet){ this.form = this.tocentry.form.parent.parent; const numberingArray = this.tocentry.numbering.split('.'); @@ -118,23 +115,39 @@ export class DatasetProfileEditorSectionFieldSetComponent extends BaseComponent this.numbering = numberingArray.join('.'); } this.selectedFieldSetId = this.tocentry.id; - //scroll to fieldset - // setTimeout(() => { - // const element = document.getElementById(this.selectedFieldSetId); - // element.scrollTop = element.scrollHeight; - // }, 2000); - - let el = this.myElement.nativeElement.querySelector("#"+this.idprefix+this.selectedFieldSetId); - // let el = this.myElement.nativeElement.getElementbyId (this.selectedFieldSetId); - - if(el){ - el.scrollIntoView({behavior: "smooth"}); - } + + this._scrollToElement(this.selectedFieldSetId); }else{//scroll on top - window.scrollTo({top:0, behavior:'smooth'}); + this._scrollOnTop(); } } + private _scrollToElement(id: string){ + let el = this.myElement.nativeElement.querySelector("#"+this.idprefix+id); + // let el = this.myElement.nativeElement.getElementbyId (this.selectedFieldSetId); + + if(el){ + + setTimeout(() => { + const el = this.myElement.nativeElement.querySelector("#"+this.idprefix+id); + if(el){ + el.scrollIntoView({behavior: "smooth"}); + } + }, 300); + }else{ + this._scrollOnTop(); + } + + } + private _scrollOnTop(){ + setTimeout(() => { + const el = this.myElement.nativeElement.querySelector('#topofcontainer'); + if(el){ + el.scrollIntoView({behavior:'smooth'}) + } + },200); + + } ngOnInit() { this.initialize(); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html index d06a4130b..310cb5f40 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html @@ -192,8 +192,6 @@
+ + + +
+
+ +
+ + +
+ + + + + + + + +
+
+ + + +
@@ -404,7 +455,7 @@
- + @@ -423,9 +474,11 @@
- + + + diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 4d453370f..6942cd9f7 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -478,10 +478,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.links = currentLinks; } - linkToScroll: LinkToScroll; - onStepFound(linkToScroll: LinkToScroll) { - this.linkToScroll = linkToScroll; - } datasetWizardModel: DatasetWizardEditorModel; formGroup: FormGroup; @@ -1532,13 +1528,13 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn switch(keyError){ case EditorCustomValidatorsEnum.atLeastOneSectionInPage: - errmess.push('Each section must have at least one subsection'); + errmess.push( this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PAGE-MUST-HAVE-SECTION')); break; case EditorCustomValidatorsEnum.emptyArray: - errmess.push(numbering+" needs more information.") + errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.NEEDS-MORE-INFORMATION')) break; case EditorCustomValidatorsEnum.sectionMustHaveOneChild: - errmess.push(numbering+" must have either subsection or input sets.") + errmess.push(numbering+this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MUST-HAVE-SECTION-OR-FIELDSET')) break; default: if (typeof errors[keyError] === 'boolean') { @@ -1610,10 +1606,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn result.forEach(err=>{ // console.log(err); if(err.key){ - errmess.push(`Missing ${err.key}` ); + errmess.push(`${this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.MISSING')} ${err.key}` ); }else{ - errmess.push('Make sure you provide a section and a subsection'); + errmess.push(this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.FORM-VALIDATION.ERROR-MESSAGES.PROVIDE-PAGE-AND-SECTION')); } // errmess.push(...this._buildErrorMessage(err.errors,"", err.key) ); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html index fc20d932d..124b823f4 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.html @@ -44,7 +44,7 @@ delete diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts index 058989859..57080ed5c 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.ts @@ -239,7 +239,7 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent if(!this.colorizeInvalid) return false; const form = this.parentLink.form; - if(!form || form.valid || !form.touched) return false; + if((!form || form.valid || !form.touched) && this.parentLink.type !== this.tocEntryType.Page) return false; const allFieldsAreTouched = this.allFieldsAreTouched(form); @@ -248,11 +248,20 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent if(form.errors && allFieldsAreTouched) return true; + //check if page has sections + if(this.parentLink.type === this.tocEntryType.Page && allFieldsAreTouched){ + const rootForm = form.root; + if(rootForm){ + const sections = rootForm.get('sections') as FormArray; + if(!sections.controls.find(section=>section.get('page').value === this.parentLink.id)){ + return true; + } + } + } - //checking form controls if have errors + //checking first child form controls if have errors let hasErrors = false; - if(allFieldsAreTouched){ if(form instanceof FormGroup){ const formGroup = form as FormGroup; diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html index 00ff6e9ae..d8b5ef748 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.html @@ -1,13 +1,8 @@
- - -

{{'DMP-EDITOR.STEPPER.USER-GUIDE' | translate}}

- + + > + - -
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts index 4d64c7e47..7010a5756 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents.ts @@ -9,6 +9,7 @@ import { Foo, ToCEntry, ToCEntryType } from './table-of-contents-entry'; import { DragulaService } from 'ng2-dragula'; import { FormArray } from '@angular/forms'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material'; +import { TranslateService } from '@ngx-translate/core'; export interface Link { /* id of the section*/ @@ -35,17 +36,13 @@ export interface Link { export class DatasetProfileTableOfContents extends BaseComponent implements OnInit { @Input() links: ToCEntry[]; - container: string; - headerSelectors = '.toc-page-header, .toc-section-header, .toc-compositeField-header'; - @Output() stepFound = new EventEmitter(); - @Output() currentLinks = new EventEmitter(); @Output() itemClick = new EventEmitter(); @Output() newEntry = new EventEmitter(); @Output() removeEntry = new EventEmitter(); - @Output() createEntry = new EventEmitter(); + @Output() createEntry = new EventEmitter();//TODO @Output() dataNeedsRefresh = new EventEmitter(); @@ -64,11 +61,6 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn @Input() viewOnly: boolean; - - subscription: Subscription; - linksSubject: Subject = new Subject(); - - @Input() isActive: boolean; show: boolean = false; isDragging: boolean = false; draggingItemId: string = null; @@ -77,11 +69,14 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn DRAGULA_ITEM_ID_PREFIX="table_item_id_"; ROOT_ID: string = "ROOT_ID";//no special meaning - + private _dragStartedAt; + + constructor( @Inject(DOCUMENT) private _document: Document, private dragulaService: DragulaService, - private snackbar: MatSnackBar + private snackbar: MatSnackBar, + private language: TranslateService ) { super(); @@ -96,6 +91,25 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn const drake = dragula.drake; drake.on('drop', (el, target, source,sibling)=>{ + + if(this._dragStartedAt){ + const timeNow = new Date().getTime(); + + if(timeNow - this._dragStartedAt> 600){ + console.log('timenow: ', timeNow); + console.log('timestarted', this._dragStartedAt); + this._dragStartedAt = null; + + }else{ + this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed + return; + } + }else{ + this.dataNeedsRefresh.emit();// even though the data is not changed the TABLE DRAG may has changed + return; + + } + const elementId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX,''); const targetId = target.id as string; const sourceId = source.id as string; @@ -123,7 +137,8 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn switch(element.type){ case ToCEntryType.FieldSet: if(targetContainer.type != this.tocEntryType.Section){ - const message = 'Fieldset can only be child of Subsections'; + // const message = 'Fieldset can only be child of Subsections'; + const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.FIELDSET-MUST-HAVE-PARENT-SECTION'); console.error(message); this.notifyUser(message) this.dataNeedsRefresh.emit(); @@ -132,7 +147,8 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn //check if target container has no sections if((targetContainer.form.get('sections') as FormArray).length){ - const message = 'Cannot have inputs and sections on the same level'; + // const message = 'Cannot have inputs and sections on the same level'; + const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL'); this.notifyUser(message); console.error(message); this.dataNeedsRefresh.emit(); @@ -207,7 +223,8 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn if(targetContainer.type == ToCEntryType.Section){ if((targetContainer.form.get('fieldSets')as FormArray).length){ - const message = 'Cannot have inputs and sections on the same level'; + // const message = 'Cannot have inputs and sections on the same level'; + const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.INPUT-SECTION-SAME-LEVEL');; this.notifyUser(message); console.info(message); this.dataNeedsRefresh.emit(); @@ -341,7 +358,8 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn targetSectionsArray.push(sectionForm); }else{ - const message = 'Drag not support to specific container'; + // const message = 'Drag not support to specific container'; + const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.DRAG-NOT-SUPPORTED'); this.notifyUser(message); console.info(message); this.dataNeedsRefresh.emit(); @@ -354,7 +372,8 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn break; case ToCEntryType.Page: if(targetId != this.ROOT_ID){ - const message = 'A page element can only be at top level'; + // const message = 'A page element can only be at top level'; + const message = this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.TABLE-OF-CONTENTS.ERROR-MESSAGES.PAGE-ELEMENT-ONLY-TOP-LEVEL'); this.notifyUser(message); console.info(message); this.dataNeedsRefresh.emit(); @@ -432,6 +451,7 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn drake.on('drag',(el,source)=>{ + this._dragStartedAt = new Date().getTime(); console.log('drag fired'); this.isDragging = true; this.draggingItemId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); @@ -490,116 +510,14 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn } ngOnInit(): void { - //emit value every 500ms - // const source = interval(500); - // this.subscription = source.subscribe(val => { - // const headers = Array.from(this._document.querySelectorAll(this.headerSelectors)) as HTMLElement[]; - // this.linksSubject.next(headers); - // }); - - // if (!this.links || this.links.length === 0) { - // this.linksSubject.asObservable() - // .pipe(distinctUntilChanged((p: HTMLElement[], q: HTMLElement[]) => JSON.stringify(p) == JSON.stringify(q))) - // .subscribe(headers => { - // const links: Array = []; - - // if (headers.length) { - // let page; - // let section; - // let show - // for (const header of headers) { - // let name; - // let id; - // if (header.classList.contains('toc-page-header')) { // deprecated after removing stepper - // name = header.innerText.trim().replace(/^link/, ''); - // id = header.id; - // page = header.id.split('_')[1]; - // section = undefined; - // show = true; - // } else if (header.classList.contains('toc-section-header')) { - // name = header.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue.trim().replace(/^link/, ''); - // id = header.id; - // page = header.id.split('.')[1]; - // section = header.id; - // if (header.id.split('.')[4]) { show = false; } - // else { show = true; } - // } else if (header.classList.contains('toc-compositeField-header')) { - // name = (header.childNodes[0]).nodeValue.trim().replace(/^link/, ''); - // id = header.id; - // // id = header.parentElement.parentElement.parentElement.id; - // show = false; - // } - // const { top } = header.getBoundingClientRect(); - // links.push({ - // name, - // id, - // type: header.tagName.toLowerCase(), - // top: top, - // active: false, - // page: page, - // section: section, - // show: show, - // selected: false - // }); - // } - // } - // this.links = links; - // // Initialize selected for button next on dataset wizard component editor - // this.links.length > 0 ? this.links[0].selected = true : null; - // }) - // } + } ngOnChanges(changes: SimpleChanges) { - // if (!this.isActive && this.links && this.links.length > 0) { - // this.links.forEach(link => { - // link.selected = false; - // }) - // this.links[0].selected = true; - // } + } - goToStep(link: Link) { - // this.stepFound.emit({ - // page: link.page, - // section: link.section - // }); - // this.currentLinks.emit(this.links); - - // setTimeout(() => { - // const target = document.getElementById(link.id); - // target.scrollIntoView(true); - - // var scrolledY = window.scrollY; - // if (scrolledY) { - // window.scroll(0, scrolledY - 70); - // } - // }, 500); - } - - toggle(headerLink: Link) { - // const headerPage = +headerLink.name.split(" ", 1); - // let innerPage; - // for (const link of this.links) { - // link.selected = false; - // if (link.type === 'mat-expansion-panel') { - // innerPage = +link.name.split(".", 1)[0]; - // if (isNaN(innerPage)) { innerPage = +link.name.split(" ", 1) } - // } else if (link.type === 'h5') { - // innerPage = +link.name.split(".", 1)[0]; - // } - // if (headerPage === innerPage && (link.type !== 'mat-expansion-panel' || (link.type === 'mat-expansion-panel' && link.id.split(".")[4]))) { - // link.show = !link.show; - // } - // } - // headerLink.selected = true; - } - - // getIndex(link: Link): number { - // return +link.id.split("_", 2)[1]; - // } - itemClicked(item: ToCEntry){ //leaf node @@ -639,12 +557,3 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn } - - - - -export interface LinkToScroll { - page: number; - section: number; -} - diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts index fe37effbd..c40ecc95b 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-field/form-field.component.ts @@ -34,6 +34,7 @@ import { ENTER, COMMA } from '@angular/cdk/keycodes'; import { DatasetIdModel } from '@app/core/model/dataset/dataset-id.model'; import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model'; import { CurrencyService } from '@app/core/services/currency/currency.service'; +import { AutoCompleteSingleData } from '@app/core/model/dataset-profile-definition/field-data/field-data'; @Component({ selector: 'app-form-field', @@ -46,7 +47,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit { @Input() form: FormGroup; @Input() datasetProfileId: any; @Input() isChild: Boolean = false; - @Input() autocompleteOptions: any; + @Input() autocompleteOptions: AutoCompleteSingleData; // change: Subscription; // trackByFn = (index, item) => item ? item['id'] : null; @@ -289,6 +290,10 @@ export class FormFieldComponent extends BaseComponent implements OnInit { throw "Could not load autocomplete options."; } autocompleteRequestItem.criteria.like = query; + + if(this.autocompleteOptions){ + return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem); + } return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem); } diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index cd67ee413..b5d1b2cd4 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -465,6 +465,23 @@ "RULE-IF": "If Value is", "RULE-THEN": "then show Field With Id" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 86f380533..16d94410b 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -465,6 +465,23 @@ "RULE-IF": "If Value is", "RULE-THEN": "then show Field With Id" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 23fefb7e1..98d1dba4d 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -465,6 +465,23 @@ "RULE-IF": "Si el valor es", "RULE-THEN": "entonces muestra el campo con identificación" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 87ed12f91..69c63c81b 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -465,6 +465,23 @@ "RULE-IF": "Εάν η τιμή είναι", "RULE-THEN": "τότε δείξε το Πεδίο με ταυτοποίηση" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 13ee785a8..e591fdca6 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -465,6 +465,23 @@ "RULE-IF": "Se Valor é", "RULE-THEN": "então mostrar Campo com o Id" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index eb27b0fc9..8a21e0239 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -465,6 +465,23 @@ "RULE-IF": "If Value is", "RULE-THEN": "then show Field With Id" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index f81cba2aa..edd84b723 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -465,6 +465,23 @@ "RULE-IF": "Ako je vrednost", "RULE-THEN": "tada prikazati polje sa Id" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": { diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 4f711b5ea..3d78ebd9e 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -465,6 +465,23 @@ "RULE-IF": "Eğer değer", "RULE-THEN": "sonra alanı kimliği ile göster" } + }, + "FORM-VALIDATION":{ + "ERROR-MESSAGES":{ + "PAGE-MUST-HAVE-SECTION": "Each section must have at least one subsection.", + "NEEDS-MORE-INFORMATION": " needs more information.", + "MUST-HAVE-SECTION-OR-FIELDSET": " must have either subsection or input set.", + "MISSING":"Missing", + "PROVIDE-PAGE-AND-SECTION":"Make sure you provide a section and a subsection" + } + }, + "TABLE-OF-CONTENTS":{ + "ERROR-MESSAGES":{ + "FIELDSET-MUST-HAVE-PARENT-SECTION":"Input set can only be child of subsection.", + "INPUT-SECTION-SAME-LEVEL": "Cannot have input set and section on the same level.", + "DRAG-NOT-SUPPORTED":"Drag n drop of subsection not supported to target container.", + "PAGE-ELEMENT-ONLY-TOP-LEVEL": "Section elements can only be at top level" + } } }, "TOOLKIT": {