User Dataset Editor. Table of contents loads properly on saved template. Table of contents and tempalte description have the same visibilityRules service.

This commit is contained in:
Kristian Ntavidi 2021-04-13 11:19:09 +03:00
parent 12a1f7da12
commit e801bbf2e2
6 changed files with 49 additions and 18 deletions

View File

@ -164,7 +164,7 @@
</mat-form-field>
</div>
<div class="col-12">
<!-- <div class="col-12">
<div class="heading">1.4 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="full-width basic-info-input">
<table class="col-12 user-table">
@ -212,7 +212,7 @@
</button>
</div>
</div>
</div>
</div> -->
<!-- <div class="col-12">
<button mat-button class="full-width" (click)="addPage()"
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.NEXT' | translate}}</button>

View File

@ -1,7 +1,7 @@
<form class="row user-role-editor" [formGroup]="formGroup" (ngSubmit)="formSubmit()">
<div *ngIf="!this.nowEditing"class="roles col">
<ng-container *ngFor="let role of this.formGroup.get('appRoles').value">
<div>
<div *ngIf="role!=3">
<span class="user-role" [ngClass]="{'user': role == 0, 'manager': role == 1, 'admin': role == 2, 'dataset-template-editor': role == 3}">
{{getPrincipalAppRoleWithLanguage(role)}}
</span>
@ -10,7 +10,9 @@
</div>
<mat-form-field *ngIf="this.nowEditing" class="select-role roles-width-180 col-auto">
<mat-select formControlName="appRoles" multiple required>
<mat-option *ngFor="let role of getPrincipalAppRoleValues()" [value]="role">{{getPrincipalAppRoleWithLanguage(role)}}</mat-option>
<ng-container *ngFor="let role of getPrincipalAppRoleValues()">
<mat-option [value]="role" *ngIf="role!=3">{{getPrincipalAppRoleWithLanguage(role)}}</mat-option>
</ng-container>
</mat-select>
<mat-error *ngIf="getFormControl('appRoles').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -54,7 +54,7 @@
<div (click)="changeStep(0)" *ngIf="datasetInfoValid()" class="main-info" [ngClass]="{'active': this.step === 0}">0. {{'DMP-EDITOR.STEPPER.MAIN-INFO' | translate}} (<mat-icon class="done-icon">done</mat-icon>)</div>
<div class="row toc-pane-container" #boundary (click)="changeStep(1)">
<div #spacer></div>
<table-of-contents [selectedFieldsetId]="fieldsetIdWithFocus" #table0fContents [showErrors]="showtocentriesErrors" [TOCENTRY_ID_PREFIX]="TOCENTRY_ID_PREFIX" [hasFocus]="step === 1" [formGroup]="formGroup" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [links]="links" [boundary]="boundary" [spacer]="spacer" [isActive]="step !== 0" stickyThing (stepFound)="onStepFound($event)" (currentLinks)="getLinks($event)" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value"></table-of-contents>
<table-of-contents [visibilityRulesService]="visRulesService" [selectedFieldsetId]="fieldsetIdWithFocus" #table0fContents [showErrors]="showtocentriesErrors" [TOCENTRY_ID_PREFIX]="TOCENTRY_ID_PREFIX" [hasFocus]="step === 1" [formGroup]="formGroup" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [links]="links" [boundary]="boundary" [spacer]="spacer" [isActive]="step !== 0" stickyThing (stepFound)="onStepFound($event)" (currentLinks)="getLinks($event)" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value"></table-of-contents>
</div>
</div>
</div>
@ -81,7 +81,7 @@
</div>
<div class="col-auto form" id="dataset-editor-form">
<app-dataset-editor-component [hidden]="this.step !== 0" [formGroup]="formGroup" [dmpId]="formGroup.get('dmp').value.id" [availableProfiles]="formGroup.get('dmp').value.profiles" (formChanged)="formChanged()"></app-dataset-editor-component>
<app-dataset-description [TOCENTRY_ID_PREFIX]="TOCENTRY_ID_PREFIX" [hidden]="this.step === 0" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value" [datasetProfileId]="formGroup.get('profile').value" [linkToScroll]="linkToScroll" (fieldsetFocusChange)="fieldsetIdWithFocus = $event"></app-dataset-description>
<app-dataset-description (visibilityRulesInstance)="visRulesService = $event" [TOCENTRY_ID_PREFIX]="TOCENTRY_ID_PREFIX" [hidden]="this.step === 0" *ngIf="formGroup && formGroup.get('datasetProfileDefinition')" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="formGroup.get('datasetProfileDefinition').get('rules').value" [datasetProfileId]="formGroup.get('profile').value" [linkToScroll]="linkToScroll" (fieldsetFocusChange)="fieldsetIdWithFocus = $event"></app-dataset-description>
</div>
</div>
</form>

View File

@ -46,6 +46,7 @@ import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { HttpClient } from '@angular/common/http';
import { ToCEntry, ToCEntryType } from '@app/ui/misc/dataset-description-form/dataset-description.component';
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
@Component({
selector: 'app-dataset-wizard-component',
@ -98,6 +99,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
datasetIsOnceSaved = false;
fieldsetIdWithFocus:string;
visRulesService:VisibilityRulesService;
constructor(
private datasetWizardService: DatasetWizardService,

View File

@ -8,6 +8,7 @@ import { LinkToScroll } from '@app/ui/misc/dataset-description-form/tableOfConte
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
import { BaseComponent } from '@common/base/base.component';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { VisibilityRuleSource } from './visibility-rules/models/visibility-rule-source';
@Component({
selector: 'app-dataset-description',
@ -28,6 +29,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit
@Input() form: FormGroup;
@Input() TOCENTRY_ID_PREFIX="";
@Output() visibilityRulesInstance = new EventEmitter<VisibilityRulesService>();
public hiddenEntriesIds:string[] = [];
@ -40,6 +42,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit
ngOnInit() {
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.form);
// if (this.form) {
// this.form.valueChanges
// .pipe(takeUntil(this._destroyed))
@ -47,6 +50,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit
// this.formChanged.emit(val);
// });
// }
this.visibilityRulesInstance.emit(this.visibilityRulesService);
this.tocentries = this.getTocEntries();
this.hiddenEntriesIds = this._findHiddenEntries(this.tocentries);

View File

@ -64,11 +64,12 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
@Input() formGroup: FormGroup;
@Input() hasFocus: boolean = false;
@Input() visibilityRulesService: VisibilityRulesService;
show: boolean = false;
constructor(
@Inject(DOCUMENT) private _document: Document,
public visibilityRulesService: VisibilityRulesService
// public visibilityRulesService: VisibilityRulesService
) {
super();
}
@ -76,21 +77,23 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
ngOnInit(): void {
this.visibilityRulesService.visibilityChange
.pipe(takeUntil(this._destroyed))
.pipe(debounceTime(200))
.subscribe(_=>{
if(this.hasFocus){
this._resetObserver();
this.hiddenEntries = this._findHiddenEntries(this.tocentries);
}
})
// this.visibilityRulesService.visibilityChange
// .pipe(takeUntil(this._destroyed))
// .pipe(debounceTime(200))
// .subscribe(_=>{
// if(this.hasFocus){
// this._resetObserver();
// this.hiddenEntries = this._findHiddenEntries(this.tocentries);
// }
// })
if(this.formGroup){
this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition'));
const fg = this.formGroup.get('datasetProfileDefinition');
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, fg);
this.hiddenEntries = this._findHiddenEntries(this.tocentries);
// this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, fg);
if(this.visibilityRulesService){
this.hiddenEntries = this._findHiddenEntries(this.tocentries);
}
}else{
@ -189,6 +192,7 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
return invisibleEntries;
}
private _visibilityRulesSubscription:Subscription;
ngOnChanges(changes: SimpleChanges) {
if(this.selectedFieldsetId){
@ -206,6 +210,25 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
}
if('visibilityRulesService'){
if(this._visibilityRulesSubscription){
this._visibilityRulesSubscription.unsubscribe();
this._visibilityRulesSubscription = null;
}
if(!this.visibilityRulesService) return;
this._visibilityRulesSubscription = this.visibilityRulesService.visibilityChange
.pipe(takeUntil(this._destroyed))
.pipe(debounceTime(200))
.subscribe(_=>{
if(this.hasFocus){
this._resetObserver();
this.hiddenEntries = this._findHiddenEntries(this.tocentries);
}
});
this.hiddenEntries = this._findHiddenEntries(this.tocentries);
}
// if (!this.isActive && this.links && this.links.length > 0) {
// this.links.forEach(link => {
// link.selected = false;