Dataset Editor scrollspy on Guide Steps.Language text updates.

This commit is contained in:
Kristian Ntavidi 2021-04-08 18:29:08 +03:00
parent c57820d6b1
commit 20a92bea9d
10 changed files with 146 additions and 34 deletions

View File

@ -2,7 +2,7 @@ import { DOCUMENT } from '@angular/common';
import { Component, EventEmitter, Inject, OnInit, Output, Input, OnChanges } from '@angular/core';
import { BaseComponent } from '@common/base/base.component';
import { interval, Subject, Subscription } from 'rxjs';
import { distinctUntilChanged } from 'rxjs/operators';
import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
import { type } from 'os';
import { SimpleChanges } from '@angular/core';
import { ToCEntry, ToCEntryType } from '../dataset-description.component';
@ -52,6 +52,8 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
@Input() selectedFieldsetId:string;
private _tocentrySelected:ToCEntry = null;
private _intersectionObserver: IntersectionObserver;
private _actOnObservation: boolean = true;
get tocentrySelected(){
return this.hasFocus?this._tocentrySelected: null;
@ -73,11 +75,21 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
ngOnInit(): void {
this.visibilityRulesService.visibilityChange
.pipe(takeUntil(this._destroyed))
.pipe(debounceTime(200))
.subscribe(_=>{
// console.log('visibility was changed');
if(this.hasFocus){
this._resetObserver();
}
})
if(this.formGroup){
this.tocentries = this.getTocEntries(this.formGroup.get('datasetProfileDefinition'));
const fg = this.formGroup.get('datasetProfileDefinition');
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, fg);
}else{
//emit value every 500ms
@ -146,6 +158,17 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
if(this.selectedFieldsetId){
this.tocentrySelected = this._findTocEntryById(this.selectedFieldsetId,this.tocentries);
this._actOnObservation = false;
setTimeout(() => {
this._actOnObservation = true;
}, 1000);
}
if(changes['hasFocus'] && changes.hasFocus.currentValue){
this._resetObserver();
}
// if (!this.isActive && this.links && this.links.length > 0) {
@ -156,6 +179,57 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
// }
}
private _resetObserver(){
if(this._intersectionObserver){//clean up
this._intersectionObserver.disconnect();
this._intersectionObserver = null;
// console.log('Clean Up observer');
}
const options = {
root: null,
rootMargin: '-38% 0px -60% 0px',
threshold: 0
}
this._intersectionObserver = new IntersectionObserver((entries,observer)=>{
if(!this._actOnObservation){
return;
}
// console.log('observer called for element', entries );
// console.log('from observer', observer);
entries.forEach(ie=>{
if(ie.isIntersecting){
try{
const target_id = ie.target.id.replace(this.TOCENTRY_ID_PREFIX,'');
if(this.visibilityRulesService.checkElementVisibility(target_id)){
this.tocentrySelected = this._findTocEntryById(target_id,this.tocentries);
// console.log('target id', target_id);
}
}catch{
}
}
})
}, options);
// console.log('Initializing Intersection Observer');
const fieldsetsEtries = this._getAllFieldSets(this.tocentries);
fieldsetsEtries.forEach(e=>{
if(e.type === ToCEntryType.FieldSet){
try{
const targetElement = document.getElementById(this.TOCENTRY_ID_PREFIX+e.id);
this._intersectionObserver.observe(targetElement);
}catch{
console.log('element not found');
}
}
});
}
goToStep(link: Link) {
this.stepFound.emit({
page: link.page,
@ -342,6 +416,26 @@ export class TableOfContents extends BaseComponent implements OnInit, OnChanges
return tocEntryFound? tocEntryFound: null;
}
/**
* Get all filedsets in a tocentry array;
* @param entries Tocentries to search in
* @returns The tocentries that are Fieldsets provided in the entries
*/
private _getAllFieldSets(entries: ToCEntry[]):ToCEntry[]{
const fieldsets:ToCEntry[] = [];
if(!entries || !entries.length) return fieldsets;
entries.forEach(e=>{
if(e.type === ToCEntryType.FieldSet){
fieldsets.push(e);
}else{
fieldsets.push(...this._getAllFieldSets(e.subEntries));
}
});
return fieldsets;
}
}

View File

@ -1,6 +1,7 @@
import { ApplicationRef, Injectable, NgZone } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style';
import { Subject } from 'rxjs';
import { isNumeric } from 'rxjs/internal/util/isNumeric';
import { Rule } from '../../../../core/model/dataset-profile-definition/rule';
import { VisibilityRule } from './models/visibility-rule';
@ -13,6 +14,7 @@ export class VisibilityRulesService {
private visibilityRuleContext: VisibilityRulesContext;
private form: AbstractControl;
private elementVisibilityMap = new Map<String, boolean>();
private _changeMade$ = new Subject<void>();
constructor(
public applicationReference: ApplicationRef,
@ -49,6 +51,7 @@ export class VisibilityRulesService {
if(isVisible){
this._emitChangesIfNeeded(visibilityRule.targetControlId, true);
this.elementVisibilityMap.set(visibilityRule.targetControlId, true);
return;
}
@ -57,6 +60,7 @@ export class VisibilityRulesService {
for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) {
if (value != null && (this.parseValue(value) !== this.parseValue(visibilityRule.sourceVisibilityRules[i].sourceControlValue))) {
this._emitChangesIfNeeded(visibilityRule.targetControlId, false);
this.elementVisibilityMap.set(visibilityRule.targetControlId, false);
this.resetControlWithId(this.form, visibilityRule.targetControlId);
//this.updateValueAndVisibility(visibilityRule.targetControlId, null);
@ -64,6 +68,7 @@ export class VisibilityRulesService {
return;
}
}
this._emitChangesIfNeeded(visibilityRule.targetControlId, true);
this.elementVisibilityMap.set(visibilityRule.targetControlId, true);
//this.updateValueAndVisibility(visibilityRule.targetControlId, null);
}
@ -71,6 +76,7 @@ export class VisibilityRulesService {
private resetVisibilityRules() {
this.elementVisibilityMap.clear();
this.elementVisibilityMap = new Map<String, boolean>();
this._changeMade$.next();
}
parseValue(value: any) {
@ -155,4 +161,16 @@ export class VisibilityRulesService {
});
(formGroup.get('multiplicityItems') as FormArray).controls.splice(0);
}
private _emitChangesIfNeeded(id:string, valueToBeSet: boolean){
if(this.elementVisibilityMap.has(id)){
if(this.elementVisibilityMap.get(id) != valueToBeSet){
this._changeMade$.next();
}
}else{
this._changeMade$.next();
}
}
public get visibilityChange(){
return this._changeMade$.asObservable();
}
}

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Visibility Rules",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Value",
"ID": "Section Unique Identifier",
"VIEW-STYLE": "Type",
@ -468,7 +468,7 @@
"TARGET": "Target Field Id",
"VALUE": "Required Value",
"RULE-IF": "If Value is",
"RULE-THEN": "then show Field With Id",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Fördergeber",
"FUNDER-HINT": "Select a funder of your research or add new",
"FUNDING-ORGANIZATIONS": "Funding organizations",
"PROJECT-HINT": "This field is to be completed only for projects where multiple grants apply.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "DMP Status",
"EXTERNAL-SOURCE-HINT": "Liste der Werte, die von externer(n) Quelle(n) stammen",
"COLLABORATORS": "Mitwirkende",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Visibility Rules",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Value",
"ID": "Section Unique Identifier",
"VIEW-STYLE": "Type",
@ -468,7 +468,7 @@
"TARGET": "Target Field Id",
"VALUE": "Required Value",
"RULE-IF": "If Value is",
"RULE-THEN": "then show Field With Id",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview & Finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Funder",
"FUNDER-HINT": "Select a funder of your research or add new",
"FUNDING-ORGANIZATIONS": "Funding organizations",
"PROJECT-HINT": "This field is to be completed only for projects where multiple grants apply.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "DMP Status",
"EXTERNAL-SOURCE-HINT": "List of values provided by external source(s)",
"COLLABORATORS": "Collaborators",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Reglas de visibilidad",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Valor",
"ID": "Identificador único de sección",
"VIEW-STYLE": "Tipo",
@ -468,7 +468,7 @@
"TARGET": "Target Field Id",
"VALUE": "Valor requerido",
"RULE-IF": "Si el valor es",
"RULE-THEN": "entonces muestra el campo con identificación",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Financiador",
"FUNDER-HINT": "Select a funder of your research or add new",
"FUNDING-ORGANIZATIONS": "Organizaciones subvencionadoras",
"PROJECT-HINT": "This field is to be completed only for projects where multiple grants apply.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "Estado del PGD",
"EXTERNAL-SOURCE-HINT": "Lista de valores proporcioador por fuente(s) externa(s)",
"COLLABORATORS": "Colaboradores",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Κανονισμοί Ορατότητας",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Τιμή",
"ID": "Ενότητα Μοναδικού Αναγνωριστικού",
"VIEW-STYLE": "Τύπος",
@ -468,7 +468,7 @@
"TARGET": "Ταυτοποίηση στοχοθετημένου πεδίου",
"VALUE": "Απαιτούμενη τιμή",
"RULE-IF": "Εάν η τιμή είναι",
"RULE-THEN": "τότε δείξε το Πεδίο με ταυτοποίηση",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Χορηγός",
"FUNDER-HINT": "Επιλέξτε έναν χρηματοδότη της έρευνας σας ή προσθέστε νέο",
"FUNDING-ORGANIZATIONS": "Χρημαδοτικοί οργανισμοί",
"PROJECT-HINT": "Αυτό το πεδίο συμπληρώνεται μόνο για έργα όπου ισχύουν πολλαπλές επιχοροηγήσεις.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "Κατάσταση Σχεδίου Διαχείρισης Δεδομένων",
"EXTERNAL-SOURCE-HINT": "Κατάλογος των τιμών που παρέχονται από εξωτερικές πηγές",
"COLLABORATORS": "Συνεργάτες",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Regras de Visibilidade",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Valor",
"ID": "Identificador Único da Secção",
"VIEW-STYLE": "Tipo",
@ -468,7 +468,7 @@
"TARGET": "Id do Campo de Destino",
"VALUE": "Valor Obrigatório",
"RULE-IF": "Se Valor é",
"RULE-THEN": "então mostrar Campo com o Id",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Financiador",
"FUNDER-HINT": "Selecione o finaciador da sua investigação ou adicione um novo",
"FUNDING-ORGANIZATIONS": "Organizações de financiamento",
"PROJECT-HINT": "Este campo deverá ser preenchido apenas para projetos onde são aplicáveis múltiplos Grants.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "Estado do PGD",
"EXTERNAL-SOURCE-HINT": "Lista de valores fornecidos por entidade(s) externa(s)",
"COLLABORATORS": "Colaboradores",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Visibility Rules",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Value",
"ID": "Section Unique Identifier",
"VIEW-STYLE": "Type",
@ -468,7 +468,7 @@
"TARGET": "Target Field Id",
"VALUE": "Required Value",
"RULE-IF": "If Value is",
"RULE-THEN": "then show Field With Id",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Financovateľ",
"FUNDER-HINT": "Select a funder of your research or add new",
"FUNDING-ORGANIZATIONS": "Organizácia poskytujúca finančné prostriedky",
"PROJECT-HINT": "This field is to be completed only for projects where multiple grants apply.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "Stav DMP",
"EXTERNAL-SOURCE-HINT": "Zoznam hodnôt dodaných z externých zdrojov",
"COLLABORATORS": "Spolupracovníci",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Podešavanje vidljivosti",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Vrednost",
"ID": "Jedinstveni identifikator odeljka",
"VIEW-STYLE": "Tip",
@ -468,7 +468,7 @@
"TARGET": "Id ciljnog polja",
"VALUE": "Obavezna vrednost",
"RULE-IF": "Ako je vrednost",
"RULE-THEN": "tada prikazati polje sa Id",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Finansijer",
"FUNDER-HINT": "Odaberite Vašeg finansijera ili dodajte novog",
"FUNDING-ORGANIZATIONS": "Institucija finansijera",
"PROJECT-HINT": "Ovo polje se popunjava samo u slučaju kada se projekat finansira sa više grantova.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "Status Plana",
"EXTERNAL-SOURCE-HINT": "Lista vrednosti obezbeđenih od spoljnih izvora",
"COLLABORATORS": "Saradnici",

View File

@ -373,7 +373,7 @@
},
"FIELD": {
"FIELDS": {
"RULES-TITLE": "Görünürlük Kuralları",
"RULES-TITLE": "Conditional Questions",
"FIELD-RULES-VALUE": "Değer",
"ID": "Bölüm Benzersiz Tanımlayıcı",
"VIEW-STYLE": "Tip",
@ -468,7 +468,7 @@
"TARGET": "Hedef Alan Kimliği",
"VALUE": "Gerekli Değer",
"RULE-IF": "Eğer değer",
"RULE-THEN": "sonra alanı kimliği ile göster",
"RULE-THEN": "then show Question",
"FIELDSETS": "Questions",
"FIELDS":"Inputs"
},
@ -514,7 +514,7 @@
"PREVIEW-AND-FINALIZE": "Preview and finalize",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Add visibility rule",
"ADD-VISIBILITY-RULE": "Add Conditional Question",
"DELETE-INPUT": "Delete this input",
"PREVIEW": "Preview",
"NOT-INITIALIZED": "Not initialized yet"
@ -938,7 +938,7 @@
"FUNDER": "Fon Sağlayıcı",
"FUNDER-HINT": "Select a funder of your research or add new",
"FUNDING-ORGANIZATIONS": "Fon Sağlayıcı Kurumlar",
"PROJECT-HINT": "This field is to be completed only for projects where multiple grants apply.",
"PROJECT-HINT": "Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted.",
"STATUS": "VYP Durumu",
"EXTERNAL-SOURCE-HINT": "Dış kaynak(lar) tarafından sağlanan değerlerin listesi",
"COLLABORATORS": "Ortaklar",