prefill popup refactor

This commit is contained in:
Diamantis Tziotzios 2024-02-28 15:41:36 +02:00
parent be796bc68f
commit 067e81207f
19 changed files with 738 additions and 208 deletions

View File

@ -1,21 +1,27 @@
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { AnnotationProtectionType } from "@app/core/common/enum/annotation-protection-type.enum";
import { User } from "@app/core/model/user/user";
import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
import { Guid } from "@common/types/guid";
export interface Annotation {
id: Guid;
entityId: Guid;
entityType: string;
anchor?: string;
payload: string;
createdAt: Date;
updatedAt: Date;
isActive: IsActive;
export interface Annotation extends BaseEntity {
entityId: Guid;
entityType: string;
anchor?: string;
payload: string;
timeStamp: Date;
author: User;
threadId: Guid;
parent: Annotation;
protection: AnnotationProtectionType;
}
export interface AnnotationPersist {
subjectId: Guid;
entityId: Guid;
entityType: string;
anchor: string;
payload: string;
export interface AnnotationPersist extends BaseEntityPersist {
subjectId: Guid;
entityId: Guid;
entityType: string;
anchor: string;
payload: string;
threadId?: Guid;
parentId?: Guid;
protection: AnnotationProtectionType;
}

View File

@ -0,0 +1,4 @@
export enum AnnotationEntityType {
Description = "description",
Dmp = "dmp"
}

View File

@ -0,0 +1,4 @@
export enum AnnotationProtectionType {
Private = 0,
EntityAccessors = 1
}

View File

@ -0,0 +1,149 @@
<div class="container form-container">
<div class="annotation-viewer row">
<!-- Create New Thread -->
<!-- <div *ngIf="this.canEdit && !this.isDeleted" class="col-12"> -->
<div class="col-12">
<form class="row p-2 mt-2 mb-3 ml-0 pr-3 mr-0 new-thread" [formGroup]="threadFormGroup">
<mat-form-field class="col msg-input">
<textarea matInput matTextareaAutosize matAutosizeMinRows="1" name="thread-text" formControlName="text" placeholder="{{'APP.ANNOTATION.THREADS.NEW-THREAD' | translate}}" required></textarea>
<mat-error *ngIf="threadFormGroup.get('text').hasError('backendError')">{{threadFormGroup.get('text').getError('backendError')?.message}}</mat-error>
<mat-error *ngIf="threadFormGroup.get('text').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <mat-form-field class="col-auto pl-0 pr-0 protection-input">
<mat-label>{{'APP.ANNOTATION.THREADS.PROTECTION.TITLE' | translate}}</mat-label>
<mat-select name="thread-annotationProtectionType" formControlName="annotationProtectionType" required>
<mat-option *ngFor="let enumValue of annotationProtectionTypeEnumValues" [value]="enumValue">{{enumUtils.toAnnotationProtectionTypeString(enumValue)}}</mat-option>
</mat-select>
<mat-error *ngIf="threadFormGroup.get('annotationProtectionType').hasError('backendError')">{{threadFormGroup.get('annotationProtectionType').getError('backendError')?.message}}</mat-error>
<mat-error *ngIf="threadFormGroup.get('annotationProtectionType').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> -->
<div class="col-auto send-msg">
<button mat-raised-button type="button" (click)="createThread()">
<i class="fa fa-paper-plane"></i> {{'APP.ANNOTATION.THREADS.SEND' | translate}}
</button>
</div>
</form>
</div>
<div class="col-12 mb-3 pt-2 gr-color" *ngIf="threads?.length > 0">{{'APP.ANNOTATION.TITLE' | translate}}</div>
<div class="col-12">
<div *ngFor="let thread of threads" class="row">
<!-- Parent Thread -->
<div class="col-12">
<div class="row parent-thread m-0 h-100">
<div class="col-auto pr-0 pl-0">
<div class="side-color"></div>
</div>
<div class="col">
<div class="row reply-content">
<div class="col-12">
<div class="row h-100">
<div class="col annotation-time">{{thread.timeStamp | date:'EEEE, MMMM d, y, h:mm a'}}</div>
<div class="col-auto" *ngIf="thread.protection === 0" matTooltip="{{'APP.ANNOTATION.PROTECTION.PRIVATE' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-auto" *ngIf="thread.protection === 1" matTooltip="{{'APP.ANNOTATION.PROTECTION.UNIT' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-auto" *ngIf="thread.protection === 65535" matTooltip="{{'APP.ANNOTATION.PROTECTION.PUBLIC' | translate}}"><i class="material-icons protection-icon icon-{{getAnnotationProtectionType(thread)}}">{{getAnnotationProtectionType(thread)}}</i></div>
<div class="col-md-12 annotation-full-text">{{thread.text}}</div>
<div class="col-md-12">
<em class="user">{{'APP.ANNOTATION.THREADS.FROM-USER' | translate}} {{thread.author.name}}</em>
<!-- <em>{{thread.author.name}}</em> -->
<!-- |
<em class="gr-color">{{'APP.ANNOTATION.THREADS.UNIT' | translate}}</em> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Previous Replies -->
<div class="col-12">
<div *ngFor="let annotation of annotationsPerThread[thread.threadId]; let i = index;" class="row replies">
<div class="col-auto pr-0">
<div class="col reply child"></div>
<div class="col reply child dummy-for-next-child" *ngIf="i != annotationsPerThread[thread.threadId].length - 1"></div>
</div>
<div class="col pl-0 pt-1">
<div class="parent row m-0">
<div class="col-auto pl-0 pr-0">
<div class="side-soft-color"></div>
</div>
<div class="col reply-content">
<div class="row h-100">
<div class="col-md-12 annotation-time">{{annotation.timeStamp | date:'EEEE, MMMM d, y, h:mm a'}}</div>
<div class="col-md-12 annotation-full-text">{{annotation.text}}</div>
<div class="col-md-12">
<em class="gr-color">{{'APP.ANNOTATION.THREADS.FROM-USER' | translate}}</em>
{{annotation.author.name}}
<!-- |
<em class="gr-color">{{'APP.ANNOTATION.THREADS.UNIT' | translate}}</em> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Type reply in thread -->
<div *ngIf="this.canEdit && !this.isDeleted" class="col-12">
<div class="row new-reply mr-0">
<mat-form-field class="col pt-2 pb-2 pr-0">
<textarea matInput matTextareaAutosize matAutosizeMinRows="1" [formControl]="this.threadReplyTextsFG[thread.id.toString()].get('replyText')" placeholder="{{'APP.ANNOTATION.THREADS.REPLY' | translate}}"></textarea>
<mat-error *ngIf="this.threadReplyTextsFG[thread.id.toString()]?.get('replyText')?.hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-auto send-msg">
<button class="form-field-margin" mat-icon-button type="button" color="accent" (click)="replyThread(thread.threadId, thread.protection)" matTooltip="{{'APP.ANNOTATION.THREADS.REPLY' | translate}}">
<i class="fa fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row d-flex justify-content-between align-items-center m-0">
<div class="col-auto"><a class="logo"><img class="logo" src="../../../assets/images/new-dmp-logo.png" onerror="this.style.display='none'"></a></div>
<div class="col-auto ml-auto close-btn" (click)="close()">
<mat-icon class="close-icon">close</mat-icon>
</div>
</div>
<div class="row content">
<!-- {{annotations | json}} -->
<div class="col-12">
<h1 mat-dialog-title class="title p-0">{{'NAV-BAR.START-NEW-DMP' | translate}}</h1>
</div>
<div class="col-12">
<p class="text">{{'NAV-BAR.START-NEW-DMP-TXT' | translate}}</p>
</div>
<div class="col-12">
<div class="row d-flex justify-content-between align-items-center">
<div class="col-auto">
<!-- <button type="button" class="normal-btn upload-btn d-flex flex-row align-items-center" (click)="uploadFile($event)">
<mat-icon class="pr-2">file_upload</mat-icon>
{{ 'NAV-BAR.IMPORT-FROM-FILE' | translate }}
</button> -->
</div>
<div class="col-auto pl-0 pr-0">
<p class="">{{ 'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate }}</p>
</div>
<div class="col-auto">
<!-- <button type="button" class="normal-btn font-weight-bold d-flex flex-row align-items-center" (click)="startWizard()">
<mat-icon>chevron_right</mat-icon>
{{ 'NAV-BAR.START-WIZARD' | translate }}
</button> -->
</div>
</div>
</div>
</div>
<div class="row m-0 pt-4">
<div class="col-auto">
<mat-icon class="material-icons-outlined warn">info</mat-icon>
</div>
<span class="col">
<b>{{'GENERAL.START-NEW-DMP-DIALOG.IMPORT' | translate }}</b> {{'GENERAL.START-NEW-DMP-DIALOG.FUNCTION-SUPPORTS' | translate }}
<b>{{'GENERAL.START-NEW-DMP-DIALOG.JSON-FILES' | translate }}</b> {{'GENERAL.START-NEW-DMP-DIALOG.PRODUCED' | translate }}
<b><a href="https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard" target="_blank">{{'GENERAL.START-NEW-DMP-DIALOG.RDA-SPECIFICATIONS' | translate }}</a></b>
{{'GENERAL.START-NEW-DMP-DIALOG.MACHINE-ACTIONABLE' | translate }}
</span>
</div>
</div>

View File

@ -0,0 +1,68 @@
::ng-deep .mat-dialog-container {
border-radius: 8px;
}
.form-container {
width: 33rem;
min-height: 14rem;
padding: 0.28rem 0.34rem 0.875rem 0.625rem;
}
.logo {
width: 8.44rem;
}
.close-icon {
cursor: pointer;
// margin-right: 20px;
padding: .4rem;
width: auto !important;
height: auto !important;
}
.close-icon:hover {
background-color: #ECECED !important;
border-radius: 50%;
}
.content {
margin: 2.17rem 2.304rem 1.1875rem 3.065rem;
}
.title,
.text {
font-size: 1.25rem;
font-weight: lighter;
color: #000000;
opacity: 0.8;
}
.title {
font-size: 2.375rem;
margin-bottom: 1.1875rem;
}
.text {
margin-bottom: 2.9375rem;
line-height: 1.9rem;
}
.upload-btn {
background-color: white;
color: #212121;
font-weight: bold;
box-shadow: 0px 3px 6px #1e202029;
border: 2px solid #212121;
}
.actions {
width: 26.667rem;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.warn {
color: #f16868;
}

View File

@ -0,0 +1,197 @@
import { HttpClient } from '@angular/common/http';
import { Component, Inject } from '@angular/core';
import { FormBuilder, FormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { Annotation, AnnotationPersist } from '@annotation-service/core/model/annotation.model';
import { AnnotationLookup } from '@annotation-service/core/query/annotation.lookup';
import { AnnotationService } from '@annotation-service/services/http/annotation.service';
import { AnnotationProtectionType } from '@app/core/common/enum/annotation-protection-type.enum';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
import { BaseComponent } from '@common/base/base.component';
import { FormService } from '@common/forms/form-service';
import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
@Component({
selector: 'app-start-new-dmp',
templateUrl: './annotation-dialog.component.html',
styleUrls: ['./annotation-dialog.component.scss']
})
export class AnnotationDialogComponent extends BaseComponent {
private entityId: Guid;
private anchor: string;
private entityType: string;
// public annotations: Array<Annotation> = [];
public threads = new Array<Annotation>();
public annotationsPerThread = {};
threadReplyTextsFG: Array<UntypedFormGroup>;
threadFormGroup: UntypedFormGroup;
private formBuilder: FormBuilder = new FormBuilder();
constructor(
public dialogRef: MatDialogRef<AnnotationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private router: Router,
public dialog: MatDialog,
private uiNotificationService: UiNotificationService,
private language: TranslateService,
private annotationService: AnnotationService,
private formService: FormService
) {
super();
this.entityId = data.entityId;
this.anchor = data.anchor;
this.entityType = data.entityType;
}
ngOnInit(): void {
// this.threadFormGroup = new UntypedFormGroup({
// text: new FormControl(null, [Validators.required]),
// annotationProtectionType: new FormControl(AnnotationProtectionType.Public, [Validators.required])
// });
// if (this.entityId != null) {
// this.loadThreads();
// }
}
createThread() {
// this.formService.removeAllBackEndErrors(this.threadFormGroup);
// this.formService.touchAllFormFields(this.threadFormGroup);
// if (!this.isFormValid(this.threadFormGroup)) {
// return;
// }
// const threadToCreate: AnnotationPersist = {
// payload: this.threadFormGroup.get('text').value,
// protection: this.threadFormGroup.get('annotationProtectionType').value,
// referenceId: this.referenceId
// };
// this.annotationService.persist(threadToCreate).pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
replyThread(threadId: Guid, threadProtection: AnnotationProtectionType) {
// // if (!this.threadReplyTexts[threadId.toString()] || this.threadReplyTexts[threadId.toString()].length === 0) { return; }
// this.formService.removeAllBackEndErrors(this.threadReplyTextsFG[threadId.toString()]);
// this.formService.touchAllFormFields(this.threadReplyTextsFG[threadId.toString()]);
// if (!this.isFormValid(this.threadReplyTextsFG[threadId.toString()])) {
// return;
// }
// const replyToCreate: AnnotationPersist = {
// threadId: threadId,
// text: this.threadReplyTextsFG[threadId.toString()].get('replyText').value,
// protection: threadProtection,
// referenceId: this.referenceId
// };
// this.annotationService.persist(replyToCreate).pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
private refreshAnnotations() {
// this.threadReplyTextsFG.forEach(element => {
// element.reset();
// });
this.loadThreads();
}
private loadThreads() {
const lookup: AnnotationLookup = new AnnotationLookup();
lookup.entityIds = [this.entityId];
// lookup.anchors = [this.anchor];
lookup.entityTypes = [this.entityType];
lookup.project = {
fields: [
nameof<Annotation>(x => x.id),
// nameof<Annotation>(x => x.threadId),
// nameof<Annotation>(x => x.threadId),
// nameof<Annotation>(x => x.timeStamp),
// nameof<Annotation>(x => x.author.name),
nameof<Annotation>(x => x.payload),
// nameof<Annotation>(x => x.protection),
]
};
this.annotationService.query(lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(
data => {
// this.annotationsPerThread = {};
// this.threadReplyTextsFG = new Array<UntypedFormGroup>();
// this.resetFormGroup();
// this.threads = data.items.filter(item => item.id === item.threadId).sort((a1, a2) => new Date(a2.timeStamp).getTime() - new Date(a1.timeStamp).getTime());
// this.threads.forEach(element => {
// // this.threadReplyTextsFG.addControl(element.id.toString(), new FormControl(null));
// this.threadReplyTextsFG[element.id.toString()] = this.fb.group({ replyText: new FormControl(null, [Validators.required]) });
// this.annotationsPerThread[element.id.toString()] = data.items.filter(x => x.threadId === element.id && x.id !== element.id).sort((a1, a2) => new Date(a1.timeStamp).getTime() - new Date(a2.timeStamp).getTime());
// });
// // this.annotationsChanged.emit(this.threads);
},
error => this.onCallbackError(error),
);
}
resetFormGroup() {
this.threadFormGroup.reset();
this.threadFormGroup.get('annotationProtectionType').setValue(AnnotationProtectionType.EntityAccessors);
}
isValidText(text: string): boolean {
return !isNullOrUndefined(text) && text.length !== 0 && text !== '';
}
// ngOnInit() {
// const lookup: AnnotationLookup = new AnnotationLookup();
// lookup.entityIds = [this.entityId];
// // lookup.anchors = [this.anchor];
// lookup.entityTypes = [this.entityType];
// this.annotationService.query(lookup).pipe(takeUntil(this._destroyed))
// .subscribe(
// data => {
// this.annotations = data.items;
// },
// error => this.onCallbackError(error)
// );
// }
private onCallbackSuccess() {
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-UPLOAD.UPLOAD-SUCCESS'), SnackBarNotificationLevel.Success);
this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans']));
// this.router.navigate(['/reload']).then(() => this.isPublic ? this.router.navigate(['/explore-plans']) : this.router.navigate(['/plans']));
}
private onCallbackError(error: any) {
this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error);
}
cancel() {
this.dialogRef.close();
}
send() {
this.dialogRef.close(this.data);
}
close() {
this.dialogRef.close(false);
}
startWizard() {
this.router.navigate(['/plans/new']);
this.close();
}
}

View File

@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { FormattingModule } from '@app/core/formatting.module';
import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module';
import { AnnotationDialogComponent } from './annotation-dialog.component';
@NgModule({
imports: [
CommonUiModule,
CommonFormsModule,
FormattingModule,
],
declarations: [
AnnotationDialogComponent,
],
exports: [
AnnotationDialogComponent,
]
})
export class AnnotationDialogModule { }

View File

@ -1,26 +1,27 @@
import { DatePipe } from '@angular/common';
import { Component, OnInit, ViewChild } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { DescriptionStatus } from '@app/core/common/enum/description-status';
import { DmpStatus } from '@app/core/common/enum/dmp-status';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { Description, DescriptionPersist } from '@app/core/model/description/description';
import { AuthService } from '@app/core/services/auth/auth.service';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { DescriptionService } from '@app/core/services/description/description.service';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { LockService } from '@app/core/services/lock/lock.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import {
SnackBarNotificationLevel,
UiNotificationService
} from '@app/core/services/notification/ui-notification-service';
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
import { DatePipe } from '@angular/common';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { AppPermission } from '@app/core/common/enum/permission.enum';
import { Description, DescriptionPersist } from '@app/core/model/description/description';
import { DescriptionService } from '@app/core/services/description/description.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
import { BaseEditor } from '@common/base/base-editor';
@ -34,12 +35,10 @@ import { map, takeUntil } from 'rxjs/operators';
import { DescriptionEditorModel, DescriptionPropertyDefinitionEditorModel } from './description-editor.model';
import { DescriptionEditorResolver } from './description-editor.resolver';
import { DescriptionEditorService } from './description-editor.service';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component';
import { ToCEntry } from './table-of-contents/models/toc-entry';
import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component';
import { ToCEntryType } from './table-of-contents/models/toc-entry-type.enum';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component';
@Component({
selector: 'app-description-editor-component',
@ -140,12 +139,18 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.route.params
.pipe(takeUntil(this._destroyed))
.subscribe((params: Params) => {
const isPublicDescription = params['public'];
const itemId = params['id'];
const dmpId = params['dmpId'];
const dmpSectionId = params['dmpSectionId'];
const isPublicDescription = params['public'];
const newDmpId = params['newDmpId'];
// const publicId = params['publicId'];
// this.dmpId = params['dmpId'];
// this.dmpSectionIndex = parseInt(params['dmpSectionIndex']);
@ -237,6 +242,29 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
// this.loadDescriptionProfiles();
// this.registerFormListeners();
});
} else if (dmpId != null && dmpSectionId != null) {
const dialogRef = this.dialog.open(PrefillDescriptionDialogComponent, {
width: '590px',
minHeight: '200px',
restoreFocus: false,
data: {
dmp: this.item.dmp,
dmpSectionId: dmpSectionId
},
panelClass: 'custom-modalbox'
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
// this.descriptionModel = this.descriptionModel.fromModel(result);
// this.descriptionModel.dmp = data;
// this.descriptionModel.dmpSectionIndex = this.dmpSectionIndex;
// this.formGroup = this.descriptionModel.buildForm();
// this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
// this.formGroup.get('dmp').disable();
// this.loadDescriptionProfiles();
// this.registerFormListeners();
}
})
}
// if (this.itemId != null && this.newDmpId == null) {

View File

@ -12,6 +12,7 @@ import { DescriptionFormProgressIndicationModule } from './form-progress-indicat
import { TableOfContentsModule } from './table-of-contents/table-of-contents.module';
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.module';
import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component';
@NgModule({
imports: [
@ -28,12 +29,13 @@ import { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module';
],
declarations: [
DescriptionEditorComponent,
DescriptionBaseFieldsEditorComponent
DescriptionBaseFieldsEditorComponent,
PrefillDescriptionDialogComponent
],
exports: [
],
providers: [
VisibilityRulesService
VisibilityRulesService,
]
})
export class DescriptionEditorModule { }

View File

@ -21,4 +21,4 @@
{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.VIEW-LESS' | translate}}
</span>
</div>
</div>
</div>

View File

@ -18,5 +18,4 @@ export class DescriptionFormFieldSetTitleComponent implements OnInit {
ngOnInit() {
}
}

View File

@ -1,6 +1,9 @@
<div *ngIf="fieldSet" class="dynamic-form-composite-field row">
<div *ngIf="showTitle" class="col-12">
<app-description-form-field-set-title class="row" [fieldSet]="fieldSet" [path]="path" [isChild]="isChild"></app-description-form-field-set-title>
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)">
<mat-icon matTooltip="{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.ANNOTATIONS' | translate}}">comment</mat-icon>
</button>
</div>
<div *ngIf="!fieldSet?.multiplicity?.tableView" class="col-12">
<div class="row" *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls">

View File

@ -6,3 +6,9 @@
width: 110px;
display: flex;
}
.annotation-icon{
margin-top: 1.625rem;
width: auto;
height: auto;
}

View File

@ -10,6 +10,9 @@ import { DescriptionPropertyDefinitionEditorModel, DescriptionPropertyDefinition
import { FormFieldSetEditorDialogComponent } from './dialog-editor/form-fieldset-editor-dialog.component';
import { cloneAbstractControl } from '@app/utilities/enhancers/utils';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Guid } from '@common/types/guid';
import { AnnotationDialogComponent } from '@app/ui/annotations/annotation-dialog-component/annotation-dialog.component';
import { AnnotationEntityType } from '@app/core/common/enum/annotation-entity-type';
@Component({
selector: 'app-description-form-field-set',
@ -21,6 +24,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
@Input() fieldSet: DescriptionTemplateFieldSet;
@Input() propertiesFormGroup: UntypedFormGroup;
@Input() descriptionId: Guid;
get isMultiplicityEnabled() {
return this.fieldSet.multiplicity != null && this.fieldSet.multiplicity.min != 0 && this.fieldSet.multiplicity.max != 0;
@ -114,6 +118,27 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
});
}
//
//
// Annotations
//
//
showAnnotations(fieldSetId: string) {
const dialogRef = this.dialog.open(AnnotationDialogComponent, {
width: '528px',
data: {
entityId: this.descriptionId,
anchor: fieldSetId,
entityType: AnnotationEntityType.Description
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && result.success) {
//TODO refactor
}
});
}
// deleteCompositeFieldFormGroup() {

View File

@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { FormattingModule } from "@app/core/formatting.module";
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
import { RichTextEditorModule } from "@app/library/rich-text-editor/rich-text-editor.module";
import { AnnotationDialogModule } from '@app/ui/annotations/annotation-dialog-component/annotation-dialog.module';
import { ReferenceFieldModule } from '@app/ui/reference/reference-field/reference-field.module';
import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module';
@ -22,7 +23,8 @@ import { DescriptionFormComponent } from './description-form.component';
RichTextEditorModule,
NgxDropzoneModule,
FormattingModule,
ReferenceFieldModule
ReferenceFieldModule,
AnnotationDialogModule
],
declarations: [
DescriptionFormComponent,

View File

@ -1,7 +1,7 @@
<div class="template-container">
<div mat-dialog-title class="row d-flex m-0 header">
<span class="template-title align-self-center">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.TITLE' | translate}}</span>
<span class="ml-auto align-self-center" (click)="closeDialog()"><mat-icon
<div mat-dialog-title class="row d-flex p-0 m-0 header">
<span class="col template-title align-self-center">{{'PREFILL-DESCRIPTION-DIALOG.TITLE' | translate}}</span>
<span class="col-auto d-flex ml-auto align-self-center" (click)="closeDialog()"><mat-icon
class="close-icon">close</mat-icon></span>
</div>
<div *ngIf="progressIndication" class="progress-bar">
@ -10,48 +10,48 @@
<div mat-dialog-content *ngIf="prefillForm" [formGroup]="prefillForm" class="definition-content">
<div class="row d-flex align-items-center justify-content-center">
<div class="pb-4 pl-4 pr-4">
{{'DATASET-CREATE-WIZARD.PREFILL-STEP.HINT' | translate}}
{{'PREFILL-DESCRIPTION-DIALOG.HINT' | translate}}
</div>
</div>
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="isPrefilled">
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="prefillSelected">
<button mat-raised-button type="button" class="empty-btn"
(click)="closeDialog()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.MANUALLY' | translate}}</button>
<div class="ml-2 mr-2">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.OR' | translate}}</div>
(click)="closeDialog()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.MANUALLY' | translate}}</button>
<div class="ml-2 mr-2">{{'PREFILL-DESCRIPTION-DIALOG.OR' | translate}}</div>
<button mat-raised-button type="button" class="prefill-btn"
(click)="isPrefilled = true">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILL' | translate}}</button>
(click)="prefillSelected = true">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.PREFILL' | translate}}</button>
</div>
<div *ngIf="isPrefilled" class="row">
<div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE' | translate}}</h4>
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<mat-select placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PROFILE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="profile">
<mat-option *ngFor="let profile of data.availableProfiles" [value]="profile">
<div (click)="checkMinMax($event, profile)">
{{profile.label}}
<mat-select placeholder="{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" formControlName="descriptionTempalte">
<mat-option *ngFor="let descriptionTempalte of availableDescriptionTempaltes" [value]="descriptionTempalte.id">
<div>
{{descriptionTempalte.label}}
</div>
</mat-option>
</mat-select>
<mat-error *ngIf="prefillForm.get('profile').hasError('backendError')">{{prefillForm.get('profile').getError('backendError').message}}</mat-error>
<mat-error *ngIf="prefillForm.get('descriptionTempalte').hasError('backendError')">{{prefillForm.get('descriptionTempalte').getError('backendError').message}}</mat-error>
</mat-form-field>
</div>
<div *ngIf="isPrefilled" class="row">
<!-- <div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.PREFILLED-DATASET' | translate}}</h4>
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefill')"
placeholder="{{'DATASET-CREATE-WIZARD.PREFILL-STEP.SEARCH' | translate}}"
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
[configuration]="prefillAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
</div>
</div> -->
</div>
<div *ngIf="isPrefilled">
<div *ngIf="prefillSelected">
<div class="col-auto d-flex pb-4 pt-2">
<button mat-raised-button type="button" class="prefill-btn ml-auto" [disabled]="prefillForm.invalid"
(click)="next()">{{'DATASET-CREATE-WIZARD.PREFILL-STEP.NEXT' | translate}}</button>
(click)="next()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.NEXT' | translate}}</button>
</div>
</div>
</div>

View File

@ -9,7 +9,7 @@
}
.template-title {
margin-left: 37px;
margin-left: 1em;
white-space: nowrap;
width: 480px;
overflow: hidden;

View File

@ -1,42 +1,46 @@
import { Component, Inject, OnInit } from "@angular/core";
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from "@angular/material/dialog";
import { DatasetProfileModel } from "@app/core/model/dataset/dataset-profile";
import { Prefilling } from "@app/core/model/dataset/prefilling";
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
import { Dmp } from "@app/core/model/dmp/dmp";
import { DmpBlueprintService } from "@app/core/services/dmp/dmp-blueprint.service";
import { PrefillingService } from "@app/core/services/prefilling.service";
import { ProgressIndicationService } from "@app/core/services/progress-indication/progress-indication-service";
import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration";
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
import { BaseComponent } from "@common/base/base.component";
import { Guid } from "@common/types/guid";
import { TranslateService } from "@ngx-translate/core";
import { Observable } from "rxjs";
import { map, takeUntil } from "rxjs/operators";
import { nameof } from "ts-simple-nameof";
import { UUID } from "crypto";
import { takeUntil } from "rxjs/operators";
@Component({
selector: 'prefill-dataset-component',
templateUrl: 'prefill-dataset.component.html',
styleUrls: ['prefill-dataset.component.scss']
selector: 'prefill-description-component',
templateUrl: 'prefill-description.component.html',
styleUrls: ['prefill-description.component.scss']
})
export class PrefillDatasetComponent extends BaseComponent implements OnInit {
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit {
progressIndication = false;
prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
isPrefilled: boolean = false;
// prefillAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
prefillSelected: boolean = false;
prefillForm: UntypedFormGroup;
constructor(public dialogRef: MatDialogRef<PrefillDatasetComponent>,
private prefillingService: PrefillingService,
private dmpBlueprintService: DmpBlueprintService,
private dialog: MatDialog,
private language: TranslateService,
dmp: Dmp;
dmpSectionId: Guid;
availableDescriptionTempaltes: DescriptionTemplate[] = [];
constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>,
// private prefillingService: PrefillingService,
// private dmpBlueprintService: DmpBlueprintService,
// private dialog: MatDialog,
// private language: TranslateService,
private progressIndicationService: ProgressIndicationService,
private fb: UntypedFormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any) {
super();
this.dmp = data.dmp;
this.dmpSectionId = data.dmpSectionId;
this.availableDescriptionTempaltes = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId).map(x => x.currentDescriptionTemplate);
}
ngOnInit() {
@ -45,153 +49,153 @@ export class PrefillDatasetComponent extends BaseComponent implements OnInit {
});
this.prefillForm = this.fb.group({
type: this.fb.control(false),
profile: this.fb.control('', Validators.required),
descriptionTempalte: this.fb.control('', Validators.required),
prefill: this.fb.control(null, Validators.required)
})
if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
}
this.prefillAutoCompleteConfiguration = {
filterFn: this.searchDatasets.bind(this),
loadDataOnStart: false,
displayFn: (item) => (item['name'].length > 60) ? (item['name'].substr(0, 60) + "...") : item['name'],
titleFn: (item) => item['name'],
subtitleFn: (item) => item['pid']
};
// if (this.data.availableProfiles && this.data.availableProfiles.length === 1) {
// this.addProfileIfUsedLessThanMax(this.data.availableProfiles[0]);
// }
// this.prefillAutoCompleteConfiguration = {
// filterFn: this.searchDescriptions.bind(this),
// loadDataOnStart: false,
// displayFn: (item) => (item['name'].length > 60) ? (item['name'].substr(0, 60) + "...") : item['name'],
// titleFn: (item) => item['name'],
// subtitleFn: (item) => item['pid']
// };
}
addProfileIfUsedLessThanMax(profile: DatasetProfileModel) {
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
const section = result.definition.sections[dmpSectionIndex];
if (section.hasTemplates) {
const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
if (foundTemplate !== undefined) {
let count = 0;
if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
count++;
}
}
if (count < foundTemplate.maxMultiplicity) {
this.prefillForm.get('profile').patchValue(profile);
}
}
}
else {
this.prefillForm.get('profile').patchValue(profile);
}
}
else {
this.prefillForm.get('profile').patchValue(profile);
}
});
}
// addProfileIfUsedLessThanMax(profile: DescriptionProfileModel) {
// const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
// const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
// this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
// .pipe(takeUntil(this._destroyed))
// .subscribe(result => {
// const section = result.definition.sections[dmpSectionIndex];
// if (section.hasTemplates) {
// const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
// if (foundTemplate !== undefined) {
// let count = 0;
// if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
// for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
// if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
// count++;
// }
// }
// if (count < foundTemplate.maxMultiplicity) {
// this.prefillForm.get('profile').patchValue(profile);
// }
// }
// }
// else {
// this.prefillForm.get('profile').patchValue(profile);
// }
// }
// else {
// this.prefillForm.get('profile').patchValue(profile);
// }
// });
// }
checkMinMax(event, profile: DatasetProfileModel) {
event.stopPropagation();
const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
const section = result.definition.sections[dmpSectionIndex];
if (section.hasTemplates) {
const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
if (foundTemplate !== undefined) {
let count = 0;
if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
count++;
}
}
if (count === foundTemplate.maxMultiplicity) {
this.dialog.open(PopupNotificationDialogComponent, {
data: {
title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'),
message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE')
}, maxWidth: '30em'
});
}
else {
this.prefillForm.get('profile').setValue(profile);
}
}
}
else {
this.prefillForm.get('profile').setValue(profile);
}
}
else {
this.prefillForm.get('profile').setValue(profile);
}
});
}
// checkMinMax(event, profile: DescriptionProfileModel) {
// event.stopPropagation();
// const dmpSectionIndex = this.data.datasetFormGroup.get('dmpSectionIndex').value;
// const blueprintId = this.data.datasetFormGroup.get('dmp').value.profile.id;
// this.dmpBlueprintService.getSingle(blueprintId, this.getBlueprintDefinitionFields())
// .pipe(takeUntil(this._destroyed))
// .subscribe(result => {
// const section = result.definition.sections[dmpSectionIndex];
// if (section.hasTemplates) {
// const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id));
// if (foundTemplate !== undefined) {
// let count = 0;
// if (this.data.datasetFormGroup.get('dmp').value.datasets != null) {
// for (let dataset of this.data.datasetFormGroup.get('dmp').value.datasets) {
// if (dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId) {
// count++;
// }
// }
// if (count === foundTemplate.maxMultiplicity) {
// this.dialog.open(PopupNotificationDialogComponent, {
// data: {
// title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'),
// message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE')
// }, maxWidth: '30em'
// });
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// }
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// }
// else {
// this.prefillForm.get('profile').setValue(profile);
// }
// });
// }
private getBlueprintDefinitionFields() {
return [
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
// private getBlueprintDefinitionFields() {
// return [
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.hasTemplates)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.category)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.dataType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.systemFieldType)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.placeholder)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.description)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.required)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.fields), nameof<FieldInSection>(x => x.ordinal)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
]
}
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.id)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.descriptionTemplateId)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.label)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.minMultiplicity)].join('.'),
// [nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.descriptionTemplates), nameof<DescriptionTemplatesInSection>(x => x.maxMultiplicity)].join('.'),
// ]
// }
public compareWith(object1: any, object2: any) {
return object1 && object2 && object1.id === object2.id;
}
searchDatasets(query: string): Observable<Prefilling[]> {
return this.prefillingService.getPrefillingList(query).pipe(map(prefilling => prefilling.sort((a, b) => {
if (a.name > b.name) {
return 1;
} else if (a.name < b.name) {
return -1;
} else {
return 0;
}
})));
}
// searchDescriptions(query: string): Observable<Prefilling[]> {
// return this.prefillingService.getPrefillingList(query).pipe(map(prefilling => prefilling.sort((a, b) => {
// if (a.name > b.name) {
// return 1;
// } else if (a.name < b.name) {
// return -1;
// } else {
// return 0;
// }
// })));
// }
next() {
if (this.isPrefilled) {
if (this.prefillForm.get('prefill').value.data == null) {
this.prefillingService.getPrefillingDataset(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
wizard.profile = this.prefillForm.get('profile').value;
this.closeDialog(wizard);
});
}
else {
this.prefillingService.getPrefillingDatasetUsingData(this.prefillForm.get('prefill').value.data, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
wizard.profile = this.prefillForm.get('profile').value;
this.closeDialog(wizard);
});
}
} else {
this.closeDialog();
}
// if (this.isPrefilled) {
// if (this.prefillForm.get('prefill').value.data == null) {
// this.prefillingService.getPrefillingDescription(this.prefillForm.get('prefill').value.pid, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
// wizard.profile = this.prefillForm.get('profile').value;
// this.closeDialog(wizard);
// });
// }
// else {
// this.prefillingService.getPrefillingDescriptionUsingData(this.prefillForm.get('prefill').value.data, this.prefillForm.get('profile').value.id, this.prefillForm.get('prefill').value.key).subscribe(wizard => {
// wizard.profile = this.prefillForm.get('profile').value;
// this.closeDialog(wizard);
// });
// }
// } else {
// this.closeDialog();
// }
}
closeDialog(result = null): void {

View File

@ -1061,6 +1061,19 @@
"DISCARD": "Discard"
}
},
"PREFILL-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Dataset",
"OR": "OR",
"HINT": "Select the dataset from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template",
"SEARCH-HEADER": "Prefilled object",
"SEARCH": "Start typing to search for an entity to use for prefilling",
"ACTIONS": {
"NEXT": "Next",
"PREFILL": "Prefill",
"MANUALLY": "Manually"
}
},
"DATASET-PUBLIC-LISTING": {
"TITLE": "Published Datasets",
"TOOLTIP": {