ui fix for description editor change ref

This commit is contained in:
Diamantis Tziotzios 2024-08-06 13:47:39 +03:00
parent d5af0aa2e6
commit f2312dabcd
4 changed files with 20 additions and 16 deletions

3
frontend/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"html.format.wrapLineLength": 0
}

View File

@ -8,9 +8,8 @@ import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/de
import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template';
import { StorageFile } from '@app/core/model/storage-file/storage-file'; import { StorageFile } from '@app/core/model/storage-file/storage-file';
import { DescriptionService } from '@app/core/services/description/description.service'; import { DescriptionService } from '@app/core/services/description/description.service';
import { PlanService } from '@app/core/services/plan/plan.service';
import { SnackBarNotificationLevel, UiNotificationService } from "@app/core/services/notification/ui-notification-service"; import { SnackBarNotificationLevel, UiNotificationService } from "@app/core/services/notification/ui-notification-service";
import { ReferenceService } from '@app/core/services/reference/reference.service'; import { PlanService } from '@app/core/services/plan/plan.service';
import { StorageFileService } from '@app/core/services/storage-file/storage-file.service'; import { StorageFileService } from '@app/core/services/storage-file/storage-file.service';
import { TagService } from '@app/core/services/tag/tag.service'; import { TagService } from '@app/core/services/tag/tag.service';
import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service';
@ -83,13 +82,11 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
public planService: PlanService, public planService: PlanService,
public descriptionService: DescriptionService, public descriptionService: DescriptionService,
public tagService: TagService, public tagService: TagService,
private cdr: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private uiNotificationService: UiNotificationService, private uiNotificationService: UiNotificationService,
public dialog: MatDialog, public dialog: MatDialog,
private fileUtils: FileUtils, private fileUtils: FileUtils,
private referenceService: ReferenceService,
private storageFileService: StorageFileService, private storageFileService: StorageFileService,
private changeDetectorRef: ChangeDetectorRef,
private httpErrorHandlingService: HttpErrorHandlingService, private httpErrorHandlingService: HttpErrorHandlingService,
private descriptionFormService: DescriptionFormService, private descriptionFormService: DescriptionFormService,
) { ) {
@ -132,6 +129,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
) )
.subscribe(item => { .subscribe(item => {
this.visibilityRulesService.updateVisibilityForSource(this.field?.id); this.visibilityRulesService.updateVisibilityForSource(this.field?.id);
this.descriptionFormService.detectChanges(true);
}); });
} }
@ -210,7 +208,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
.pipe(takeUntil(this._destroyed)).subscribe((response) => { .pipe(takeUntil(this._destroyed)).subscribe((response) => {
this.propertiesFormGroup?.get(this.field.id).get('textValue').patchValue(response[0].id.toString()); this.propertiesFormGroup?.get(this.field.id).get('textValue').patchValue(response[0].id.toString());
this.createFileNameDisplay(response[0].name, response[0].extension); this.createFileNameDisplay(response[0].name, response[0].extension);
this.cdr.detectChanges(); this.changeDetectorRef.detectChanges();
}, error => { }, error => {
this.onCallbackUploadFail(error.error); this.onCallbackUploadFail(error.error);
}) })
@ -270,8 +268,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
onRemove(makeFilesNull: boolean = true) { onRemove(makeFilesNull: boolean = true) {
this.makeFilesNull() this.makeFilesNull()
this.cdr.detectChanges(); this.changeDetectorRef.detectChanges();
} }
makeFilesNull() { makeFilesNull() {

View File

@ -1,14 +1,16 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
import { PlanUser } from '@app/core/model/plan/plan';
import { BaseComponent } from '@common/base/base.component'; import { BaseComponent } from '@common/base/base.component';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Guid } from '@common/types/guid';
import { ToCEntry } from '../../../table-of-contents/models/toc-entry'; import { ToCEntry } from '../../../table-of-contents/models/toc-entry';
import { ToCEntryType } from '../../../table-of-contents/models/toc-entry-type.enum'; import { ToCEntryType } from '../../../table-of-contents/models/toc-entry-type.enum';
import { LinkToScroll } from '../../../table-of-contents/table-of-contents.component'; import { LinkToScroll } from '../../../table-of-contents/table-of-contents.component';
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
import { Guid } from '@common/types/guid'; import { DescriptionFormService } from '../services/description-form.service';
import { PlanUser } from '@app/core/model/plan/plan'; import { takeUntil } from 'rxjs';
@Component({ @Component({
@ -38,6 +40,7 @@ export class DescriptionFormSectionComponent extends BaseComponent implements On
@Input() validationErrorModel: ValidationErrorModel; @Input() validationErrorModel: ValidationErrorModel;
constructor( constructor(
private descriptionFormService: DescriptionFormService,
private changeDetector: ChangeDetectorRef private changeDetector: ChangeDetectorRef
) { ) {
super(); super();
@ -45,6 +48,7 @@ export class DescriptionFormSectionComponent extends BaseComponent implements On
} }
ngOnInit() { ngOnInit() {
this.descriptionFormService.getDetectChangesObservable().pipe(takeUntil(this._destroyed)).subscribe( _ => this.changeDetector.markForCheck() );
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {

View File

@ -1,15 +1,15 @@
import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { MatExpansionPanel } from '@angular/material/expansion'; import { MatExpansionPanel } from '@angular/material/expansion';
import { AnnotationEntityType } from '@app/core/common/enum/annotation-entity-type';
import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
import { PlanUser } from '@app/core/model/plan/plan';
import { BaseComponent } from '@common/base/base.component'; import { BaseComponent } from '@common/base/base.component';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Guid } from '@common/types/guid'; import { Guid } from '@common/types/guid';
import { LinkToScroll } from '../table-of-contents/table-of-contents.component';
import { FormAnnotationService } from '../../../annotations/annotation-dialog-component/form-annotation.service'; import { FormAnnotationService } from '../../../annotations/annotation-dialog-component/form-annotation.service';
import { LinkToScroll } from '../table-of-contents/table-of-contents.component';
import { VisibilityRulesService } from './visibility-rules/visibility-rules.service'; import { VisibilityRulesService } from './visibility-rules/visibility-rules.service';
import { PlanUser } from '@app/core/model/plan/plan';
import { AnnotationEntityType } from '@app/core/common/enum/annotation-entity-type';
@Component({ @Component({
selector: 'app-description-form', selector: 'app-description-form',