changed the flow of Desription creation to first select a description template

This commit is contained in:
Diamantis Tziotzios 2024-07-15 13:29:07 +03:00
parent 992d9c2f45
commit 0de389d91d
19 changed files with 221 additions and 210 deletions

View File

@ -104,8 +104,8 @@
<div class="row" *ngIf="descriptionInfoValid()"> <div class="row" *ngIf="descriptionInfoValid()">
<div (click)="table0fContents.onToCentrySelected()" class="col-12 main-info" [ngClass]="{'active': reachedBase}">{{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (<mat-icon class="done-icon">done</mat-icon>)</div> <div (click)="table0fContents.onToCentrySelected()" class="col-12 main-info" [ngClass]="{'active': reachedBase}">{{'DESCRIPTION-EDITOR.TOC.MAIN-INFO' | translate}} (<mat-icon class="done-icon">done</mat-icon>)</div>
</div> </div>
<div class="row toc-pane-container" #boundary> <div class="row toc-pane-container">
<div #spacer></div> <div></div>
<div class="col-12"> <div class="col-12">
<app-table-of-contents <app-table-of-contents
*ngIf="formGroup" *ngIf="formGroup"
@ -115,9 +115,6 @@
[hasFocus]="reachedBase == false" [hasFocus]="reachedBase == false"
[formGroup]="formGroup.get('properties')" [formGroup]="formGroup.get('properties')"
[descriptionTemplate]="item.descriptionTemplate" [descriptionTemplate]="item.descriptionTemplate"
[links]="links"
[boundary]="boundary" [spacer]="spacer"
[pageToFieldSetMap]="pageToFieldSetMap"
[anchorFieldsetId]="anchorFieldsetId" [anchorFieldsetId]="anchorFieldsetId"
(entrySelected)="changeStep($event.entry, $event.execute)" (entrySelected)="changeStep($event.entry, $event.execute)"
#table0fContents #table0fContents

View File

@ -4,12 +4,12 @@ import { MatDialog } from '@angular/material/dialog';
import { Title } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DescriptionStatus } from '@app/core/common/enum/description-status';
import { PlanStatus } from '@app/core/common/enum/plan-status';
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type'; import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { LockTargetType } from '@app/core/common/enum/lock-target-type'; import { LockTargetType } from '@app/core/common/enum/lock-target-type';
import { AppPermission } from '@app/core/common/enum/permission.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum';
import { DescriptionTemplate, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; import { PlanStatus } from '@app/core/common/enum/plan-status';
import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplatePage, DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
import { Description, DescriptionPersist, DescriptionStatusPersist } from '@app/core/model/description/description'; import { Description, DescriptionPersist, DescriptionStatusPersist } from '@app/core/model/description/description';
import { PlanBlueprintDefinitionSection } from '@app/core/model/plan-blueprint/plan-blueprint'; import { PlanBlueprintDefinitionSection } from '@app/core/model/plan-blueprint/plan-blueprint';
import { PlanDescriptionTemplate } from '@app/core/model/plan/plan'; import { PlanDescriptionTemplate } from '@app/core/model/plan/plan';
@ -22,6 +22,7 @@ import { LockService } from '@app/core/services/lock/lock.service';
import { LoggingService } from '@app/core/services/logging/logging-service'; import { LoggingService } from '@app/core/services/logging/logging-service';
import { AnalyticsService } from '@app/core/services/matomo/analytics-service'; import { AnalyticsService } from '@app/core/services/matomo/analytics-service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { QueryParamsService } from '@app/core/services/utilities/query-params.service'; import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service'; import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service';
@ -35,16 +36,15 @@ import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { map, takeUntil } from 'rxjs/operators'; import { map, takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { FormAnnotationService } from '../../annotations/annotation-dialog-component/form-annotation.service';
import { DescriptionEditorModel, DescriptionFieldIndicator, DescriptionPropertyDefinitionEditorModel } from './description-editor.model'; import { DescriptionEditorModel, DescriptionFieldIndicator, DescriptionPropertyDefinitionEditorModel } from './description-editor.model';
import { DescriptionEditorEntityResolver } from './resolvers/description-editor-entity.resolver';
import { DescriptionEditorService } from './description-editor.service'; import { DescriptionEditorService } from './description-editor.service';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component'; import { DescriptionFormService } from './description-form/components/services/description-form.service';
import { NewDescriptionDialogComponent, NewDescriptionDialogComponentResult } from './new-description/new-description.component';
import { DescriptionEditorEntityResolver } from './resolvers/description-editor-entity.resolver';
import { ToCEntry } from './table-of-contents/models/toc-entry'; import { ToCEntry } from './table-of-contents/models/toc-entry';
import { TableOfContentsService } from './table-of-contents/services/table-of-contents-service'; import { TableOfContentsService } from './table-of-contents/services/table-of-contents-service';
import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component'; import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component';
import { RouterUtilsService } from '@app/core/services/router/router-utils.service';
import { DescriptionFormService } from './description-form/components/services/description-form.service';
import { FormAnnotationService } from '../../annotations/annotation-dialog-component/form-annotation.service';
@Component({ @Component({
selector: 'app-description-editor-component', selector: 'app-description-editor-component',
@ -61,6 +61,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
canAnnotate = false; canAnnotate = false;
item: Description; item: Description;
fileTransformerEntityTypeEnum = FileTransformerEntityType; fileTransformerEntityTypeEnum = FileTransformerEntityType;
showDescriptionTemplateLoader = false;
viewOnly = false; viewOnly = false;
lockStatus: Boolean; lockStatus: Boolean;
@ -77,8 +78,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
scrollToField: boolean = false; scrollToField: boolean = false;
openAnnotation: boolean = false; openAnnotation: boolean = false;
pageToFieldSetMap: Map<string, DescriptionFieldIndicator[]> = new Map<string, DescriptionFieldIndicator[]>();
private initialTemplateId: string = Guid.EMPTY; private initialTemplateId: string = Guid.EMPTY;
private permissionPerSection: Map<Guid, string[]>; private permissionPerSection: Map<Guid, string[]>;
@ -153,11 +152,11 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
//Regular Editor case //Regular Editor case
if (itemId != null && newPlanId == null) { if (itemId != null && newPlanId == null) {
this.checkLock(this.item.id, LockTargetType.Description, 'DESCRIPTION-EDITOR.LOCKED-DIALOG.TITLE', 'DESCRIPTION-EDITOR.LOCKED-DIALOG.MESSAGE'); this.checkLock(this.item.id, LockTargetType.Description, 'DESCRIPTION-EDITOR.LOCKED-DIALOG.TITLE', 'DESCRIPTION-EDITOR.LOCKED-DIALOG.MESSAGE');
} }
else if (planId != null && planSectionId != null) { else if (planId != null && planSectionId != null) {
this.isNew = true; this.isNew = true;
const dialogRef = this.dialog.open(PrefillDescriptionDialogComponent, { this.reachedBase = false;
const dialogRef = this.dialog.open(NewDescriptionDialogComponent, {
width: '590px', width: '590px',
minHeight: '200px', minHeight: '200px',
restoreFocus: false, restoreFocus: false,
@ -167,19 +166,25 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
}, },
panelClass: 'custom-modalbox' panelClass: 'custom-modalbox'
}); });
dialogRef.afterClosed().subscribe((result: Description) => { dialogRef.afterClosed().subscribe((result: NewDescriptionDialogComponentResult) => {
if (result) { if (result) {
this.titleService.setTitle(result.label); if (result.description != null) {
this.titleService.setTitle(result.description.label);
result.plan = this.item.plan; result.description.plan = this.item.plan;
result.planDescriptionTemplate = this.item.planDescriptionTemplate; result.description.planDescriptionTemplate = this.item.planDescriptionTemplate;
const sectionId = this.item.planDescriptionTemplate.sectionId; const sectionId = this.item.planDescriptionTemplate.sectionId;
result.planDescriptionTemplate = this.item.plan.planDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == result.descriptionTemplate.groupId); result.description.planDescriptionTemplate = this.item.plan.planDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == result.description.descriptionTemplate.groupId);
this.prepareForm(result); this.prepareForm(result.description);
this.changeDetectorRef.markForCheck(); // when prefilling a description the "prepareForm" has already being executed from the base-editor and we need to trigger the angular's change-detector manually this.changeDetectorRef.markForCheck(); // when prefilling a description the "prepareForm" has already being executed from the base-editor and we need to trigger the angular's change-detector manually
this.descriptionFormService.detectChanges(true); this.descriptionFormService.detectChanges(true);
} else if (result.descriptionTemplateId != null) {
this.formGroup.get('descriptionTemplateId').setValue(result.descriptionTemplateId);
}
} else {
this.reachedBase = true;
} }
}) })
} }
@ -237,7 +242,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.canAnnotate = this.permissionPerSection && this.permissionPerSection[this.item.planDescriptionTemplate.sectionId.toString()] && this.permissionPerSection[this.item.planDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.AnnotateDescription); this.canAnnotate = this.permissionPerSection && this.permissionPerSection[this.item.planDescriptionTemplate.sectionId.toString()] && this.permissionPerSection[this.item.planDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.AnnotateDescription);
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.canEdit, this.visibilityRulesService); this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.canEdit, this.visibilityRulesService);
if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);;
// this.selectedSystemFields = this.selectedSystemFieldDisabled(); // this.selectedSystemFields = this.selectedSystemFieldDisabled();
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
@ -644,8 +648,10 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.item.planDescriptionTemplate = this.item.plan.planDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == descriptionTemplate.groupId); this.item.planDescriptionTemplate = this.item.plan.planDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == descriptionTemplate.groupId);
this.formGroup.get('planDescriptionTemplateId').setValue(this.item.planDescriptionTemplate.id); this.formGroup.get('planDescriptionTemplateId').setValue(this.item.planDescriptionTemplate.id);
if (descriptionTemplate.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (descriptionTemplate.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
if (descriptionTemplate.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);
if (this.formGroup.get('label').value == null || this.formGroup.get('label').value.length == 0) {
this.formGroup.get('label').setValue(descriptionTemplate.label);
}
this.registerFormListeners(); this.registerFormListeners();
}, },
error => { error => {
@ -655,17 +661,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
} }
} }
mapPageToFieldSet(descriptionTemplate: DescriptionTemplate): Map<string, DescriptionFieldIndicator[]> {
const pageToFieldSetMap = new Map<string, DescriptionFieldIndicator[]>();
descriptionTemplate.definition.pages?.forEach((page: DescriptionTemplatePage) => {
let fieldsByPage = this.getFieldsetsOfPage(page);
pageToFieldSetMap.set(page.id, fieldsByPage);
});
return pageToFieldSetMap;
}
getFieldsetsOfPage(page: DescriptionTemplatePage): DescriptionFieldIndicator[] { getFieldsetsOfPage(page: DescriptionTemplatePage): DescriptionFieldIndicator[] {
const fieldsByPage: DescriptionFieldIndicator[] = [] const fieldsByPage: DescriptionFieldIndicator[] = []

View File

@ -12,7 +12,7 @@ import { DescriptionFormProgressIndicationModule } from './form-progress-indicat
import { TableOfContentsModule } from './table-of-contents/table-of-contents.module'; import { TableOfContentsModule } from './table-of-contents/table-of-contents.module';
import { RichTextEditorModule } from '@app/library/rich-text-editor/rich-text-editor.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 { TagsFieldModule } from '@app/ui/tag/tags-field/tags-field.module';
import { PrefillDescriptionDialogComponent } from './prefill-description/prefill-description.component'; import { NewDescriptionDialogComponent } from './new-description/new-description.component';
import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module';
import { DeprecatedDescriptionTemplateDialog } from './description-base-fields-editor/dialog-description-template/deprecated-description-template-dialog.component'; import { DeprecatedDescriptionTemplateDialog } from './description-base-fields-editor/dialog-description-template/deprecated-description-template-dialog.component';
@ -33,7 +33,7 @@ import { DeprecatedDescriptionTemplateDialog } from './description-base-fields-e
declarations: [ declarations: [
DescriptionEditorComponent, DescriptionEditorComponent,
DescriptionBaseFieldsEditorComponent, DescriptionBaseFieldsEditorComponent,
PrefillDescriptionDialogComponent, NewDescriptionDialogComponent,
DeprecatedDescriptionTemplateDialog DeprecatedDescriptionTemplateDialog
], ],
exports: [ exports: [

View File

@ -1,31 +1,20 @@
<div class="template-container"> <div class="template-container">
<div mat-dialog-title class="row d-flex p-0 m-0 header"> <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 template-title align-self-center">{{'NEW-DESCRIPTION-DIALOG.TITLE' | translate}}</span>
<span class="col-auto d-flex ml-auto align-self-center" (click)="closeDialog()"><mat-icon <span class="col-auto d-flex ml-auto align-self-center" (click)="closeDialog()"><mat-icon class="close-icon">close</mat-icon></span>
class="close-icon">close</mat-icon></span>
</div> </div>
<div *ngIf="progressIndication" class="progress-bar"> <div *ngIf="progressIndication" class="progress-bar">
<mat-progress-bar color="primary" mode="indeterminate"></mat-progress-bar> <mat-progress-bar color="primary" mode="indeterminate"></mat-progress-bar>
</div> </div>
<div mat-dialog-content *ngIf="prefillForm" [formGroup]="prefillForm" class="definition-content"> <div mat-dialog-content *ngIf="prefillForm" [formGroup]="prefillForm" class="definition-content">
<div class="row d-flex align-items-center justify-content-center"> <div class="row d-flex align-items-center">
<div class="pb-4 pl-4 pr-4"> <div class="pb-4 pl-4 pr-4">
{{'PREFILL-DESCRIPTION-DIALOG.HINT' | translate}} {{'NEW-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE-HINT' | translate}}
</div> </div>
</div> </div>
<div class="row d-flex align-items-center justify-content-center" [class.pb-4]="prefillSelected"> <div class="row">
<button mat-raised-button type="button" class="empty-btn" <mat-form-field class="col-md-12 pb-2 pl-4 pr-4">
(click)="closeDialog()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.MANUALLY' | translate}}</button> <mat-select placeholder="{{'NEW-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" [formControl]="prefillForm.get('descriptionTemplateId')">
<div class="ml-2 mr-2">{{'PREFILL-DESCRIPTION-DIALOG.OR' | translate}}</div>
<button mat-raised-button type="button" class="prefill-btn"
(click)="prefillSelected = true">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.PREFILL' | translate}}</button>
</div>
<div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE' | translate}}</h4>
</div>
<mat-form-field class="col-md-12">
<mat-select placeholder="{{'PREFILL-DESCRIPTION-DIALOG.DESCRIPTION-TEMPLATE'| translate}}" [required]="true" [compareWith]="compareWith" [formControl]="prefillForm.get('descriptionTemplateId')">
<mat-option *ngFor="let descriptionTemplate of availableDescriptionTemplates" [value]="descriptionTemplate.id"> <mat-option *ngFor="let descriptionTemplate of availableDescriptionTemplates" [value]="descriptionTemplate.id">
<div> <div>
<span>{{descriptionTemplate.label}}, </span> <span>{{descriptionTemplate.label}}, </span>
@ -35,25 +24,34 @@
</mat-select> </mat-select>
<mat-error *ngIf="prefillForm.get('descriptionTemplateId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="prefillForm.get('descriptionTemplateId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div>
<div class="row d-flex align-items-center justify-content-center">
<div class="pb-4 pl-4 pr-4">
{{'NEW-DESCRIPTION-DIALOG.PREFILL-HINT' | translate}}
</div>
</div>
<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)="manuallySelected()">{{'NEW-DESCRIPTION-DIALOG.ACTIONS.MANUALLY' | translate}}</button>
<div class="ml-2 mr-2">{{'NEW-DESCRIPTION-DIALOG.OR' | translate}}</div>
<button mat-raised-button type="button" class="prefill-btn" (click)="prefillSelected = true">{{'NEW-DESCRIPTION-DIALOG.ACTIONS.PREFILL' | translate}}</button>
</div>
<div *ngIf="prefillSelected" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row"> <div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}</h4> <h4 class="col-auto heading">{{'NEW-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}</h4>
</div> </div>
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')" <app-single-auto-complete [required]="true" [formControl]="prefillForm.get('prefillingSourceId')" placeholder="{{'NEW-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}" [configuration]="singlePrefillingSourceAutoCompleteConfiguration" (optionSelected)="changePreffillingSource($event)">
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.PREFILLING-SOURCE' | translate}}"
[configuration]="singlePrefillingSourceAutoCompleteConfiguration" (optionSelected)="changePreffillingSource($event)">
</app-single-auto-complete> </app-single-auto-complete>
<mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="prefillForm.get('prefillingSourceId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div *ngIf="prefillForm.get('prefillingSourceId').value != null" class="row"> <div *ngIf="prefillForm.get('prefillingSourceId').value != null" class="row">
<div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row"> <div class="col-12 pl-0 pr-0 pb-2 d-flex flex-row">
<h4 class="col-auto heading">{{'PREFILL-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4> <h4 class="col-auto heading">{{'NEW-DESCRIPTION-DIALOG.SEARCH-HEADER' | translate}}</h4>
</div> </div>
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">
<app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')" <app-single-auto-complete [required]="true" [formControl]="prefillForm.get('data')" placeholder="{{'NEW-DESCRIPTION-DIALOG.SEARCH' | translate}}" [configuration]="prefillObjectAutoCompleteConfiguration">
placeholder="{{'PREFILL-DESCRIPTION-DIALOG.SEARCH' | translate}}"
[configuration]="prefillObjectAutoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>
</mat-form-field> </mat-form-field>
</div> </div>
@ -61,8 +59,7 @@
</div> </div>
<div *ngIf="prefillSelected"> <div *ngIf="prefillSelected">
<div class="col-auto d-flex pb-4 pt-2"> <div class="col-auto d-flex pb-4 pt-2">
<button mat-raised-button type="button" class="prefill-btn ml-auto" [disabled]="prefillForm.invalid" <button mat-raised-button type="button" class="prefill-btn ml-auto" [disabled]="prefillForm.invalid" (click)="next()">{{'NEW-DESCRIPTION-DIALOG.ACTIONS.NEXT' | translate}}</button>
(click)="next()">{{'PREFILL-DESCRIPTION-DIALOG.ACTIONS.NEXT' | translate}}</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,8 +1,10 @@
import { Component, Inject, OnInit } from "@angular/core"; import { Component, Inject, OnInit } from "@angular/core";
import { UntypedFormGroup } from "@angular/forms"; import { UntypedFormGroup } from "@angular/forms";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { IsActive } from "@app/core/common/enum/is-active.enum";
import { DescriptionPrefillingRequest, PrefillingSearchRequest } from "@app/core/model/description-prefilling-request/description-prefilling-request"; import { DescriptionPrefillingRequest, PrefillingSearchRequest } from "@app/core/model/description-prefilling-request/description-prefilling-request";
import { DescriptionTemplate } from "@app/core/model/description-template/description-template"; import { DescriptionTemplate } from "@app/core/model/description-template/description-template";
import { Description } from "@app/core/model/description/description";
import { Plan } from "@app/core/model/plan/plan"; import { Plan } from "@app/core/model/plan/plan";
import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source"; import { Prefilling } from "@app/core/model/prefilling-source/prefilling-source";
import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service"; import { PrefillingSourceService } from "@app/core/services/prefilling-source/prefilling-source.service";
@ -10,20 +12,19 @@ import { ProgressIndicationService } from "@app/core/services/progress-indicatio
import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration"; import { SingleAutoCompleteConfiguration } from "@app/library/auto-complete/single/single-auto-complete-configuration";
import { BaseComponent } from "@common/base/base.component"; import { BaseComponent } from "@common/base/base.component";
import { FormService } from "@common/forms/form-service"; import { FormService } from "@common/forms/form-service";
import { HttpErrorHandlingService } from "@common/modules/errors/error-handling/http-error-handling.service";
import { Guid } from "@common/types/guid"; import { Guid } from "@common/types/guid";
import { Observable } from "rxjs"; import { Observable } from "rxjs";
import { takeUntil } from "rxjs/operators"; import { takeUntil } from "rxjs/operators";
import { DescriptionEditorEntityResolver } from "../resolvers/description-editor-entity.resolver"; import { DescriptionEditorEntityResolver } from "../resolvers/description-editor-entity.resolver";
import { IsActive } from "@app/core/common/enum/is-active.enum"; import { DescriptionPrefillingRequestEditorModel } from "./new-description-editor.model";
import { DescriptionPrefillingRequestEditorModel } from "./prefill-description-editor.model";
import { HttpErrorHandlingService } from "@common/modules/errors/error-handling/http-error-handling.service";
@Component({ @Component({
selector: 'prefill-description-component', selector: 'new-description-component',
templateUrl: 'prefill-description.component.html', templateUrl: 'new-description.component.html',
styleUrls: ['prefill-description.component.scss'] styleUrls: ['new-description.component.scss']
}) })
export class PrefillDescriptionDialogComponent extends BaseComponent implements OnInit { export class NewDescriptionDialogComponent extends BaseComponent implements OnInit {
progressIndication = false; progressIndication = false;
singlePrefillingSourceAutoCompleteConfiguration: SingleAutoCompleteConfiguration; singlePrefillingSourceAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
@ -35,7 +36,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
planSectionId: Guid; planSectionId: Guid;
availableDescriptionTemplates: DescriptionTemplate[] = []; availableDescriptionTemplates: DescriptionTemplate[] = [];
constructor(public dialogRef: MatDialogRef<PrefillDescriptionDialogComponent>, constructor(public dialogRef: MatDialogRef<NewDescriptionDialogComponent>,
private progressIndicationService: ProgressIndicationService, private progressIndicationService: ProgressIndicationService,
public prefillingSourceService: PrefillingSourceService, public prefillingSourceService: PrefillingSourceService,
private formService: FormService, private formService: FormService,
@ -92,7 +93,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
this.prefillingSourceService.generate(formData, DescriptionEditorEntityResolver.descriptionTemplateLookupFieldsForDescrption()) this.prefillingSourceService.generate(formData, DescriptionEditorEntityResolver.descriptionTemplateLookupFieldsForDescrption())
.pipe(takeUntil(this._destroyed)).subscribe(description => { .pipe(takeUntil(this._destroyed)).subscribe(description => {
if (description) { if (description) {
this.closeDialog(description); this.closeDialog({ description: description });
} else { } else {
this.closeDialog(); this.closeDialog();
} }
@ -103,7 +104,17 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements
}); });
} }
manuallySelected() {
if (!this.prefillForm.get('descriptionTemplateId').valid) return;
this.closeDialog({ descriptionTemplateId: this.prefillForm.get('descriptionTemplateId').value });
}
closeDialog(result = null): void { closeDialog(result = null): void {
this.dialogRef.close(result); this.dialogRef.close(result);
} }
} }
export class NewDescriptionDialogComponentResult {
description: Description;
descriptionTemplateId: Guid;
}

View File

@ -206,7 +206,7 @@
</div> </div>
<div *ngIf="!isNew" class="col-auto" style="margin-top: 1rem;"> <div *ngIf="!isNew" class="col-auto" style="margin-top: 1rem;">
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(field.id)" matTooltip="{{ 'PLAN-EDITOR.ACTIONS.ANNOTATIONS' | translate }}" [disabled]="!canAnnotate(section.id)"> <button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(field.id)" matTooltip="{{ 'PLAN-EDITOR.ACTIONS.ANNOTATIONS' | translate }}" [disabled]="!canAnnotate(section.id)">
<mat-icon [matBadge]="annotationsPerAnchor.get(field.id)" [matBadgeHidden]="annotationsPerAnchor.get(field.id) <= 0" matBadgeColor="warn">comment</mat-icon> <mat-icon [matBadge]="annotationsPerAnchor?.get(field.id)" [matBadgeHidden]="annotationsPerAnchor?.get(field.id) <= 0" matBadgeColor="warn">comment</mat-icon>
</button> </button>
</div> </div>
</div> </div>

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",

View File

@ -1020,10 +1020,11 @@
"SELECT-PLAN": "Select Plan", "SELECT-PLAN": "Select Plan",
"PLAN-SECTION": "Select Section" "PLAN-SECTION": "Select Section"
}, },
"PREFILL-DESCRIPTION-DIALOG": { "NEW-DESCRIPTION-DIALOG": {
"TITLE": "Initialize your Description", "TITLE": "Initialize your Description",
"OR": "OR", "OR": "OR",
"HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.", "DESCRIPTION-TEMPLATE-HINT": "Select the Template to be used for your Description.",
"PREFILL-HINT": "Select the item from Zenodo to automatically retrieve answers to some questions in your template or start by answering the questions manually.",
"DESCRIPTION-TEMPLATE": "Description Template", "DESCRIPTION-TEMPLATE": "Description Template",
"PREFILLING-SOURCE": "Prefilling Source", "PREFILLING-SOURCE": "Prefilling Source",
"SEARCH-HEADER": "Prefilled object", "SEARCH-HEADER": "Prefilled object",