fixed missing files error
This commit is contained in:
parent
a90c4d7561
commit
2c47630087
|
@ -1,3 +1,6 @@
|
|||
import { VisibilityRulesService } from './visibility-rules/visibility-rules.service';
|
||||
import { DynamicFormSectionComponent } from './form/dynamic-form-section/dynamic-form-section';
|
||||
import { DynamicFormCompositeFieldComponent } from './form/dynamic-form-composite-field/dynamic-form-composite-field';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule, forwardRef } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
|
@ -81,6 +84,7 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
|
|||
DynamicFormComponent,
|
||||
DynamicFormFieldComponent,
|
||||
DynamicFormGroupComponent,
|
||||
DynamicFormCompositeFieldComponent,
|
||||
TocComponent,
|
||||
GooggleSignInComponent,
|
||||
MainSignInComponent,
|
||||
|
@ -93,7 +97,7 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
|
|||
DatasetsComponent,
|
||||
ConfirmationComponent,
|
||||
AutocompleteRemoteComponent,
|
||||
|
||||
DynamicFormSectionComponent,
|
||||
ProjectTableFilterPipe,
|
||||
DmpVersionFilterPipe,
|
||||
DmpStatusFilterPipe,
|
||||
|
@ -126,7 +130,7 @@ import { ProjectDetailedComponent } from './viewers/project-detailed/project-det
|
|||
useClass: GlobalInterceptor,
|
||||
multi: true,
|
||||
},
|
||||
ServerService, dataModelBuilder, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService,NativeLoginService
|
||||
ServerService, dataModelBuilder,VisibilityRulesService, GlobalVariables, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService,NativeLoginService
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -7,24 +7,7 @@
|
|||
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||
|
||||
<div *ngFor = "let section of dataModel.sections; let i = index;">
|
||||
<div *ngIf="section.groupFields.length>0 else sectionHeader">
|
||||
<div *ngIf="shouldIShow(section);"><h3>{{section.title}}</h3></div>
|
||||
<div *ngFor="let group of section.groupFields">
|
||||
<div *ngIf="shouldIShow(group);" >
|
||||
<df-group [group]="group" [dataModel]="dataModel" [form]="getSubForm(group.key)"></df-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ng-template *ngIf="shouldIShow(section);" #sectionHeader>
|
||||
<h2>{{section.title}}</h2>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
<div *ngFor="let field of dataModel.fields">
|
||||
<div [formGroup]="form" class="form-group">
|
||||
<df-field [field]="field" [form]="form" [dataModel]="dataModel" ></df-field>
|
||||
</div>
|
||||
<df-section [section]="section" [form]="form.get('sections').get(''+i)"></df-section>
|
||||
</div>
|
||||
|
||||
<!-- <div *ngFor="let group of dataModel.groups">
|
||||
|
@ -36,7 +19,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12 form-footer-seperator" >
|
||||
<!-- <div class="col-md-12 form-footer-seperator" >
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -45,7 +28,6 @@
|
|||
<div >
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow= "" aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width': dirtyValues + '%'}">
|
||||
<!-- {{dirtyValues}}% -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -54,20 +36,19 @@
|
|||
<button type="button" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus" (click)="SaveForm();">Save</button>
|
||||
<button type="button" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus" data-toggle="modal" data-target="#confirmModal">Finalize</button>
|
||||
</div>
|
||||
|
||||
-->
|
||||
<!--
|
||||
<div *ngIf="payLoad" class="form-row">
|
||||
<strong>Saved the following values</strong><br>{{payLoad}}
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!--
|
||||
|
||||
<p>Form value: {{ form.value | json }}</p>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
<!-- pagination -->
|
||||
<!-- <div class="text-center">
|
||||
<ul *ngIf="pagination.pages && pagination.pages.length" class="pagination">
|
||||
<li [ngClass]="{disabled:pagination.currentPage === 1}">
|
||||
<a (click)="setPage(1)" class="cursor-link" >First</a>
|
||||
|
@ -85,35 +66,31 @@
|
|||
<a (click)="setPage(pagination.totalPages)" class="cursor-link">Last</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="!expandedToc" class="collapsed-div-caret" (click)="toggleTOC()">
|
||||
<!--
|
||||
<!-- <div *ngIf="!expandedToc" class="collapsed-div-caret" (click)="toggleTOC()">
|
||||
--> <!--
|
||||
<i class="fa toc-toggler" [ngClass]="{true:'fa-arrow-right', false:'fa-arrow-left'}[expandedToc]" aria-hidden="true" ><div>Show ToC</div></i>
|
||||
-->
|
||||
<i class="fa toc-toggler" aria-hidden="true" ><div>Show ToC</div></i>
|
||||
<!-- <i class="fa toc-toggler" aria-hidden="true" ><div>Show ToC</div></i>
|
||||
</div>
|
||||
|
||||
<div *ngIf="expandedToc" class="col-md-12" style="width:200px; text-align: center;">
|
||||
<h4 style="display: inline-block; text-align: center; width:150px;">Table of Contents</h4>
|
||||
<div class="child-div-caret" style="display: inline-block; width:50px;" (click)="toggleTOC()">
|
||||
<div class="child-div-caret" style="display: inline-block; width:50px;" (click)="toggleTOC()"> -->
|
||||
<!--
|
||||
<i class="fa toc-toggler" [ngClass]="{true:'fa-arrow-right', false:'fa-arrow-left'}[expandedToc]" aria-hidden="true" ><div>Shrink</div></i>
|
||||
-->
|
||||
<i class="fa toc-toggler" aria-hidden="true"><div>(hide)</div></i>
|
||||
<!-- <i class="fa toc-toggler" aria-hidden="true"><div>(hide)</div></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="child-div-right" [ngClass]="{true:'col-md-4 col-sm-3', false:'shrink-width' }[expandedToc]" id="toc-container">
|
||||
<toc [dataModel]="dataModel" (setPage)="setPage($event)"></toc>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
|
||||
|
@ -121,7 +98,7 @@
|
|||
|
||||
|
||||
<!--Modal for Confirmation -->
|
||||
<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="newVersionDmpModalLabel" aria-hidden="true">
|
||||
<!-- <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="newVersionDmpModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
@ -139,5 +116,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service';
|
||||
import { TestModel } from '../testModel/testmodel';
|
||||
import { DatasetModel } from '../models/DatasetModel';
|
||||
import { Rule } from '../models/Rule';
|
||||
|
||||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||
import { Component, Input, OnInit, AfterViewChecked, ViewChild, forwardRef } from '@angular/core';
|
||||
import { FormGroup, Validators, ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { NgForm } from '@angular/forms';
|
||||
|
@ -51,7 +57,7 @@ declare var PerfectScrollbar : any;
|
|||
})
|
||||
export class DynamicFormComponent implements OnInit {
|
||||
|
||||
@Input() dataModel: DataModel = new DataModel();
|
||||
@Input() dataModel: DatasetModel = new DatasetModel();
|
||||
form: FormGroup;
|
||||
payLoad = '';
|
||||
@Input() dirtyValues: number = 0;
|
||||
|
@ -69,7 +75,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
|
||||
|
||||
constructor(private qcs: FieldControlService, private serverService: ServerService, private dataModelService: dataModelBuilder, private router: Router,
|
||||
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService) {
|
||||
private _location: Location, private route: ActivatedRoute, private pagerService: PaginationService, private tokenService: TokenService,private visibilityRulesService:VisibilityRulesService) {
|
||||
this.form = this.qcs.toFormGroup(new Array(), new Array());
|
||||
this.xml2jsonOBJ = new X2JS();
|
||||
}
|
||||
|
@ -80,134 +86,14 @@ export class DynamicFormComponent implements OnInit {
|
|||
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
|
||||
|
||||
//this.route.fragment.subscribe(fragment => { this.fragment = fragment; }); //navigate to certain section of the page, it doesn't use anymore
|
||||
let sub = this.route.queryParams.subscribe(params => {
|
||||
this.id = params.id;
|
||||
this.datasetId = params.datasetId;
|
||||
//this.datasetProperties = params.datasetProperties
|
||||
});
|
||||
|
||||
|
||||
this.serverService.getDatasetByID(this.datasetId).subscribe(
|
||||
(data) => {
|
||||
var flatList;
|
||||
var formValues = "";
|
||||
if (data.properties) {
|
||||
console.log("Found already submitted form, loading that one!");
|
||||
simple_notifier("info",null,"Resumed previous form");
|
||||
formValues = JSON.parse(data.properties);
|
||||
flatList = flatten(formValues);
|
||||
//this.patchForm(flatList);
|
||||
if(data.status == 2) this.finalizeStatus=true;
|
||||
}
|
||||
|
||||
//the call for the dataset profile above - independent
|
||||
this.serverService.getDatasetProfileByID(this.id).subscribe(
|
||||
|
||||
response => {
|
||||
|
||||
console.log("response");
|
||||
console.log(response);
|
||||
|
||||
const data = response;
|
||||
|
||||
//replace the xmls {model,view,rule} definitions with json -- https://github.com/abdmob/x2js library
|
||||
data.definition = this.xml2jsonOBJ.xml_str2json(data.definition);
|
||||
data.ruleset.definition = this.xml2jsonOBJ.xml_str2json(data.ruleset.definition);
|
||||
data.viewstyle.definition = this.xml2jsonOBJ.xml_str2json(data.viewstyle.definition);
|
||||
//can be converted back to xml (which shouldn't be needed) with this.xml2jsonOBJ.json2xml_str
|
||||
|
||||
console.log("this.serverService.getFields");
|
||||
|
||||
console.log("data.dataset")
|
||||
console.log(data.definition)
|
||||
console.log(data.ruleset.definition)
|
||||
console.log(data.viewstyle.definition)
|
||||
|
||||
|
||||
this.dataModel = new DataModel();
|
||||
this.dataModel = this.dataModelService.getDataModel(data, formValues); //get formvalues and acossiate them with fields
|
||||
|
||||
this.form = this.qcs.toFormGroup(this.dataModel.fields, this.dataModel.groups);
|
||||
|
||||
this.form.valueChanges.subscribe(data => {
|
||||
// console.log('Form changes', data);
|
||||
let dirtyValuesArray: Array<any> = [];
|
||||
let count = 0;
|
||||
let countDirtyValues = 0;
|
||||
let percentage = 0;
|
||||
Object.keys(this.form.controls).forEach((c) => {
|
||||
//count++;
|
||||
let currentControl = this.form.controls[c];
|
||||
if (currentControl.dirty)
|
||||
dirtyValuesArray.push(currentControl.value);
|
||||
|
||||
});
|
||||
|
||||
Object.keys(this.form.value).forEach((c) => {
|
||||
//count++;
|
||||
Object.keys(this.form.value[c]).forEach((item) => {
|
||||
let value = this.form.value[c][item]
|
||||
if (typeof(value) == "string") value.trim();
|
||||
if(typeof(value)== "boolean") value.toString();
|
||||
if (value != undefined && value != "")
|
||||
countDirtyValues++; //TODO REMOVE SPACES FROM EMPTY STRING
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
this.dataModel.groups.forEach(grp => {
|
||||
grp.groupFields.forEach((fld) => {
|
||||
if (fld.visible == true || fld.visible == "true")
|
||||
count++;
|
||||
// if (fld.value != undefined && fld.value != " ")
|
||||
// countDirtyValues++;
|
||||
});
|
||||
});
|
||||
//console.log(count);
|
||||
// var percentage = Math.floor(dirtyValuesArray.length * 100 / count);
|
||||
percentage = Math.floor(countDirtyValues * 100 / count);
|
||||
this.dirtyValues = percentage;
|
||||
})
|
||||
|
||||
//this.form = this.qcs.toFormGroup(this.fields);
|
||||
|
||||
console.log("SUMMARY: ======>");
|
||||
console.log(this.dataModel);
|
||||
console.log(this.form);
|
||||
|
||||
this.route.paramMap //this is how i get the projects's id
|
||||
|
||||
// initialize to page 1
|
||||
this.setPage(1);
|
||||
|
||||
},
|
||||
err => {
|
||||
console.log("There was an error fetching the data from server");
|
||||
console.log(err);
|
||||
}
|
||||
);
|
||||
//end- klhsh gia to dataset profiel
|
||||
},
|
||||
(err) => {
|
||||
|
||||
});
|
||||
|
||||
var formScroller = new PerfectScrollbar("#form-container");
|
||||
var tocScroller = new PerfectScrollbar("#toc-container");
|
||||
|
||||
|
||||
|
||||
//this.breadcrumbService.breadcrumbDataEmitter
|
||||
|
||||
this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(TestModel,DatasetModel);
|
||||
this.form = this.dataModel.buildForm();
|
||||
this.visibilityRulesService.formGroup = this.form;
|
||||
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
||||
this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
}
|
||||
|
||||
scrollToElemID(elemID) {
|
||||
/* scrollToElemID(elemID) {
|
||||
scroll("#" + elemID);
|
||||
}
|
||||
|
||||
|
@ -310,5 +196,5 @@ export class DynamicFormComponent implements OnInit {
|
|||
toggleTOC(){
|
||||
this.expandedToc = !this.expandedToc;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
|
@ -8,10 +8,11 @@ export class VisibilityRulesService {
|
|||
|
||||
public formGroup: FormGroup;
|
||||
public visibilityRuleContext: VisibilityRulesContext;
|
||||
|
||||
public isElementVisible(pathKey: string,id:string) {
|
||||
public fieldsPathMemory: any = {};
|
||||
public isElementVisible(pathKey: string, id: string) {
|
||||
if (!this.fieldsPathMemory[id]) this.fieldsPathMemory[id] = pathKey;
|
||||
let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id);
|
||||
if(!visibilityRule) return true;
|
||||
if (!visibilityRule) return true;
|
||||
return this.checkElementVisibility(visibilityRule);
|
||||
}
|
||||
|
||||
|
@ -19,7 +20,8 @@ export class VisibilityRulesService {
|
|||
let sourceVisibilityRules = visibilityRule.sourceVisibilityRules;
|
||||
for (let i = 0; i < sourceVisibilityRules.length; i++) {
|
||||
let sourceVisibilityRule = sourceVisibilityRules[i];
|
||||
if (sourceVisibilityRule.sourceControlValue != this.formGroup.get(this.getParentPath(sourceVisibilityRule.sourceControlId)).value) return false;
|
||||
if (!this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value')||
|
||||
(sourceVisibilityRule.sourceControlValue != this.formGroup.get( this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +31,7 @@ export class VisibilityRulesService {
|
|||
this.visibilityRuleContext.buildVisibilityRuleContext(item);
|
||||
}
|
||||
|
||||
private getParentPath(parentId:string):string{
|
||||
private getParentPath(parentId: string): string {
|
||||
return '';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Data Management Plans Creator</title>
|
||||
<base href="/">
|
||||
<meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
<!--
|
||||
<script src="https://apis.google.com/js/platform.js" ></script>
|
||||
-->
|
||||
<link rel="stylesheet" href="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.css"><!--bootstrap plugin for ToC-->
|
||||
<script src="https://cdn.rawgit.com/afeld/bootstrap-toc/v0.4.1/dist/bootstrap-toc.min.js"></script>
|
||||
|
||||
|
||||
<!-- XML to json and vice versa lib -->
|
||||
<script src="assets/xml2json.min.js"></script>
|
||||
|
||||
<!-- Json formatter lib -->
|
||||
<link rel="stylesheet" type="text/css" href="assets/jquery.json-viewer.css">
|
||||
<script src="assets/jquery.json-viewer.js"></script>
|
||||
|
||||
<!-- lib 4 pretty-printing xml and json -->
|
||||
<script src="assets/vkbeautify.0.99.00.js"></script>
|
||||
|
||||
<!-- Nice BS notifications -->
|
||||
<script src="assets/bootstrap-notify.min.js"></script>
|
||||
|
||||
<!-- that's google sign in library -->
|
||||
<script src="https://apis.google.com/js/platform.js"></script>
|
||||
|
||||
<!-- font-awesome css -->
|
||||
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
||||
|
||||
<!-- Customized scrollbars source: https://github.com/utatti/perfect-scrollbar -->
|
||||
<link rel="stylesheet" type="text/css" href="assets/perfect-scrollbar/perfect-scrollbar.css">
|
||||
<script src="assets/perfect-scrollbar/perfect-scrollbar.js"></script>
|
||||
|
||||
|
||||
<!-- my custom global code and css -->
|
||||
<link rel="stylesheet" type="text/css" href="assets/custom.css">
|
||||
<script src="assets/custom.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
function signOut() {
|
||||
var auth2 = gapi.auth2.getAuthInstance();
|
||||
auth2.signOut().then(function () {
|
||||
console.log('User signed out.');
|
||||
localStorage.removeItem('currentUser');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<app-root></app-root>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue