From 2df5c6820a3ad073e7c208b13e5127ded750f2fe Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Wed, 31 Mar 2021 18:31:57 +0300 Subject: [PATCH 1/2] Dataset Profile Editor. Drag n drop fix on Import Template. Feedback messages on update/save template. Code cleanups. MultiAutoComplete Preview Fix. --- .../editor/animations/animations.ts | 2 +- ...ile-editor-section-fieldset.component.html | 4 +- ...ile-editor-section-fieldset.component.scss | 103 ++++----- .../dataset-profile-editor.component.html | 1 - .../dataset-profile-editor.component.ts | 196 ++++++++---------- ...-confirmation-upload-profiles.component.ts | 8 +- .../dataset-profile-listing.component.ts | 9 +- .../table-of-contents-entry.ts | 2 +- .../table-of-contents-internal-section.html | 6 +- .../table-of-contents-internal-section.scss | 159 ++++---------- .../table-of-contents-internal-section.ts | 182 +++++++--------- .../table-of-contents/table-of-contents.html | 6 +- .../table-of-contents/table-of-contents.scss | 122 ++--------- .../table-of-contents/table-of-contents.ts | 75 ++----- .../form-field/form-field.component.ts | 4 +- dmp-frontend/src/assets/i18n/de.json | 3 + dmp-frontend/src/assets/i18n/en.json | 3 + dmp-frontend/src/assets/i18n/es.json | 3 + dmp-frontend/src/assets/i18n/gr.json | 3 + dmp-frontend/src/assets/i18n/pt.json | 3 + dmp-frontend/src/assets/i18n/sk.json | 3 + dmp-frontend/src/assets/i18n/sr.json | 3 + dmp-frontend/src/assets/i18n/tr.json | 3 + 23 files changed, 321 insertions(+), 582 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts index a0b261a4c..c62b30393 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/animations/animations.ts @@ -59,6 +59,6 @@ export const GENERAL_ANIMATIONS = [ trigger('fadeElement',[ state('updated',style({opacity:0})), transition("*=>updated", - animate('2s 40ms ease-out')) + animate('2s 1s ease-out')) ]) ] \ No newline at end of file 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 f23669afd..ee9cacacd 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 @@ -17,7 +17,7 @@
-
-
+
this.form.get('sections')).push(section.buildForm()); // } - addPage() { - const page: PageEditorModel = new PageEditorModel(this.dataModel.pages.length); - this.dataModel.pages.push(page); - (this.form.get('pages')).push(page.buildForm()); - } + // addPage() { + // const page: PageEditorModel = new PageEditorModel(this.dataModel.pages.length); + // this.dataModel.pages.push(page); + // (this.form.get('pages')).push(page.buildForm()); + // } - DeleteSection(index) { - this.dataModel.sections.splice(index, 1); - (this.form.get('sections')).removeAt(index); - } + // DeleteSection(index) { + // this.dataModel.sections.splice(index, 1); + // (this.form.get('sections')).removeAt(index); + // } onSubmit() { let data = this.form.value; + if (this.datasetProfileId) { this.datasetProfileService.updateForm(this.datasetProfileId, data) .pipe(takeUntil(this._destroyed)) .subscribe(() => { this.router.navigate(['/dataset-profiles']); - }); + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); + },error=> this.onCallbackError(error)); } else if (this.newVersionId) { data.label = this.form.get('label').value; data.description = this.form.get('description').value; @@ -289,17 +291,21 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn .pipe(takeUntil(this._destroyed)) .subscribe(() => { this.router.navigate(['/dataset-profiles']); + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); }, error => this.onCallbackErrorNewVersion(error) ); } else { - this.form.get('status').setValue(DatasetStatus.Draft); + if(this.form.get('status').value != DatasetStatus.Finalized){// forn created and finalized instantly + this.form.get('status').setValue(DatasetStatus.Draft); + } data = this.form.value; this.datasetProfileService.createForm(data) .pipe(takeUntil(this._destroyed)) .subscribe(() => { this.router.navigate(['/dataset-profiles']); - }); + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success); + }, error=> this.onCallbackError(error)); } } @@ -315,21 +321,22 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn .pipe(takeUntil(this._destroyed)) .subscribe(() => { this.router.navigate(['/dataset-profiles']); - }); + this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.FEEDBACK-MESSAGES.SAVE-SUCCESS'), SnackBarNotificationLevel.Success) + },error=>this.onCallbackError(error)); } showUpdateButton() { return !this.isNew && this.dataModel.status === DatasetProfileEnum.FINALIZED; } - isStepActive(step: number) { - return this.stepper && this.stepper.selectedIndex === step; - } + // isStepActive(step: number) { + // return this.stepper && this.stepper.selectedIndex === step; + // } - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/master-items']); - } + // onCallbackSuccess(): void { + // this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + // this.router.navigate(['/master-items']); + // } onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) { this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error); @@ -430,68 +437,70 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn // } } - printErrors(rootform: FormGroup) { - if (!rootform.valid) { - Object.keys(rootform.controls).forEach(key => { - const errors = rootform.get(key).errors; - if (errors !== null) { - let numbering: string = ''; - for (let j = 0; j < this.nestedCount.length; j++) { - numbering += this.nestedCount[j]; - if (j < this.nestedIndex) { - numbering += '.'; - } else { - break; - } - } - Object.keys(errors).forEach(keyError => { - if (typeof errors[keyError] === 'boolean') { - this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError); - } else { - this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); - } - }); - } else { - if (rootform.get(key) instanceof FormGroup) { - this.printErrors(rootform.get(key)); - } else if (rootform.get(key) instanceof FormArray) { - this.nestedIndex++; - this.nestedCount[this.nestedIndex] = 0; - for (let childForm of (rootform.get(key)).controls) { - this.nestedCount[this.nestedIndex]++; - this.printErrors(childForm); - } - this.nestedCount[this.nestedIndex] = 0; - this.nestedIndex--; - } - } - }); - } - } + //BEFORE REDESIGN + // printErrors(rootform: FormGroup) { + // if (!rootform.valid) { + // Object.keys(rootform.controls).forEach(key => { + // const errors = rootform.get(key).errors; + // if (errors !== null) { + // let numbering: string = ''; + // for (let j = 0; j < this.nestedCount.length; j++) { + // numbering += this.nestedCount[j]; + // if (j < this.nestedIndex) { + // numbering += '.'; + // } else { + // break; + // } + // } + // Object.keys(errors).forEach(keyError => { + // if (typeof errors[keyError] === 'boolean') { + // this.errorMessages.push(numbering + ' ' + key + ' is ' + keyError); + // } else { + // this.errorMessages.push(numbering + ' ' + key + ': ' + keyError + ': ' + JSON.stringify(errors[keyError])); + // } + // }); + // } else { + // if (rootform.get(key) instanceof FormGroup) { + // this.printErrors(rootform.get(key)); + // } else if (rootform.get(key) instanceof FormArray) { + // this.nestedIndex++; + // this.nestedCount[this.nestedIndex] = 0; + // for (let childForm of (rootform.get(key)).controls) { + // this.nestedCount[this.nestedIndex]++; + // this.printErrors(childForm); + // } + // this.nestedCount[this.nestedIndex] = 0; + // this.nestedIndex--; - private showValidationErrorsDialog(projectOnly?: boolean) { - const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { - disableClose: true, - autoFocus: false, - restoreFocus: false, - data: { - errorMessages: this.errorMessages, - projectOnly: projectOnly - }, - }); - } + // } + // } + // }); + // } + // } + + // private showValidationErrorsDialog(projectOnly?: boolean) { + // const dialogRef = this.dialog.open(FormValidationErrorsDialogComponent, { + // disableClose: true, + // autoFocus: false, + // restoreFocus: false, + // data: { + // errorMessages: this.errorMessages, + // projectOnly: projectOnly + // }, + // }); + // } - links: Link[] = []; + // links: Link[] = []; - getLinks(currentLinks: Link[]) { - this.links = currentLinks; - } + // getLinks(currentLinks: Link[]) { + // this.links = currentLinks; + // } datasetWizardModel: DatasetWizardEditorModel; @@ -751,7 +760,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn return tocEntryFound? tocEntryFound: null; } - addNewEntry(tce: Foo) { + addNewEntry(tce: NewEntryType) { const parent = tce.parent; @@ -1514,7 +1523,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn } - isStepCompleted(stepIndex: number){ //TODO NA TO DOUME MIPOS DEN XREIAZETAI + isStepCompleted(stepIndex: number){ let stepCompleted = false; this.steps.forEach((step,index)=>{ @@ -1708,41 +1717,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn return fieldsets; } - // private _printToCentriesErrrors(entries: ToCEntry[]){ - - // if(!entries || !entries.length) return; - - // entries.forEach(e=>{ - - - // // if(e.form instanceof FormGroup) console.log('is Formgroup'); - // // if(e.form instanceof FormControl) console.log('is formcontrols'); - // // if(e.form instanceof FormArray) console.log('isForm array'); - - - // const form = e.form as FormGroup; - // if(form.invalid){ - // const controls = form.controls; - // const keys = Object.keys(controls); - // keys.forEach(key=>{ - // const control = controls[key]; - - // if(control.invalid){ - // console.log('control ', key, 'is invalid'); - // } - // }) - - - // // console.log('keys,', keys); - - - // this._printToCentriesErrrors(e.subEntries); - // } - // }); - // } - - - private _getErrors(aControl: AbstractControl):InvalidControl[]{ diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts index 3b08731b9..2fe4b0343 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component.ts @@ -21,7 +21,13 @@ export class DialogConfirmationUploadDatasetProfiles { selectXML(event) { - const file: FileList = event.target.files; + let file: FileList = null; + + if(event.target && event.target.files){ + file = event.target.files; + }else if(event.addedFiles && event.addedFiles.length){ + file = event.addedFiles; + } if(!file) return;//no select closed with cancel . no file selected const size: number = file[0].size; // Get file size. this.sizeError = size > this.maxFileSize; // Checks if file size is valid. diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts index e5bc2af41..fafcd4f0f 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.ts @@ -217,7 +217,14 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI if (data && data.sucsess && data.name != null && data.file != null) { this.datasetService.uploadFile(data.file, data.name) .pipe(takeUntil(this._destroyed)) - .subscribe(); + .subscribe(_=>{ + this.uiNotificationService.snackBarNotification('Template successfully uploaded', SnackBarNotificationLevel.Success); + this.refresh(); + }, + error=>{ + this.uiNotificationService.snackBarNotification(error.message, SnackBarNotificationLevel.Error); + } + ); } }); } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts index 896933079..b1ddf7e9a 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-entry.ts @@ -18,7 +18,7 @@ export enum ToCEntryType { Field = 3 } -export interface Foo { +export interface NewEntryType { childType: ToCEntryType, parent: ToCEntry } 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 d40264399..6eab86109 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 @@ -23,7 +23,7 @@ [ngStyle]="{'font-size' : (parentLink.type == tocEntryType.FieldSet? '.9rem':'1rem')}" > --> - diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss index 9c12602f4..03cd37891 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/table-of-contents/table-of-contents-internal-section/table-of-contents-internal-section.scss @@ -1,88 +1,52 @@ -.docs-toc-container { - width: 100%; - padding: 5px 0 10px 0px; - // cursor: pointer; - // border-left: solid 4px #0c7489; +// .docs-toc-container { +// width: 100%; +// padding: 5px 0 10px 0px; +// // cursor: pointer; +// // border-left: solid 4px #0c7489; - .scroll-container { - overflow-y: auto; - // calc(100vh - 250px) - // height: calc(100vh - 250px); - } +// .scroll-container { +// overflow-y: auto; +// // calc(100vh - 250px) +// // height: calc(100vh - 250px); +// } - .docs-link { - color: rgba(0, 0, 0, 0.54); - // color: mat-color($app-blue-theme-foreground, secondary-text); - transition: color 100ms; +// .docs-link { +// color: rgba(0, 0, 0, 0.54); +// // color: mat-color($app-blue-theme-foreground, secondary-text); +// transition: color 100ms; - &:hover, - &.docs-active { - .link-name { - background-color: #ececec; - border-radius: 6px; - cursor: pointer;; - // color: #0c7489; - } - // color: mat-color($primary, if($is-dark-theme, 200, default)); - } - } -} - -.docs-toc-heading { - margin: 0; - padding: 0; - font-size: 13px; - font-weight: bold; -} - -// span { -// line-height: 16px; -// margin: 6px 0 0; -// position: relative; -// text-decoration: none; -// display: block; -// overflow: hidden; -// color: #21212194; -// font-weight: 400; -// max-width: 290px; -// min-width: 290px; -// padding: 0rem .4rem; -// span { -// white-space: nowrap; -// overflow: hidden; -// text-overflow: ellipsis; -// display: inline-block; -// width: 100%; +// &:hover, +// &.docs-active { +// .link-name { +// background-color: #ececec; +// border-radius: 6px; +// cursor: pointer;; +// // color: #0c7489; +// } +// // color: mat-color($primary, if($is-dark-theme, 200, default)); +// } // } // } -.selected { - color: #212121 !important; - font-weight: 700 !important; - opacity: 1 !important; -} - -// .docs-level-mat-expansion-panel { -// margin-left: 12px; +// .docs-toc-heading { +// margin: 0; +// padding: 0; +// font-size: 13px; +// font-weight: bold; // } -.docs-level-h5 { - margin-left: 24px; -} +// .table-item-actions{ +// // display: none; +// display: inline-block; +// visibility: hidden; +// } - -.table-item-actions{ - // display: none; - display: inline-block; - visibility: hidden; -} - -.table-item:hover { - .table-item-actions{ - // display: inline-block; - visibility: visible; - } -} +// .table-item:hover { +// .table-item-actions{ +// // display: inline-block; +// visibility: visible; +// } +// } // .table-item col{ // text-overflow: ellipsis; @@ -117,49 +81,6 @@ overflow: hidden; } -.link-box { - padding: 20px 10px; - border-bottom: solid 1px #ccc; - color: rgba(0, 0, 0, 0.87); - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - box-sizing: border-box; - cursor: move; - background: white; - font-size: 14px; -} - -.cdk-drag-preview { - background-color: #FFF; - box-sizing: border-box; - border-radius: 4px; - box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), - 0 8px 10px 1px rgba(0, 0, 0, 0.14), - 0 3px 14px 2px rgba(0, 0, 0, 0.12); - - .add-new-entry{ - display: none; - } -} - -.cdk-drag-placeholder { - opacity: 0; - // background-color: black; -} - -.cdk-drag-animating { - transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); -} - -.link-box:last-child { - border: none; -} - -.cdk-link-list.cdk-drop-list-dragging .link-box:not(.cdk-drag-placeholder) { - transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); -} $blue-color : #129D99; 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 57080ed5c..922f1d050 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 @@ -3,7 +3,7 @@ import { DOCUMENT } from '@angular/common'; import { Component, EventEmitter, Inject, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; import { BaseComponent } from '@common/base/base.component'; -import { Foo, ToCEntry, ToCEntryType } from '../table-of-contents-entry'; +import { NewEntryType, ToCEntry, ToCEntryType } from '../table-of-contents-entry'; @Component({ selector: 'app-dataset-profile-table-of-contents-internal-section', @@ -14,10 +14,9 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent @Input() links: ToCEntry[]; @Output() itemClick = new EventEmitter(); - @Output() newEntry = new EventEmitter(); @Output() removeEntry = new EventEmitter(); - @Output() createFooEntry = new EventEmitter(); + @Output() createFooEntry = new EventEmitter(); @Output() dataNeedsRefresh = new EventEmitter(); @@ -35,10 +34,10 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent @Input() viewOnly: boolean; // @Input() dropListGroup: Set = new Set(); - @Input() dropListGroup: string[]; + // @Input() dropListGroup: string[]; - @Input() dragHoveringOver: boolean = false; - @Input() depth: number = 0; + // @Input() dragHoveringOver: boolean = false; + // @Input() depth: number = 0; // @Input() dropListStruct: { id: string, depth: number}[] = []; @@ -49,60 +48,25 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent tocEntryType = ToCEntryType; - // showStructs(){ - // console.log(this.dropListStruct.sort(this.compareFn)); + + // compareFn(a, b){ + // if(a.depth> b.depth) return -1; + // if(a.depth< b.depth) return 1; + + // return 0; // } - // get orderedListGroup(){ - // return this.dropListStruct.sort(this.compareFn).map(element=> element.id); - // } - - - compareFn(a, b){ - if(a.depth> b.depth) return -1; - if(a.depth< b.depth) return 1; - - return 0; - } - ngOnInit(): void { - // if(this.parentLink.id && this.dropListGroup){ - // if(!this.dropListGroup.includes(this.parentLink.id)){ - // this.dropListGroup.unshift(this.parentLink.id);//TODO - // } - // } - - // this.dropListStruct.push({ - // id: this.parentLink.id, - // depth: this.depth - // }); - - // if(this.links){ - // this.links.forEach(link=>{ - // this.dropListGroup.push(link.id); - // }) - // } - - - - // this.dropListGroup.add(this.parentLink.id) } - showDroplists(){ - console.log(this.dropListGroup); - } + // hoveroverEnter(){ + // // console.log('user hovering drag over', this.parentLink.id, this.parentLink.label); + // this.dragHoveringOver = true; + // } + // hoveroverLeft(){ + // this.dragHoveringOver = false; + // } - hoveroverEnter(){ - // console.log('user hovering drag over', this.parentLink.id, this.parentLink.label); - this.dragHoveringOver = true; - } - hoveroverLeft(){ - this.dragHoveringOver = false; - } - - fellowContainers(){ - return this.dropListGroup.filter(dl=> dl != this.parentLink.id); - } ngOnChanges(changes: SimpleChanges) { } @@ -119,30 +83,30 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent this.removeEntry.emit(currentLink); } - createNewEntry(foo: Foo){ + createNewEntry(foo: NewEntryType){ this.createFooEntry.emit(foo); } - tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ + // tocEntryIsChildOf(testingChild: ToCEntry,parent: ToCEntry): boolean{ - if(!testingChild || !parent) return false; + // if(!testingChild || !parent) return false; - if(testingChild.id == parent.id){return true;} + // if(testingChild.id == parent.id){return true;} - if(parent.subEntries){ - let childFound:boolean = false; + // if(parent.subEntries){ + // let childFound:boolean = false; - parent.subEntries.forEach(subEntry=>{ - if(this.tocEntryIsChildOf(testingChild, subEntry)){ - childFound = true; - return true; - } - }) + // parent.subEntries.forEach(subEntry=>{ + // if(this.tocEntryIsChildOf(testingChild, subEntry)){ + // childFound = true; + // return true; + // } + // }) - return childFound; - } - return false; - } + // return childFound; + // } + // return false; + // } get selectedItemInLinks(){ if(!this.links || !this.itemSelected) return false; @@ -158,59 +122,59 @@ export class DatasetProfileTableOfContentsInternalSection extends BaseComponent // return this.dropListGroup; // } - drop(event: CdkDragDrop) { - // if(!this.links || !this.links.length) return; + // drop(event: CdkDragDrop) { + // // if(!this.links || !this.links.length) return; - if(event.container === event.previousContainer){ - moveItemInArray(this.links, event.previousIndex, event.currentIndex); + // if(event.container === event.previousContainer){ + // moveItemInArray(this.links, event.previousIndex, event.currentIndex); - let arrayToUpdate: FormArray = this.links[0].form.parent as FormArray; - // if(this.parentLink && this.parentLink.form){ - // switch(this.parentLink.subEntriesType){ - // case this.tocEntryType.Field: - // arrayToUpdate = (this.parentLink.form.get('fields') as FormArray); - // break; - // case this.tocEntryType.FieldSet: - // arrayToUpdate = (this.parentLink.form.get('fieldSets') as FormArray); - // break; - // case this.tocEntryType.Section: - // arrayToUpdate = (this.parentLink.form.get('sections') as FormArray); - // break - // } + // let arrayToUpdate: FormArray = this.links[0].form.parent as FormArray; + // // if(this.parentLink && this.parentLink.form){ + // // switch(this.parentLink.subEntriesType){ + // // case this.tocEntryType.Field: + // // arrayToUpdate = (this.parentLink.form.get('fields') as FormArray); + // // break; + // // case this.tocEntryType.FieldSet: + // // arrayToUpdate = (this.parentLink.form.get('fieldSets') as FormArray); + // // break; + // // case this.tocEntryType.Section: + // // arrayToUpdate = (this.parentLink.form.get('sections') as FormArray); + // // break + // // } - // } - if(arrayToUpdate.controls){ - moveItemInArray(arrayToUpdate.controls, event.previousIndex, event.currentIndex); - //update ordinality - arrayToUpdate.controls.forEach((element,idx ) => { - element.get('ordinal').setValue(idx); - element.updateValueAndValidity(); - }); - } + // // } + // if(arrayToUpdate.controls){ + // moveItemInArray(arrayToUpdate.controls, event.previousIndex, event.currentIndex); + // //update ordinality + // arrayToUpdate.controls.forEach((element,idx ) => { + // element.get('ordinal').setValue(idx); + // element.updateValueAndValidity(); + // }); + // } - this.dataNeedsRefresh.emit(); - }else{ - console.log('not same container'); - } + // this.dataNeedsRefresh.emit(); + // }else{ + // console.log('not same container'); + // } - console.log(event.container.id); + // console.log(event.container.id); - } + // } onDataNeedsRefresh(){ this.dataNeedsRefresh.emit(); } - get hoveringOverParent(){ - if(!this.overContainerId) return false; - const child = this._findTocEntryById(this.overContainerId, this.parentLink.subEntries); - if(!child) return false; - return true; - } + // get hoveringOverParent(){ + // if(!this.overContainerId) return false; + // const child = this._findTocEntryById(this.overContainerId, this.parentLink.subEntries); + // if(!child) return false; + // return true; + // } - private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ + public _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{ if(!tocentries){ return null; } 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 1ebc7a9fc..c88f0a71b 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,16 +1,14 @@ -
- +

{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.TEMPLATE-OUTLINE' | translate}}

(); - @Output() newEntry = new EventEmitter(); - @Output() removeEntry = new EventEmitter(); - - - @Output() createEntry = new EventEmitter();//TODO - - @Output() dataNeedsRefresh = new EventEmitter(); - @Input() itemSelected: ToCEntry; @Input() colorizeInvalid: boolean = false; - - // @Input() set itemSelected(entry:ToCEntry){ - // this._itemSelected = entry; - // }; - // get itemSelected():ToCEntry{ - // return this._itemSelected; - // } - - // private _itemSelected:ToCEntry; - - - @Input() viewOnly: boolean; - show: boolean = false; + + + @Output() itemClick = new EventEmitter(); + // @Output() newEntry = new EventEmitter(); + @Output() removeEntry = new EventEmitter(); + @Output() createEntry = new EventEmitter(); + @Output() dataNeedsRefresh = new EventEmitter(); + isDragging: boolean = false; draggingItemId: string = null; - tocEntryType = ToCEntryType; DRAGULA_ITEM_ID_PREFIX="table_item_id_"; ROOT_ID: string = "ROOT_ID";//no special meaning private _dragStartedAt; private VALID_DROP_TIME = 500;//ms + overcontainer: string = null; constructor( @Inject(DOCUMENT) private _document: Document, @@ -80,8 +49,6 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn private language: TranslateService ) { super(); - - if(this.dragulaService.find('TABLEDRAG')){ this.dragulaService.destroy('TABLEDRAG'); @@ -456,7 +423,7 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn drake.on('drag',(el,source)=>{ this._dragStartedAt = new Date().getTime(); - console.log('drag fired'); + // console.log('drag fired'); this.isDragging = true; this.draggingItemId = (el.id as string).replace(this.DRAGULA_ITEM_ID_PREFIX, ''); @@ -484,10 +451,6 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn } - - - overcontainer: string = null; - private _scrollIntoDragginItem(id: string){ // const table = document.getElementById('tocentrytable'); @@ -561,23 +524,15 @@ export class DatasetProfileTableOfContents extends BaseComponent implements OnIn this.itemClick.emit(item); } - // propagateClickToParent(childIds:ToCEntry[], currentItem: ToCEntry){ - // childIds.push(currentItem); - // this.itemClick.emit(childIds); + // addNewEntry(tce: ToCEntry){ + // this.newEntry.emit(tce); // } - - - addNewEntry(tce: ToCEntry){ - this.newEntry.emit(tce); - } deleteEntry(currentLink: ToCEntry){ this.removeEntry.emit(currentLink); } - - - createNewEntry(foo: Foo){ - this.createEntry.emit(foo); + createNewEntry(newEntry: NewEntryType){ + this.createEntry.emit(newEntry); } onDataNeedsRefresh(){ this.dataNeedsRefresh.emit(); 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 59d9a89a5..b6cf4e15d 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 @@ -335,8 +335,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit { this.multipleAutoCompleteConfiguration = { filterFn: myfunc.bind(this), initialItems: (extraData) => myfunc(''), - displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label']}catch{return''}}, - titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)['label'] : item['label']}catch{return''}}, + displayFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title]}catch{return''}}, + titleFn: (item) => { try{return typeof (item) == 'string' ? JSON.parse(item)[title] : item[title]}catch{return''}}, valueAssign: (item) => { try{return typeof (item) == 'string' ? item : JSON.stringify(item)}catch{return''}}, subtitleFn: (item) => { try{return item[subtitle]}catch{return''}} } diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index 08c5c95db..adeb3eb94 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 6639552be..efbd317d3 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index f14ed0b98..284c21235 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 07400c2e3..18618c198 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index ef0a82272..107ada514 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index 1fbf650fc..2a86bd292 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 5f684e3b5..9d8816e7c 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 64dd48505..5b35c6215 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -520,6 +520,9 @@ "MULTIPLICITY": "Multiplicity", "MORE": "More.." } + }, + "FEEDBACK-MESSAGES":{ + "SAVE-SUCCESS":"Changes were saved successfully." } }, "GRANT-LISTING": { From b04e2b3482e17544c0c819fbfd1cfe7a418dfa5f Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Thu, 1 Apr 2021 18:57:23 +0300 Subject: [PATCH 2/2] Dataset profile Editor. Ui fixes. Visibility Rules fix. --- .../core/model/dataset/dataset-id.model.ts | 5 ++ .../admin/rule-editor-model.ts | 6 +- ...rofile-editor-composite-field.component.ts | 5 +- ...ataset-profile-editor-field.component.html | 2 +- .../dataset-profile-editor-field.component.ts | 25 +++++- ...dataset-profile-editor-rule.component.html | 12 ++- .../dataset-profile-editor-rule.component.ts | 83 +++++++++++++++++-- ...ofile-editor-section-fieldset.component.ts | 3 +- .../dataset-profile-listing.component.scss | 3 +- .../table-of-contents-internal-section.html | 2 +- .../table-of-contents/table-of-contents.ts | 18 ++-- .../dmp-profile-listing.component.scss | 12 +-- .../user/listing/user-listing.component.scss | 2 +- .../listing/dataset-listing.component.scss | 14 ++-- .../ui/dmp/listing/dmp-listing.component.scss | 14 ++-- .../form-field/form-field.component.ts | 6 ++ dmp-frontend/src/assets/i18n/de.json | 8 +- dmp-frontend/src/assets/i18n/en.json | 8 +- dmp-frontend/src/assets/i18n/es.json | 8 +- dmp-frontend/src/assets/i18n/gr.json | 8 +- dmp-frontend/src/assets/i18n/pt.json | 8 +- dmp-frontend/src/assets/i18n/sk.json | 8 +- dmp-frontend/src/assets/i18n/sr.json | 8 +- dmp-frontend/src/assets/i18n/tr.json | 8 +- .../src/assets/splash/about/how-it-works.html | 4 +- 25 files changed, 210 insertions(+), 70 deletions(-) diff --git a/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts b/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts index 5020bbbcb..1063a3cbf 100644 --- a/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts +++ b/dmp-frontend/src/app/core/model/dataset/dataset-id.model.ts @@ -6,11 +6,16 @@ export class DatasetIdModel { type: string; constructor(data: any) { + try{ const parsed = JSON.parse(data); if (!isNullOrUndefined(parsed)) { this.identifier = parsed.identifier; this.type = parsed.type; } + } + catch(error){ + console.warn('Could not parse DatasetIdModel'); + } } buildForm(): FormGroup { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts index 6d029f80e..6e878666c 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/rule-editor-model.ts @@ -1,4 +1,4 @@ -import { FormGroup } from "@angular/forms"; +import { FormGroup, Validators } from "@angular/forms"; import { Rule } from "../../../../core/model/admin/dataset-profile/dataset-profile"; import { BaseFormModel } from "../../../../core/model/base-form-model"; @@ -21,9 +21,9 @@ export class RuleEditorModel extends BaseFormModel { buildForm(disabled: boolean = false, skipDisable: Array = []): FormGroup { const formGroup = this.formBuilder.group({ // sourceField: [this.sourceField], - target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }], + target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }, [Validators.required]], ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }], - value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }], + value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }, [Validators.required]], ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }], valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }] }); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts index da00e51bb..2b5a1f2fe 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, Input, OnChanges, OnInit } from '@angular/core'; import { AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'; import { FieldEditorModel } from '../../../admin/field-editor-model'; import { Guid } from '@common/types/guid'; @@ -73,6 +73,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh viewStyleEnum = DatasetProfileFieldViewStyle; viewTypeEnum = ViewStyleType; + private myCustomValidators:EditorCustomValidators = new EditorCustomValidators(); constructor( @@ -245,7 +246,6 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh } - // generatePreview(){ // const editorModel = new DatasetDescriptionCompositeFieldEditorModel(); // editorModel.title = this.form.get('title').value; @@ -806,7 +806,6 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit, OnCh } (this.form.get('fields')).push(new FieldEditorModel().fromModel(field).buildForm()); - // fieldForm.get('viewStyle').get('renderStyle').updateValueAndValidity(); // fieldForm.get('data').updateValueAndValidity(); 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 ef6136738..2045e38f4 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 @@ -9,7 +9,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
  • +
  • visibility
  • diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts index 4ca3a48ec..4e5684788 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts @@ -380,7 +380,25 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements // }); }; - + get canApplyVisibility():boolean{ + + + switch(this.viewType){ + case this.viewTypeEnum.TextArea: + case this.viewTypeEnum.FreeText: + case this.viewTypeEnum.BooleanDecision: + case this.viewTypeEnum.RadioBox: + case this.viewTypeEnum.Select: + case this.viewTypeEnum.CheckBox: + case this.viewTypeEnum.DatePicker: + return true; + + } + + + return false; + + } // validTicket:string; // generatePreview(){ @@ -417,6 +435,9 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements const field: Field = this.form.getRawValue(); field.defaultValue = {type:null, value: null}; + if(!this.canApplyVisibility){ + field.visible.rules = []; + } @@ -767,6 +788,8 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements fields.removeAt(index); fields.insert(index, form); this.form = form; + + } setTimeout(() => { //TODO diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html index 7ce02a6bf..dd2a26762 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.html @@ -25,7 +25,7 @@ {{'DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.FIELDS.RULE-THEN'| translate}} - + + [disabled]="parentIds.includes(option.id) || hiddenBy.includes(option.id)" + [matTooltip]="getToolTipMessage(option.id)" + [matTooltipShowDelay]="700" + > {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}}
    @@ -55,7 +58,10 @@ + [disabled]="parentIds.includes(option.id) ||hiddenBy.includes(option.id)" + [matTooltip]="getToolTipMessage(option.id)" + [matTooltipShowDelay]="700" + > {{option.label? option.label:'<'+ ('DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) + '>'}}
    diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts index bb9cb6463..14963db30 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/rule/dataset-profile-editor-rule.component.ts @@ -1,8 +1,10 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; import { FormArray, FormControl, FormGroup } from '@angular/forms'; import { DatasetProfileFieldViewStyle } from '../../../../../../core/common/enum/dataset-profile-field-view-style'; import { DatasetProfileComboBoxType } from '../../../../../../core/common/enum/dataset-profile-combo-box-type'; import { ToCEntryType } from '../../../table-of-contents/table-of-contents-entry'; +import { Rule } from '@app/core/model/admin/dataset-profile/dataset-profile'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-dataset-profile-editor-rule-component', @@ -12,6 +14,7 @@ import { ToCEntryType } from '../../../table-of-contents/table-of-contents-entry export class DatasetProfileEditorRuleComponent implements OnInit{ + @Input() form: FormArray; @Input() viewStyleForCheck: DatasetProfileFieldViewStyle; @@ -20,6 +23,16 @@ export class DatasetProfileEditorRuleComponent implements OnInit{ @Input() comboBoxTypeForCheck: DatasetProfileComboBoxType; @Input() viewOnly: boolean; + + options: OptionItem[]; + sectionOptions: OptionItem[]; + fieldSetOptions: OptionItem[]; + fieldOptions: OptionItem[]; + + constructor(private language: TranslateService){ + + } + targetValidation() { //TODO } @@ -29,8 +42,11 @@ export class DatasetProfileEditorRuleComponent implements OnInit{ } ngOnInit(): void { + this._computeOptions(); + } + + private _computeOptions(){ this.options = this.getOptions(); - // TODO TO SEE IF THE COMPONENT IS NOT DESTROYED AND THE FORM UPDATES this.sectionOptions = []; this.fieldOptions = []; @@ -50,12 +66,39 @@ export class DatasetProfileEditorRuleComponent implements OnInit{ break; } }); + //remove options to hide if given fieldset is already hidden by option + this.fieldOptions.forEach(e=>this._buildHiddenBy(e)); + this.fieldSetOptions.forEach(e=>this._buildHiddenBy(e)); } - options: OptionItem[]; - sectionOptions: OptionItem[]; - fieldSetOptions: OptionItem[]; - fieldOptions: OptionItem[]; + + + + computeOptions(isOpened: boolean){ + if(isOpened){ + this._computeOptions(); + } + } + + private _buildHiddenBy(fo:OptionItem){ + try{ + this.fieldOptions.forEach(foption=>{ + const rules = (foption.form.get('visible').get('rules') as FormArray).controls.map(c=>(c as FormGroup).getRawValue()) as Rule[] + const targets = rules.map(rule=>rule.target); + targets.forEach(target=>{ + if(fo.parentsIds.includes(target) && !fo.hiddenBy.includes(foption.id)){ + fo.hiddenBy.push(...foption.parentsIds); + } + }) + + }); + }catch{ + console.log('error'); + } + } + + + getOptions():OptionItem[]{ @@ -96,7 +139,9 @@ export class DatasetProfileEditorRuleComponent implements OnInit{ type: type, label: type ===ToCEntryType.Field? form.get('data').get('label').value :form.get('title').value, // parentsIds: [form.get('id').value] - parentsIds: [...parentIds, form.get('id').value] + parentsIds: [...parentIds, form.get('id').value], + form: form, + hiddenBy:[] } result.push(currentOptionItem); @@ -130,6 +175,26 @@ export class DatasetProfileEditorRuleComponent implements OnInit{ } return []; } + get hiddenBy(): string[]{ + if(!this.formControlForCheck.get('id')) return []; + + const current = this.options.find(opt=> opt.id === this.formControlForCheck.get('id').value); + + if(current){ + return current.hiddenBy; + } + return []; + } + + getToolTipMessage(id: string){ + if(this.parentIds.includes(id)){ + // return 'Cannot hide element that contain the field'; + return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-CHILD-OF-TARGET'); + }else if(this.hiddenBy.includes(id)){ + return this.language.instant('DATASET-PROFILE-EDITOR.STEPS.FORM.RULE.HINTS.ELEMENT-HIDDEN-FROM-ELEMENT'); + } + return ''; + } } @@ -138,5 +203,7 @@ interface OptionItem{ id: string, label: string, type: ToCEntryType, - parentsIds: string[] + parentsIds: string[], + form:FormGroup, + hiddenBy:string[] } \ No newline at end of file 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 4876d2e42..ea6b8089f 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 @@ -118,7 +118,8 @@ export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnC this.numbering = this.tocentry.numbering; this._selectedFieldSetId = null; - this._scrollToElement(this.tocentry.id); + // this._scrollToElement(this.tocentry.id); + this._scrollOnTop(); }else if(this.tocentry.type === ToCEntryType.FieldSet){ this.form = this.tocentry.form.parent.parent; const numberingArray = this.tocentry.numbering.split('.'); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss index 8026d4970..456be7372 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.scss @@ -69,10 +69,11 @@ mat-row:hover { // // background-color: #eef0fb; // } -::ng-deep .mat-paginator-container { +:host ::ng-deep .mat-paginator-container { flex-direction: row-reverse !important; justify-content: space-between !important; background-color: #f6f6f6; + align-items: center; // height: 30px; // min-height: 30px !important; } 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 6eab86109..72a3d7179 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 @@ -72,7 +72,7 @@
    stringValue).replace(new RegExp('{', 'g'), '{"').replace(new RegExp('=', 'g'), '":"').replace(new RegExp(',', 'g'), '",').replace(new RegExp(', ', 'g'), ', "').replace(new RegExp('}', 'g'), '"}'); @@ -397,6 +400,9 @@ export class FormFieldComponent extends BaseComponent implements OnInit { } const tagArray = JSON.parse(stringValue); this.form.patchValue({'value': tagArray}); + }catch(e){ + console.warn('Could not parse tags'); + } } filterTags(value: string): Observable { diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index adeb3eb94..879fccd01 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -468,6 +468,10 @@ "RULE-THEN": "then show Field With Id", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index efbd317d3..3c6d4e1a4 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -468,6 +468,10 @@ "RULE-THEN": "then show Field With Id", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 284c21235..13d676603 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -468,6 +468,10 @@ "RULE-THEN": "entonces muestra el campo con identificación", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 18618c198..ab983afeb 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -468,6 +468,10 @@ "RULE-THEN": "τότε δείξε το Πεδίο με ταυτοποίηση", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 107ada514..04a41867c 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -468,6 +468,10 @@ "RULE-THEN": "então mostrar Campo com o Id", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index 2a86bd292..0140d68cd 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -468,6 +468,10 @@ "RULE-THEN": "then show Field With Id", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 9d8816e7c..3aacf3569 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -468,6 +468,10 @@ "RULE-THEN": "tada prikazati polje sa Id", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 5b35c6215..956b83b7a 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -468,6 +468,10 @@ "RULE-THEN": "sonra alanı kimliği ile göster", "FIELDSETS": "Questions", "FIELDS":"Inputs" + }, + "HINTS":{ + "ELEMENT-CHILD-OF-TARGET":"This element is parent of selected input.", + "ELEMENT-HIDDEN-FROM-ELEMENT":"This element hides the element or a parent element of the input you are trying to apply visibility rule from." } }, "FORM-VALIDATION":{ @@ -515,8 +519,8 @@ "FIELDSET": { "ADD-INPUT": "Add new input", "COMMENT-FIELD": "Comment field", - "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the givven question.", - "ENABLE-MULTIPLICITY": "User may provide more than one answer to the givven question.", + "INCLUDE-COMMENT-FIELD": "A comment field input is appended to the given question.", + "ENABLE-MULTIPLICITY": "User may provide more than one answer to the given question.", "MULTIPLICITY": "Multiplicity", "MORE": "More.." } diff --git a/dmp-frontend/src/assets/splash/about/how-it-works.html b/dmp-frontend/src/assets/splash/about/how-it-works.html index 704a265a3..31beaf045 100644 --- a/dmp-frontend/src/assets/splash/about/how-it-works.html +++ b/dmp-frontend/src/assets/splash/about/how-it-works.html @@ -180,7 +180,7 @@
    -
    +
    -
    +
    DMP editor DMP outputs Dataset editor