fix on table-of-content validation trigger
This commit is contained in:
parent
850eed05d0
commit
18365de1d4
|
@ -49,6 +49,7 @@ import { DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
|
||||||
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
|
import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
|
||||||
|
import { TableOfContentsValidationService } from './table-of-contents/services/table-of-contents-validation-service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-description-editor-component',
|
selector: 'app-description-editor-component',
|
||||||
|
@ -99,6 +100,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
private dmpService: DmpService,
|
private dmpService: DmpService,
|
||||||
public visibilityRulesService: VisibilityRulesService,
|
public visibilityRulesService: VisibilityRulesService,
|
||||||
public fileTransformerService: FileTransformerService,
|
public fileTransformerService: FileTransformerService,
|
||||||
|
public tocValidationService: TableOfContentsValidationService
|
||||||
|
|
||||||
) {
|
) {
|
||||||
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService);
|
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService);
|
||||||
|
@ -623,6 +625,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
|
|
||||||
refreshData(): void {
|
refreshData(): void {
|
||||||
this.getItem(this.editorModel.id, (data: Description) => this.prepareForm(data));
|
this.getItem(this.editorModel.id, (data: Description) => this.prepareForm(data));
|
||||||
|
this.tocValidationService.validateForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshOnNavigateToData(id?: Guid): void {
|
refreshOnNavigateToData(id?: Guid): void {
|
||||||
|
@ -1016,6 +1019,10 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.formGroup.get('properties').valueChanges
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(next => this.tocValidationService.validateForm());
|
||||||
|
|
||||||
// // const labelSubscription =
|
// // const labelSubscription =
|
||||||
// this.formGroup.get('label').valueChanges
|
// this.formGroup.get('label').valueChanges
|
||||||
// .pipe(takeUntil(this._destroyed))
|
// .pipe(takeUntil(this._destroyed))
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { EventEmitter, Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TableOfContentsValidationService {
|
||||||
|
private _validateFormEvent: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
get validateFormEvent(): EventEmitter<any> {
|
||||||
|
return this._validateFormEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
validateForm(): void {
|
||||||
|
this._validateFormEvent.emit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import { ToCEntry } from '../models/toc-entry';
|
||||||
import { ToCEntryType } from '../models/toc-entry-type.enum';
|
import { ToCEntryType } from '../models/toc-entry-type.enum';
|
||||||
import { DescriptionFieldIndicator } from '../../description-editor.model';
|
import { DescriptionFieldIndicator } from '../../description-editor.model';
|
||||||
import { Observable, Subscription, map } from 'rxjs';
|
import { Observable, Subscription, map } from 'rxjs';
|
||||||
|
import { TableOfContentsValidationService } from '../services/table-of-contents-validation-service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'table-of-contents-internal',
|
selector: 'table-of-contents-internal',
|
||||||
|
@ -34,8 +35,7 @@ export class TableOfContentsInternal implements OnInit, OnDestroy {
|
||||||
tocEntriesStateSubscriptions: Subscription[] = [];
|
tocEntriesStateSubscriptions: Subscription[] = [];
|
||||||
tocEntriesStateMap: Map<string, boolean> = new Map<string, boolean>();
|
tocEntriesStateMap: Map<string, boolean> = new Map<string, boolean>();
|
||||||
|
|
||||||
constructor() {
|
constructor(private tocValidationService: TableOfContentsValidationService) { }
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// console.log('component created' + JSON.stringify(this.tocentries));
|
// console.log('component created' + JSON.stringify(this.tocentries));
|
||||||
|
@ -93,7 +93,7 @@ export class TableOfContentsInternal implements OnInit, OnDestroy {
|
||||||
this.tocEntriesStateMap.set(entry.id, false);
|
this.tocEntriesStateMap.set(entry.id, false);
|
||||||
|
|
||||||
this.tocEntriesStateSubscriptions.push(
|
this.tocEntriesStateSubscriptions.push(
|
||||||
this.propertiesFormGroup.statusChanges
|
this.tocValidationService.validateFormEvent
|
||||||
.pipe(map(() => this.hasErrors(entry.id)))
|
.pipe(map(() => this.hasErrors(entry.id)))
|
||||||
.subscribe(next => {
|
.subscribe(next => {
|
||||||
this.tocEntriesStateMap.set(entry.id, next);
|
this.tocEntriesStateMap.set(entry.id, next);
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {NgModule} from '@angular/core';
|
import { NgModule} from '@angular/core';
|
||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal';
|
import { TableOfContentsInternal } from './table-of-contents-internal/table-of-contents-internal';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
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';
|
||||||
import { TableOfContentsComponent } from './table-of-contents.component';
|
import { TableOfContentsComponent } from './table-of-contents.component';
|
||||||
|
import { TableOfContentsValidationService } from './services/table-of-contents-validation-service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CommonModule, RouterModule, MatIconModule],
|
imports: [CommonModule, RouterModule, MatIconModule],
|
||||||
declarations: [TableOfContentsComponent, TableOfContentsInternal],
|
declarations: [TableOfContentsComponent, TableOfContentsInternal],
|
||||||
exports: [TableOfContentsComponent],
|
exports: [TableOfContentsComponent],
|
||||||
providers: [VisibilityRulesService]
|
providers: [VisibilityRulesService, TableOfContentsValidationService]
|
||||||
})
|
})
|
||||||
export class TableOfContentsModule { }
|
export class TableOfContentsModule { }
|
||||||
|
|
Loading…
Reference in New Issue