no message
This commit is contained in:
parent
bfdcdff33a
commit
8c7d505178
|
@ -19,9 +19,9 @@ public abstract class AbstractBatchLogger {
|
|||
private Map<String, Object> concurrentHashMap = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
public AbstractBatchLogger(Environment environment) {
|
||||
//ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
//executor.scheduleAtFixedRate(() -> this.outputData(), Long.parseLong(environment.getProperty("http-logger.initial-delay")), Long.parseLong(environment.getProperty("http-logger.delay")), TimeUnit.SECONDS);
|
||||
executor.scheduleAtFixedRate(() -> this.outputData(), Long.parseLong(environment.getProperty("http-logger.initial-delay")), Long.parseLong(environment.getProperty("http-logger.delay")), TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public abstract LoggingOutputType logOutputType();
|
||||
|
|
|
@ -15,7 +15,7 @@ import { ExternalSourcesService } from '../../services/external-sources/external
|
|||
import { DatasetWizardService } from '../../services/dataset-wizard/dataset-wizard.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ActivatedRoute, Router, Params } from '@angular/router';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef } from "@angular/core";
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation, TemplateRef, ChangeDetectionStrategy } from "@angular/core";
|
||||
import { FormGroup, Validators, FormBuilder, FormArray } from "@angular/forms";
|
||||
import * as FileSaver from 'file-saver';
|
||||
import { MatPaginator, MatSort, MatSnackBar, MatStepper, MatDialog } from "@angular/material";
|
||||
|
@ -46,7 +46,7 @@ import { ServicesReferencedModelHelperComponent } from '../dataset-referenced-mo
|
|||
selector: 'app-dataset-wizard-component',
|
||||
templateUrl: 'dataset-wizard.component.html',
|
||||
styleUrls: ['./dataset-wizard.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
})
|
||||
export class DatasetWizardComponent implements OnInit, IBreadCrumbComponent {
|
||||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form" [ngSwitch]="field.viewStyle.renderStyle">
|
||||
<div *ngIf="form" [id]="field.id" [formGroup]="form" [ngSwitch]="field.viewStyle.renderStyle">
|
||||
|
||||
<!-- <h5 *ngIf="field.title">{{field.title}}</h5> -->
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Field } from '../../models/Field';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -12,20 +13,25 @@ import { VisibilityRulesService } from '../../utilities/visibility-rules/visibil
|
|||
styleUrls: [
|
||||
'./dynamic-form-field.component.css'
|
||||
],
|
||||
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
||||
export class DynamicFormFieldComponent implements OnInit {
|
||||
@Input() field: Field;
|
||||
@Input() form: FormGroup;
|
||||
form: FormGroup;
|
||||
@Input() pathName: string;
|
||||
@Input() path: string;
|
||||
change: Subscription;
|
||||
trackByFn = (index,item) => item["id"]
|
||||
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) {
|
||||
|
||||
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) { }
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.form.get('value').valueChanges.subscribe(item => {
|
||||
this.form = this.visibilityRulesService.getFormGroup(this.field.id)
|
||||
if(!this.form) debugger;
|
||||
if(!this.form.get('value')) debugger;
|
||||
this.change = this.form.get('value').valueChanges.subscribe(item => {
|
||||
this.visibilityRulesService.updateValueAndVisibility(this.field.id)
|
||||
})
|
||||
}
|
||||
|
@ -34,6 +40,12 @@ export class DynamicFormFieldComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
//Called once, before the instance is destroyed.
|
||||
//Add 'implements OnDestroy' to the class.
|
||||
this.change.unsubscribe()
|
||||
}
|
||||
|
||||
clearInput() {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div [id]="compositeField.id" [formGroup]="form">
|
||||
<div *ngIf="form" [id]="compositeField.id" [formGroup]="form">
|
||||
|
||||
<div *ngIf="compositeField.fields.length == 1" class="fieldset-component">
|
||||
<h5 *ngIf="compositeField.title" style="font-weight:bold; color: #3a3737;">{{compositeField.title}}</h5>
|
||||
|
@ -7,7 +7,7 @@
|
|||
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
||||
<i>{{compositeField.extendedDescription}}</i>
|
||||
</h5>
|
||||
<df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]" [form]="form.get('fields').get(''+0)"
|
||||
<df-field *ngIf="compositeField.fields.length == 1" [field]="compositeField.fields[0]"
|
||||
[pathName]="pathName+'.fields.'+0"></df-field>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -20,8 +20,8 @@
|
|||
<h5 *ngIf="compositeField.extendedDescription" class="fieldset-extended-desc">
|
||||
<i>{{compositeField.extendedDescription}}</i>
|
||||
</h5>
|
||||
<div *ngFor="let field of compositeField.fields; let i = index;">
|
||||
<div *ngIf="visibilityRulesService.isElementVisible(null,field.id)">
|
||||
<div *ngFor="let field of compositeField.fields; let i = index; trackBy: trackByFn ">
|
||||
<div>
|
||||
<div *ngIf="(field?.multiplicity?.max - 1) > (field?.multiplicityItems?.length)">
|
||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||
Add one more field +
|
||||
|
@ -29,9 +29,9 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<df-field [field]="field" [form]="form.get('fields').get(''+i)" [pathName]="pathName+'.fields.'+i"></df-field>
|
||||
<div *ngFor="let multipleField of field.multiplicityItems; let j = index;">
|
||||
<df-field [field]="multipleField" [form]="form.get('fields').get(''+i).get('multiplicityItems').get(''+j)" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
|
||||
<df-field [field]="field" [pathName]="pathName+'.fields.'+i"></df-field>
|
||||
<div *ngFor="let multipleField of field.multiplicityItems; let j = index; trackBy: trackByFn">
|
||||
<df-field [field]="multipleField" [pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||
import { CompositeField } from '../../models/CompositeField';
|
||||
import { FormGroup, FormArray } from '@angular/forms';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Field } from '../../models/Field';
|
||||
@Component({
|
||||
selector: 'df-composite-field',
|
||||
|
@ -14,15 +14,19 @@ import { Field } from '../../models/Field';
|
|||
export class DynamicFormCompositeFieldComponent implements OnInit {
|
||||
|
||||
@Input() compositeField: CompositeField
|
||||
@Input() form: FormGroup;
|
||||
form: FormGroup;
|
||||
@Input() pathName: string;
|
||||
@Input() path: string;
|
||||
trackByFn = (index, item) => item["id"]
|
||||
|
||||
constructor(private visibilityRulesService: VisibilityRulesService) { }
|
||||
constructor(private visibilityRulesService: VisibilityRulesService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.form = this.visibilityRulesService.getFormGroup(this.compositeField.id)
|
||||
}
|
||||
|
||||
|
||||
addMultipleField(fieldIndex: number) {
|
||||
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex, "");
|
||||
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<div *ngIf="visibilityRulesService.isElementVisible(pathName,group.id)" class="group-component" [id]="group.id" [formGroup]="form">
|
||||
<div *ngIf="form" class="group-component" [id]="group.id" [formGroup]="form">
|
||||
<div class="content-left-margin">
|
||||
|
||||
<div *ngFor="let compositeField of group.compositeFields; let i = index;">
|
||||
<div *ngIf="visibilityRulesService.isElementVisible(null,compositeField.id)">
|
||||
<div *ngFor="let compositeField of group.compositeFields; let i = index; trackBy: trackByFn">
|
||||
<div>
|
||||
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
|
||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||
Add one more fieldset +
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index;">
|
||||
<df-composite-field [compositeField]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||
<df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
|
||||
<df-composite-field [compositeField]="multipleCompositeField"
|
||||
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||
import { FieldGroup } from '../../models/FieldGroup';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { FormGroup, Validators, FormControl, FormArray } from '@angular/forms';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { CompositeField } from '../../models/CompositeField';
|
||||
|
@ -15,31 +15,16 @@ import { CompositeField } from '../../models/CompositeField';
|
|||
})
|
||||
export class DynamicFormGroupComponent implements OnInit {
|
||||
@Input() group: FieldGroup
|
||||
@Input() form: FormGroup;
|
||||
form: FormGroup;
|
||||
@Input() pathName: string;
|
||||
|
||||
@Input() path: string;
|
||||
|
||||
|
||||
trackByFn = (index,item) => item["id"]
|
||||
constructor(public visibilityRulesService: VisibilityRulesService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
//let st = this.group.style == "any" ? "" : this.group.style;
|
||||
//this.classFromJson = this.group.class == "" ? "" : this.group.class;
|
||||
|
||||
/* this.customStyle = {};
|
||||
if (st != "") {
|
||||
st.replace(/"/g, '\\"');
|
||||
|
||||
var attributes = st.split(';');
|
||||
for (var i = 0; i < attributes.length; i++) {
|
||||
var entry = attributes[i].split(':');
|
||||
entry[1].replace(/["]/g, " ");
|
||||
//this.customStyle[entry[0]] = '2px solid #c1baba';
|
||||
var a = entry[0];
|
||||
this.customStyle[a] = entry[1];
|
||||
} */
|
||||
this.form = this.visibilityRulesService.getFormGroup(this.group.id)
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,29 +35,7 @@ export class DynamicFormGroupComponent implements OnInit {
|
|||
}
|
||||
|
||||
addFieldSet() {
|
||||
/* debugger;
|
||||
let subgroup: any = {};
|
||||
this.group.compositeFields.groupFields.forEach((field, i) => {
|
||||
debugger;
|
||||
this.form.addControl(field.key + "_" + i, new FormControl(""))
|
||||
|
||||
if (field.controlType == "textbox") {
|
||||
let newfield: FieldBase<any>;
|
||||
let rule = new Rule();
|
||||
newfield = new TextboxField({
|
||||
label: field.label + "_" + i,
|
||||
key: field.key + "_" + i,
|
||||
value: "",
|
||||
order: field.order,
|
||||
rules: field.rules,
|
||||
visible: field.visible,
|
||||
group: field.group,
|
||||
description: field.description
|
||||
});
|
||||
this.group.compositeFields.groupFields.push(newfield)
|
||||
}
|
||||
|
||||
}); */
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div *ngIf="visibilityRulesService.isElementVisible(pathName,section.id)" class="panel-group" style="margin-top:10px;">
|
||||
<div class="panel-group" style="margin-top:10px;">
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel expanded=true>
|
||||
<mat-expansion-panel-header>
|
||||
|
@ -7,20 +7,20 @@
|
|||
</mat-panel-title>
|
||||
<mat-panel-description>
|
||||
<h3 *ngIf="section.description">{{section.description}}</h3>
|
||||
<h4 *ngIf="section.extendedDescription">{{section.extendedDescription}}</h4>
|
||||
<!-- <h4 *ngIf="section.extendedDescription">{{section.extendedDescription}}</h4> -->
|
||||
</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
<div *ngFor="let compositeField of section.compositeFields; let i = index;">
|
||||
<div *ngIf="isVisible(pathName+'.compositeFields.'+i, compositeField)">
|
||||
<div *ngFor="let compositeField of section.compositeFields; let i = index; trackBy: trackByFn">
|
||||
<div>
|
||||
<div *ngIf="(compositeField?.multiplicity?.max - 1) > (compositeField?.multiplicityItems?.length)">
|
||||
<a (click)="addMultipleField(i)" style="cursor: pointer">
|
||||
Add one more fieldset +
|
||||
</a>
|
||||
</div>
|
||||
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index;">
|
||||
<df-composite-field [compositeField]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||
<df-composite-field [compositeField]="compositeField" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
||||
<div *ngFor="let multipleCompositeField of compositeField.multiplicityItems; let j = index; trackBy: trackByFn">
|
||||
<df-composite-field [compositeField]="multipleCompositeField"
|
||||
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||
</div>
|
||||
<div *ngIf="compositeField.hasCommentField" [formGroup]="form.get('compositeFields').get(''+i)">
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
<div *ngIf="section.sections">
|
||||
<div *ngFor="let itemsection of section.sections; let j = index;">
|
||||
<df-section [section]="itemsection" [form]="form.get('sections').get(''+j)" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></df-section>
|
||||
<df-section [section]="itemsection" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j"></df-section>
|
||||
</div>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||
import { FormGroup, Form, FormArray } from '@angular/forms';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { CompositeField } from '../../models/CompositeField';
|
||||
import { Section } from '../../models/Section';
|
||||
|
||||
|
@ -16,12 +16,14 @@ import { Section } from '../../models/Section';
|
|||
export class DynamicFormSectionComponent implements OnInit {
|
||||
|
||||
@Input() section: Section
|
||||
@Input() form: FormGroup;
|
||||
form: FormGroup;
|
||||
@Input() pathName: string;
|
||||
@Input() path: string;
|
||||
trackByFn = (item) => item["id"]
|
||||
constructor(public visibilityRulesService: VisibilityRulesService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.form = this.visibilityRulesService.getFormGroup(this.section.id)
|
||||
}
|
||||
|
||||
addMultipleField(fieldsetIndex: number) {
|
||||
|
@ -31,9 +33,9 @@ export class DynamicFormSectionComponent implements OnInit {
|
|||
}
|
||||
|
||||
isVisible(pathname: string, fieldSet: CompositeField): boolean {
|
||||
if (!this.visibilityRulesService.isElementVisible(pathname, fieldSet.id)) return false;
|
||||
if (!fieldSet || !this.visibilityRulesService.getFormGroup(fieldSet.id)) return false;
|
||||
for (var i = 0; i < fieldSet.fields.length; i++) {
|
||||
if (this.visibilityRulesService.isElementVisible(pathname + '.fields.' + i, fieldSet.fields[i].id))
|
||||
if (this.visibilityRulesService.getFormGroup(fieldSet.fields[i].id))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,47 +1,44 @@
|
|||
<div class="dynamic-form-editor">
|
||||
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
|
||||
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
|
||||
<!-- <mat-sidenav-container class="ng-sidebar-container"> -->
|
||||
<!-- <mat-sidenav mode="push" position="right" [(opened)]="visibleSidebar">
|
||||
<table-of-content class="toc-container full-height" [model]="datasetProfileDefinitionModel"></table-of-content>
|
||||
</mat-sidenav> -->
|
||||
|
||||
<!-- <mat-sidenav-content> -->
|
||||
<!-- <button mat-raised-button color="primary" style="margin: 15px;" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button> -->
|
||||
<form *ngIf="form" novalidate [formGroup]="form">
|
||||
<!-- <button mat-raised-button color="primary" *ngIf="dataModel&&dataModel.status.toString() != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||
<!-- <mat-sidenav-content> -->
|
||||
<!-- <button mat-raised-button color="primary" style="margin: 15px;" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button> -->
|
||||
<form *ngIf="form" novalidate [formGroup]="form">
|
||||
<!-- <button mat-raised-button color="primary" *ngIf="dataModel&&dataModel.status.toString() != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||
(click)="save();" type="button">Save</button>
|
||||
<button mat-raised-button color="primary" *ngIf="dataModel&&dataModel?.status != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||
(click)="saveFinalize();" type="button">Save and Finalize</button> -->
|
||||
<div>
|
||||
<div class="alignment-center">
|
||||
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
|
||||
<progress-bar *ngIf="form" [formGroup]="form"></progress-bar>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="alignment-center">
|
||||
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
|
||||
<progress-bar *ngIf="form" [formGroup]="form"></progress-bar>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
|
||||
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
|
||||
<mat-vertical-stepper #stepper [linear]="false">
|
||||
<div *ngFor="let page of datasetProfileDefinitionModel.pages let z=index;">
|
||||
<div *ngFor="let section of page.sections; let i = index;">
|
||||
<mat-step [stepControl]="section">
|
||||
<ng-template matStepLabel>{{page.title}}</ng-template>
|
||||
<div *ngIf="stepper.selectedIndex == z">
|
||||
<df-section [section]="section" [form]="form.get('pages').get(''+z).get('sections').get(''+i)" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></df-section>
|
||||
<!-- <div>
|
||||
<button mat-button matStepperNext>Next</button>
|
||||
</div> -->
|
||||
</div>
|
||||
</mat-step>
|
||||
</div>
|
||||
</div>
|
||||
</mat-vertical-stepper>
|
||||
<!-- <div *ngFor="let section of datasetProfileDefinitionModel.sections; let i = index;">
|
||||
<div *ngIf='datasetProfileDefinitionModel' class="col-md-12" id="form-container">
|
||||
<!-- <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> -->
|
||||
<mat-vertical-stepper #stepper [linear]="false">
|
||||
<div *ngFor="let page of datasetProfileDefinitionModel.pages; let z=index; trackBy: pageTrackByFn">
|
||||
<div *ngFor="let section of page.sections; let i = index; trackBy: trackByFn">
|
||||
<mat-step [stepControl]="section">
|
||||
<ng-template matStepLabel>{{page.title}}</ng-template>
|
||||
<div *ngIf="stepper.selectedIndex == z">
|
||||
<df-section [section]="section" [path]="z+1" [pathName]="'pages.'+z+'.sections.'+i"></df-section>
|
||||
</div>
|
||||
</mat-step>
|
||||
</div>
|
||||
</div>
|
||||
</mat-vertical-stepper>
|
||||
<!-- <div *ngFor="let section of datasetProfileDefinitionModel.sections; let i = index;">
|
||||
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
|
||||
[pathName]="'sections.'+i"></df-section>
|
||||
</div> -->
|
||||
</div>
|
||||
</form>
|
||||
<!-- </mat-sidenav-content>
|
||||
</div>
|
||||
</form>
|
||||
<!-- </mat-sidenav-content>
|
||||
</mat-sidenav-container> -->
|
||||
</div>
|
||||
<!-- <p>Form value: {{ form.value | json }}</p> -->
|
||||
|
|
|
@ -6,7 +6,7 @@ import { BaseHttpService } from '../../utilities/cite-http-service-module/base-h
|
|||
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
||||
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
|
||||
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
|
||||
import { Component, Input, OnInit, AfterViewChecked, ViewChild, forwardRef, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Input, OnInit, AfterViewChecked, ViewChild, forwardRef, ViewEncapsulation, AfterViewInit, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { FormGroup, Validators, ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { NgForm } from '@angular/forms';
|
||||
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
|
||||
|
@ -28,10 +28,13 @@ declare function simple_notifier(type: string, title: string, message: string):
|
|||
})
|
||||
export class DynamicFormComponent implements OnInit {
|
||||
|
||||
|
||||
@Input() dataModel: DatasetWizardModel = new DatasetWizardModel();
|
||||
@Input() path: string;
|
||||
@Input() form: FormGroup;
|
||||
id: string;
|
||||
trackByFn = (index,item) => item["id"]
|
||||
pageTrackByFn = (index,item) => item["id"]
|
||||
|
||||
// @Input() datasetId: string;
|
||||
pathName: string;
|
||||
|
@ -64,6 +67,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
this.visibilityRulesService.formGroup = this.form;
|
||||
this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
this.datasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition
|
||||
this.visibilityRulesService.setModel(this.datasetProfileDefinitionModel)
|
||||
this.createPagination();
|
||||
this.progressbar = true;
|
||||
|
||||
|
@ -78,6 +82,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
toggleSidebar() {
|
||||
this.visibleSidebar = !this.visibleSidebar;
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@ export class ProgressBarComponent implements OnInit {
|
|||
else if (control instanceof FormArray) {
|
||||
let formArray = (<FormArray>control);
|
||||
for (let i = 0; i < formArray.length; i++) {
|
||||
if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
||||
value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
||||
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
||||
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
||||
}
|
||||
}
|
||||
else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
||||
value++;
|
||||
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
||||
//value++;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
import { Serializable } from '../models/interfaces/Serializable';
|
||||
export class JsonSerializer {
|
||||
|
||||
public static fromJSONArray<T extends Serializable<T>>(items: any[], type: { new(): T; }): T[] {
|
||||
if (!items) return new Array<T>();
|
||||
const objectList: T[] = new Array<T>();
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
objectList.push(new type().fromJSONObject(items[i]))
|
||||
}
|
||||
return objectList;
|
||||
public static fromJSONArray<T extends Serializable<T>>(items: any[], type: { new(): T; }): T[] {
|
||||
if (!items) return new Array<T>();
|
||||
const objectList: T[] = new Array<T>();
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
objectList.push(new type().fromJSONObject(items[i]))
|
||||
}
|
||||
return objectList;
|
||||
}
|
||||
|
||||
public static fromJSONObject<T extends Serializable<T>>(item: any, type: { new(): T; }): T {
|
||||
if (!item) return null;
|
||||
return new type().fromJSONObject(item);
|
||||
}
|
||||
public static fromJSONObject<T extends Serializable<T>>(item: any, type: { new(): T; }): T {
|
||||
if (!item) return null;
|
||||
return new type().fromJSONObject(item);
|
||||
}
|
||||
|
||||
public static copy<T extends Serializable<T>>(item: any, itemToCopy: any): T {
|
||||
if (!item) return null;
|
||||
return item.fromJSONObject(itemToCopy);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
import { VisibilityRule } from './models/VisibilityRule';
|
||||
import { VisibilityRulesContext } from './models/VisibilityRulesContext';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, ApplicationRef, NgZone } from '@angular/core';
|
||||
import { Rule } from '../../models/Rule';
|
||||
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
|
||||
import { JsonSerializer } from '../JsonSerializer';
|
||||
@Injectable()
|
||||
export class VisibilityRulesService {
|
||||
|
||||
|
@ -10,17 +12,27 @@ export class VisibilityRulesService {
|
|||
public visibilityRuleContext: VisibilityRulesContext;
|
||||
public fieldsPathMemory: any = {};
|
||||
private elementVisibilityMap = new Map<String, boolean>();
|
||||
private initialModel: DatasetProfileDefinitionModel;
|
||||
private currentModel: DatasetProfileDefinitionModel;
|
||||
|
||||
public isElementVisible(pathKey: string, id: string) {
|
||||
constructor(public applicationReference: ApplicationRef, public ngZone: NgZone) {
|
||||
|
||||
}
|
||||
|
||||
public setModel(model: DatasetProfileDefinitionModel) {
|
||||
this.initialModel = JsonSerializer.fromJSONObject(model, DatasetProfileDefinitionModel);
|
||||
this.currentModel = model
|
||||
this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item))
|
||||
|
||||
}
|
||||
|
||||
public getFormGroup(id: string): FormGroup {
|
||||
let pathKeyArray = this.search("pages", this.initialModel.pages, id).split(".")
|
||||
|
||||
pathKeyArray.pop();
|
||||
let pathKey = pathKeyArray.join(".");
|
||||
if (!this.fieldsPathMemory[id] && pathKey) this.fieldsPathMemory[id] = pathKey;
|
||||
if (pathKey && this.visibilityRuleContext.getRulesFromKey(id)) this.evaluateVisibility(this.visibilityRuleContext.getRulesFromKey(id))
|
||||
|
||||
if (this.checkElementVisibility(id)) {
|
||||
return true
|
||||
} else {
|
||||
this.clearValues(pathKey)
|
||||
return false;
|
||||
}
|
||||
return (<FormGroup>this.formGroup.get(pathKey));
|
||||
}
|
||||
|
||||
public checkElementVisibility(id: string): boolean {
|
||||
|
@ -44,16 +56,25 @@ export class VisibilityRulesService {
|
|||
if (this.formGroup.get(pathKey + '.value') && ((this.formGroup.get(pathKey + '.value').value == null || this.formGroup.get(pathKey + '.value').value == undefined) || "" + this.formGroup.get(pathKey + '.value').value != "" + visibilityRule.sourceVisibilityRules[i].sourceControlValue)) {
|
||||
if (this.formGroup.get(pathKey).parent.get("id")) {
|
||||
if (!this.checkElementVisibility(this.formGroup.get(pathKey).parent.get("id").value)) {
|
||||
let targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId]
|
||||
this.getObject(this.currentModel, "id", visibilityRule.targetControlId, this.currentModel, true)
|
||||
this.elementVisibilityMap.set(visibilityRule.targetControlId, false)
|
||||
this.clearValues(targetPathKey)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let targetPathKey = this.fieldsPathMemory[visibilityRule.targetControlId]
|
||||
this.getObject(this.currentModel, "id", visibilityRule.targetControlId, this.currentModel, true)
|
||||
this.elementVisibilityMap.set(visibilityRule.targetControlId, false)
|
||||
this.clearValues(targetPathKey)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let obj = this.getObject(this.initialModel, "id", visibilityRule.targetControlId, this.initialModel)
|
||||
let targetObjPathKey = this.fieldsPathMemory[visibilityRule.targetControlId] ? this.fieldsPathMemory[visibilityRule.targetControlId] : this.search("pages", this.initialModel.pages, obj);
|
||||
this.updateValue(this.currentModel, obj, targetObjPathKey)
|
||||
this.elementVisibilityMap.set(visibilityRule.targetControlId, true)
|
||||
}
|
||||
|
||||
|
@ -67,6 +88,61 @@ export class VisibilityRulesService {
|
|||
for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++)
|
||||
this.clearValues(pathKey + '.fields.' + i);
|
||||
}
|
||||
}
|
||||
|
||||
// deleteFromModel(path: string, obj: any) {
|
||||
// if (!path) return
|
||||
// const _obj = JSON.parse(JSON.stringify(obj));
|
||||
// const keys = path.split('.');
|
||||
|
||||
// keys.reduce((acc, key, index) => {
|
||||
// if (index === keys.length - 1) {
|
||||
// delete acc[key];
|
||||
// return true;
|
||||
// }
|
||||
// return acc[key];
|
||||
// }, _obj);
|
||||
// return _obj;
|
||||
// }
|
||||
|
||||
updateValue(obj, value, path) {
|
||||
var i;
|
||||
if (value['id'].targetControlId === "other216a") debugger;
|
||||
path = path.split('.');
|
||||
for (i = 0; i < path.length - 1; i++)
|
||||
obj = obj[path[i]];
|
||||
|
||||
for (let propIndex = 0; propIndex < obj.length; propIndex++) {
|
||||
if (obj[propIndex]["id"] === value["id"]) return
|
||||
}
|
||||
obj.splice(path[i], 0, value);
|
||||
}
|
||||
|
||||
search(path, obj, target) {
|
||||
for (var k in obj) {
|
||||
if (obj.hasOwnProperty(k))
|
||||
if (obj[k] === target)
|
||||
return path + "." + k
|
||||
else if (typeof obj[k] === "object") {
|
||||
var result = this.search(path + "." + k, obj[k], target);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private getObject(obj, key, val, parent, deleteObj = false) {
|
||||
for (var i in obj) {
|
||||
if (!obj.hasOwnProperty(i)) continue;
|
||||
if (typeof obj[i] == 'object') {
|
||||
let returnObj = this.getObject(obj[i], key, val, obj, deleteObj);
|
||||
if (returnObj) return returnObj
|
||||
} else if (i == key && obj[key] == val) {
|
||||
//console.log(obj[key])
|
||||
if (deleteObj) parent.splice(parent.indexOf(obj), 1);
|
||||
return obj
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue