Fix some bugs in dataset editor while navigating with buttons and scroll in the table of contents

This commit is contained in:
Konstantinos Triantafyllou 2022-10-19 01:48:48 +03:00
parent 3361b6aff6
commit 4a54915a8e
3 changed files with 23 additions and 20 deletions

View File

@ -76,7 +76,7 @@
[showErrors]="showtocentriesErrors" [TOCENTRY_ID_PREFIX]="TOCENTRY_ID_PREFIX" [hasFocus]="step > 0"
[formGroup]="formGroup" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [links]="links"
[boundary]="boundary" [spacer]="spacer" [isActive]="step !== 0" stickyThing (stepFound)="onStepFound($event)"
(currentLinks)="getLinks($event)" (entrySelected)="changeStep($event)"
(currentLinks)="getLinks($event)" (entrySelected)="changeStep($event.entry, $event.execute)"
[visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value"></table-of-contents>
</div>
</div>

View File

@ -61,6 +61,7 @@ import {PopupNotificationDialogComponent} from '@app/library/notification/popup/
import {CheckDeactivateBaseComponent} from '@app/library/deactivate/deactivate.component';
import {PrefillDatasetComponent} from "@app/ui/dataset/dataset-wizard/prefill-dataset/prefill-dataset.component";
import {ToCEntry, ToCEntryType} from "@app/ui/misc/dataset-description-form/dataset-description.component";
import {dispatchFakeEvent} from "@angular/cdk/testing/testbed/fake-events";
@Component({
selector: 'app-dataset-wizard-component',
@ -1192,13 +1193,15 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
}
}
public changeStep(selected: ToCEntry = null) {
if(selected) {
let fieldSet = this.getFirstFieldSet(selected);
let index = this.visibleFieldSets.findIndex(entry => entry.id === fieldSet.id);
this.step = index + (selected.type === ToCEntryType.FieldSet?1:0.5);
} else {
this.step = 0;
public changeStep(selected: ToCEntry = null, execute: boolean = true) {
if(execute) {
if(selected) {
let fieldSet = this.getFirstFieldSet(selected);
let index = this.visibleFieldSets.findIndex(entry => entry.id === fieldSet.id);
this.step = index + (selected.type === ToCEntryType.FieldSet?1:0.5);
} else {
this.step = 0;
}
}
}
@ -1208,22 +1211,22 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
public nextStep() {
if (this.step < this.maxStep) {//view is changing
this.step++;
let entry = this.visibleFieldSets[Math.floor(this.step) - 1];
this.table0fContents.onToCentrySelected(entry);
this.step = Math.floor(this.step + 1);
let entry = this.visibleFieldSets[this.step - 1];
this.table0fContents.onToCentrySelected(entry, false);
this.scroll(entry);
}
}
public previousStep() {
if (this.step > 0) {
this.step--;
if(this.step > 0) {
let entry = this.visibleFieldSets[Math.floor(this.step) - 1];
this.table0fContents.onToCentrySelected(entry);
this.step = Math.ceil(this.step - 1);
if(this.step >= 1) {
let entry = this.visibleFieldSets[this.step - 1];
this.table0fContents.onToCentrySelected(entry, false);
this.scroll(entry);
} else {
this.table0fContents.onToCentrySelected();
this.table0fContents.onToCentrySelected(null, false);
this.resetScroll();
}
}

View File

@ -43,7 +43,7 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
headerSelectors = '.toc-page-header, .toc-section-header, .toc-compositeField-header';
@Output() stepFound = new EventEmitter<LinkToScroll>();
@Output() currentLinks = new EventEmitter<Link[]>();
@Output() entrySelected = new EventEmitter<ToCEntry>();
@Output() entrySelected = new EventEmitter<any>();
subscription: Subscription;
linksSubject: Subject<HTMLElement[]> = new Subject<HTMLElement[]>();
@ -201,7 +201,7 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
ngOnChanges(changes: SimpleChanges) {
if(this.selectedFieldsetId){
this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId,this.tocentries));
this.onToCentrySelected(this._findTocEntryById(this.selectedFieldsetId,this.tocentries), false);
this._actOnObservation = false;
setTimeout(() => {
this._actOnObservation = true;
@ -441,9 +441,9 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
}
onToCentrySelected(entry: ToCEntry = null){
onToCentrySelected(entry: ToCEntry = null, execute: boolean = true){
this.tocentrySelected = entry;
this.entrySelected.emit(entry);
this.entrySelected.emit({entry: entry, execute: execute});
}
private _findTocEntryById(id: string, tocentries: ToCEntry[]): ToCEntry{