no message
This commit is contained in:
parent
e6962b05e2
commit
bbb046656c
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PropertiesModel implements PropertiesGenerator{
|
public class PropertiesModel implements PropertiesGenerator{
|
||||||
|
private int status;
|
||||||
private List<Section> sections;
|
private List<Section> sections;
|
||||||
|
|
||||||
public List<Section> getSections() {
|
public List<Section> getSections() {
|
||||||
|
@ -15,6 +16,14 @@ public class PropertiesModel implements PropertiesGenerator{
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toMap(Map<String, Object> fieldValues) {
|
public void toMap(Map<String, Object> fieldValues) {
|
||||||
this.sections.forEach(item->item.toMap(fieldValues));
|
this.sections.forEach(item->item.toMap(fieldValues));
|
||||||
|
|
|
@ -122,12 +122,12 @@ public class Field implements Comparable,PropertiesModelBuilder, ModelDefinition
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Field cloneForMultiplicity(String id, Map<String, Object> properties){
|
public Field cloneForMultiplicity(String key, Map<String, Object> properties){
|
||||||
Field newField = new Field();
|
Field newField = new Field();
|
||||||
newField.id = id;
|
newField.id = key;
|
||||||
newField.ordinal = this.ordinal;
|
newField.ordinal = this.ordinal;
|
||||||
newField.title = this.title;
|
newField.title = this.title;
|
||||||
newField.value = (String)properties.get(id);
|
newField.value = (String)properties.get(key);
|
||||||
newField.description = this.description;
|
newField.description = this.description;
|
||||||
newField.extendedDescription = this.extendedDescription;
|
newField.extendedDescription = this.extendedDescription;
|
||||||
newField.viewStyle = this.viewStyle;
|
newField.viewStyle = this.viewStyle;
|
||||||
|
@ -193,8 +193,8 @@ public class Field implements Comparable,PropertiesModelBuilder, ModelDefinition
|
||||||
return this.ordinal.compareTo(((Field)o).getOrdinal());
|
return this.ordinal.compareTo(((Field)o).getOrdinal());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
public void fromJsonObject(Map<String, Object> properties, String path) {
|
||||||
this.value = (String)properties.get("multiple_"+this.id+"_"+index);
|
this.value = (String)properties.get(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -110,19 +110,20 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ModelDefinit
|
||||||
|
|
||||||
List<String> compositeKeys = properties.keySet().stream().filter(keys->keys.startsWith("multiple_"+this.getId())).collect(Collectors.toList());
|
List<String> compositeKeys = properties.keySet().stream().filter(keys->keys.startsWith("multiple_"+this.getId())).collect(Collectors.toList());
|
||||||
for (String key : compositeKeys) {
|
for (String key : compositeKeys) {
|
||||||
this.multiplicityItems.add(this.cloneForMultiplicity(key, properties));
|
this.multiplicityItems.add(this.cloneForMultiplicity(key,compositeKeys.indexOf(key), properties));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FieldSet cloneForMultiplicity(String id, Map<String, Object> properties){
|
private FieldSet cloneForMultiplicity(String key, int index,Map<String, Object> properties){
|
||||||
FieldSet newFieldSet = new FieldSet();
|
FieldSet newFieldSet = new FieldSet();
|
||||||
newFieldSet.id = id;
|
newFieldSet.id = key;
|
||||||
|
|
||||||
newFieldSet.ordinal = this.ordinal;
|
newFieldSet.ordinal = this.ordinal;
|
||||||
newFieldSet.fields = new LinkedList();
|
newFieldSet.fields = new LinkedList();
|
||||||
this.fields.forEach(item->{
|
this.fields.forEach(item->{
|
||||||
newFieldSet.fields.add(item.cloneForMultiplicity("multiple_"+item.getId()+"_"+this.fields.indexOf(item), properties));
|
newFieldSet.fields.add(item.cloneForMultiplicity(key, properties));
|
||||||
});
|
});
|
||||||
|
//newFieldSet.fields.forEach(item->item.fromJsonObject(properties));
|
||||||
return newFieldSet;
|
return newFieldSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ModelDefinit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
public void fromJsonObject(Map<String, Object> properties, String path) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class Group implements PropertiesModelBuilder, ModelDefinition<entities.x
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
public void fromJsonObject(Map<String, Object> properties, String index) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class Section implements Comparable,ViewStyleDefinition<entities.xmlmodel
|
||||||
return this.ordinal.compareTo(((Section)o).getOrdinal());
|
return this.ordinal.compareTo(((Section)o).getOrdinal());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
public void fromJsonObject(Map<String, Object> properties, String index) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import models.user.components.commons.Rule;
|
||||||
public class DatasetProfile implements PropertiesModelBuilder{
|
public class DatasetProfile implements PropertiesModelBuilder{
|
||||||
private List<Section> sections;
|
private List<Section> sections;
|
||||||
private List<Rule> rules;
|
private List<Rule> rules;
|
||||||
|
private int status;
|
||||||
public List<Section> getSections() {
|
public List<Section> getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,14 @@ public class DatasetProfile implements PropertiesModelBuilder{
|
||||||
|
|
||||||
public void setRules(List<Rule> rules) {
|
public void setRules(List<Rule> rules) {
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){
|
public void buildProfile(entities.xmlmodels.modeldefinition.FieldGroup fieldGroup,entities.xmlmodels.viewstyledefinition.ViewStyleModel viewStyle){
|
||||||
|
@ -47,7 +56,7 @@ public class DatasetProfile implements PropertiesModelBuilder{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJsonObject(Map<String, Object> properties, int index) {
|
public void fromJsonObject(Map<String, Object> properties, String index) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface PropertiesModelBuilder {
|
public interface PropertiesModelBuilder {
|
||||||
void fromJsonObject(Map<String,Object> properties);
|
void fromJsonObject(Map<String,Object> properties);
|
||||||
void fromJsonObject(Map<String,Object> properties,int index);
|
void fromJsonObject(Map<String,Object> properties,String pathKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class DatasetProfileController {
|
||||||
try {
|
try {
|
||||||
entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
|
entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
|
||||||
models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
||||||
|
datasetprofile.setStatus(dataset.getStatus());
|
||||||
if(dataset.getProperties()!=null){
|
if(dataset.getProperties()!=null){
|
||||||
JSONObject jobject = new JSONObject(dataset.getProperties());
|
JSONObject jobject = new JSONObject(dataset.getProperties());
|
||||||
Map<String,Object> properties = (Map<String, Object>)jobject.toMap();
|
Map<String,Object> properties = (Map<String, Object>)jobject.toMap();
|
||||||
|
@ -61,6 +62,7 @@ public class DatasetProfileController {
|
||||||
properties.toMap(values);
|
properties.toMap(values);
|
||||||
JSONObject jobject = new JSONObject(values);
|
JSONObject jobject = new JSONObject(values);
|
||||||
dataset.setProperties(jobject.toString());
|
dataset.setProperties(jobject.toString());
|
||||||
|
dataset.setStatus((short)properties.getStatus());
|
||||||
datasetDao.update(dataset);
|
datasetDao.update(dataset);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(properties);
|
return ResponseEntity.status(HttpStatus.OK).body(properties);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="field-component" [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form"
|
<div class="field-component" [id]="field.id" *ngIf="visibilityRulesService.isElementVisible(pathName,field.id)" [formGroup]="form"
|
||||||
[ngSwitch]="field.viewStyle.renderStyle">
|
[ngSwitch]="field.viewStyle.renderStyle">
|
||||||
|
|
||||||
<h5 *ngIf="field.title">{{path + ' ' + field.title}}</h5>
|
<h5 *ngIf="field.title">{{field.title}}</h5>
|
||||||
|
|
||||||
|
|
||||||
<div [class.content-left-margin]="field.title">
|
<div [class.content-left-margin]="field.title">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
<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]" [form]="form.get('fields').get(''+0)"
|
||||||
[path]="path" [pathName]="pathName+'.fields.'+0"></df-field>
|
[pathName]="pathName+'.fields.'+0"></df-field>
|
||||||
|
|
||||||
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
|
<div *ngIf="compositeField.fields.length > 1" class="fieldset-component">
|
||||||
<h4 *ngIf="compositeField.title">{{compositeField.title}}</h4>
|
<h4 *ngIf="compositeField.title">{{compositeField.title}}</h4>
|
||||||
|
@ -17,9 +17,9 @@
|
||||||
Add one more field +
|
Add one more field +
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<df-field [field]="field" [form]="form.get('fields').get(''+i)" [path]="path" [pathName]="pathName+'.fields.'+i"></df-field>
|
<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;">
|
<div *ngFor="let multipleField of field.multiplicityItems; let j = index;">
|
||||||
<df-field [field]="multipleField" [form]="form.get('fields').get(''+i).get('multiplicityItems').get(''+j)" [path]="path"
|
<df-field [field]="multipleField" [form]="form.get('fields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||||
[pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
|
[pathName]="pathName+'.fields.'+i+'.multiplicityItems.'+j"></df-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class DynamicFormCompositeFieldComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
addMultipleField(fieldIndex: number) {
|
addMultipleField(fieldIndex: number) {
|
||||||
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex);
|
let field: Field = this.compositeField.fields[fieldIndex].cloneForMultiplicity(fieldIndex,"");
|
||||||
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
this.compositeField.fields[fieldIndex].multiplicityItems.push(field);
|
||||||
(<FormArray>(this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
|
(<FormArray>(this.form.get("fields").get('' + fieldIndex).get('multiplicityItems'))).push(field.buildForm());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<df-composite-field [compositeField]="compositeField" [form]="form.get('compositeFields').get(''+i)" [path]="path" [pathName]="pathName+'.compositeFields.'+i"></df-composite-field>
|
<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;">
|
<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]="multipleCompositeField" [form]="form.get('compositeFields').get(''+i).get('multiplicityItems').get(''+j)"
|
||||||
[path]="path" [pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
[pathName]="pathName+'.compositeFields.'+i+'.multiplicityItems.'+j"></df-composite-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<h4 *ngIf="section.extendedDescription">{{section.extendedDescription}}</h4>
|
<h4 *ngIf="section.extendedDescription">{{section.extendedDescription}}</h4>
|
||||||
<div *ngIf="section.fieldGroups">
|
<div *ngIf="section.fieldGroups">
|
||||||
<div *ngFor="let group of section.fieldGroups; let j = index;">
|
<div *ngFor="let group of section.fieldGroups; let j = index;">
|
||||||
<df-group [group]="group" [form]="form.get('fieldGroups').get(''+j)" [path]="path+'.'+(j+1)" [pathName]="pathName+'.fieldGroups.'+j"></df-group>
|
<df-group [group]="group" [form]="form.get('fieldGroups').get(''+j)" [pathName]="pathName+'.fieldGroups.'+j"></df-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="section.sections">
|
<div *ngIf="section.sections">
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
<div class="ui-g" ng-sidebar-content>
|
<div class="ui-g" ng-sidebar-content>
|
||||||
<button type="button" style="margin: 15px;" class="btn btn-primary" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button>
|
<button type="button" style="margin: 15px;" class="btn btn-primary" (click)="toggleSidebar()" icon="fa-arrow-left">Table Of Contents</button>
|
||||||
<button type="button" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;" class="btn btn-primary" (click)="submit();">Save and Finalize</button>
|
<button type="button" *ngIf="dataModel&&dataModel.status != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||||
|
class="btn btn-primary" type="button" (click)="save();">Save</button>
|
||||||
|
<button type="button" *ngIf="dataModel&&dataModel?.status != 1" style="margin-top: 15px;margin-bottom: 15px;margin-right: 15px;"
|
||||||
|
class="btn btn-primary" (click)="submit();">Save and Finalize</button>
|
||||||
<div class="ui-g-12">
|
<div class="ui-g-12">
|
||||||
<p-steps [model]="stepperItems" [activeIndex]="this.currentPageIndex" (activeIndexChange)="changePageIndex($event)" [readonly]="false"></p-steps>
|
<p-steps [model]="stepperItems" [activeIndex]="this.currentPageIndex" (activeIndexChange)="changePageIndex($event)" [readonly]="false"></p-steps>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +19,6 @@
|
||||||
<div class="col-md-12 form-body-container" id="form-container">
|
<div class="col-md-12 form-body-container" id="form-container">
|
||||||
|
|
||||||
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
|
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
|
||||||
|
|
||||||
<div *ngFor="let section of dataModel.sections; let i = index;">
|
<div *ngFor="let section of dataModel.sections; let i = index;">
|
||||||
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
|
<df-section *ngIf='this.shouldDisplaySection(section)' [section]="section" [form]="form.get('sections').get(''+i)" [path]="i+1"
|
||||||
[pathName]="'sections.'+i"></df-section>
|
[pathName]="'sections.'+i"></df-section>
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { NgForm } from '@angular/forms';
|
||||||
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
|
import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
|
||||||
import 'rxjs/add/operator/switchMap';
|
import 'rxjs/add/operator/switchMap';
|
||||||
|
|
||||||
//import { FieldBase } from '../../app/form/fields/field-base';
|
import { Ng4LoadingSpinnerService } from 'ng4-loading-spinner';
|
||||||
import { FieldControlService } from '../../app/services/field-control.service';
|
import { FieldControlService } from '../../app/services/field-control.service';
|
||||||
import { ServerService } from '../../app/services/server.service';
|
import { ServerService } from '../../app/services/server.service';
|
||||||
import { TokenService, TokenProvider } from '../services/login/token.service';
|
import { TokenService, TokenProvider } from '../services/login/token.service';
|
||||||
|
@ -72,7 +72,9 @@ export class DynamicFormComponent implements OnInit {
|
||||||
private fragment: string;
|
private fragment: string;
|
||||||
constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService,
|
constructor(private serverService: ServerService, private router: Router, private pdfService: PDFService,
|
||||||
private _location: Location, private route: ActivatedRoute, private tokenService: TokenService
|
private _location: Location, private route: ActivatedRoute, private tokenService: TokenService
|
||||||
, private visibilityRulesService: VisibilityRulesService
|
, private visibilityRulesService: VisibilityRulesService,
|
||||||
|
private spinnerService: Ng4LoadingSpinnerService
|
||||||
|
|
||||||
) {
|
) {
|
||||||
this.datasetId = route.snapshot.params['id'];
|
this.datasetId = route.snapshot.params['id'];
|
||||||
}
|
}
|
||||||
|
@ -120,11 +122,25 @@ export class DynamicFormComponent implements OnInit {
|
||||||
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
let rules:Rule[] = new JsonSerializer<Rule>().fromJSONArray(TestModel.rules,Rule);
|
||||||
this.visibilityRulesService.buildVisibilityRules(rules) */
|
this.visibilityRulesService.buildVisibilityRules(rules) */
|
||||||
}
|
}
|
||||||
|
save() {
|
||||||
submit() {
|
let data = this.form.value;
|
||||||
this.serverService.updateDataset(this.datasetId, this.form.value).subscribe()
|
data.status = 0;
|
||||||
|
this.spinnerService.show();
|
||||||
|
this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{
|
||||||
|
this.spinnerService.hide()
|
||||||
|
this.router.navigate(["dmps"]);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
let data = this.form.value;
|
||||||
|
data.status = 1;
|
||||||
|
this.spinnerService.show();
|
||||||
|
this.serverService.updateDataset(this.datasetId, data).subscribe(item=>{
|
||||||
|
this.spinnerService.hide()
|
||||||
|
this.router.navigate(["dmps"]);
|
||||||
|
})
|
||||||
|
}
|
||||||
toggleSidebar() {
|
toggleSidebar() {
|
||||||
this.visibleSidebar = !this.visibleSidebar;
|
this.visibleSidebar = !this.visibleSidebar;
|
||||||
}
|
}
|
||||||
|
@ -173,78 +189,6 @@ export class DynamicFormComponent implements OnInit {
|
||||||
if (pageIndex === -1) return;
|
if (pageIndex === -1) return;
|
||||||
this.currentPageIndex = pageIndex;
|
this.currentPageIndex = pageIndex;
|
||||||
}
|
}
|
||||||
/* scrollToElemID(elemID) {
|
|
||||||
scroll("#" + elemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private patchForm(flatList: any) {
|
|
||||||
|
|
||||||
|
|
||||||
for (var prop in flatList) {
|
|
||||||
if (flatList.hasOwnProperty(prop)) {
|
|
||||||
if (prop.endsWith('.id') || prop.endsWith('.answer') || prop.endsWith('.value')) continue;
|
|
||||||
//console.log("updating value of "+prop +" to "+flatList[prop].valueOf())
|
|
||||||
this.form.get(prop).setValue(flatList[prop].valueOf());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewChecked(): void { //navigate to certain section of the page
|
|
||||||
try {
|
|
||||||
document.querySelector('#' + this.fragment).scrollIntoView();
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SaveForm() {
|
|
||||||
let final = false;
|
|
||||||
this.submitForm(false);
|
|
||||||
|
|
||||||
this.payLoad = JSON.stringify(this.form.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
SaveFinalizeForm(){
|
|
||||||
$("#confirmModal").modal("hide");
|
|
||||||
let final = true;
|
|
||||||
this.submitForm(final);
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldIShow(element) { //pagination , pages are declared in xml for every groupfield
|
|
||||||
|
|
||||||
if (this.pagination.currentPage == element.page){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
setPage(page: number) {
|
|
||||||
|
|
||||||
if (page < 1 || page > this.pagination.totalPages) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var pagesize = 4;
|
|
||||||
// get pagination object from service
|
|
||||||
this.pagination = this.pagerService.getPagination(this.dataModel.groups, this.dataModel.groups.length, page, pagesize);
|
|
||||||
|
|
||||||
//get current page of items
|
|
||||||
// this.dataModel.sections.forEach(section => {
|
|
||||||
// if (section.groupFields.length > 0) {
|
|
||||||
// section.groupFields = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//this.dataModel.groups = this.dataModel.groups.slice(this.pagination.startIndex, this.pagination.endIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
toggleTOC(){
|
|
||||||
this.expandedToc = !this.expandedToc;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
createPDF(elementID: string, pdffilename: string) {
|
createPDF(elementID: string, pdffilename: string) {
|
||||||
this.pdfService.toPDF(elementID, pdffilename);
|
this.pdfService.toPDF(elementID, pdffilename);
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
<a (click)="scrollToId(model.id,page)">{{path+' '+model.title}}</a>
|
|
||||||
|
|
|
@ -1,10 +1 @@
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
|
|
||||||
<ul>
|
|
||||||
<div *ngFor="let field of model.fields let i = index">
|
|
||||||
<li *ngIf="visibilityRulesService.isElementVisible(null,field.id)">
|
|
||||||
<table-of-contents-field [page]='page' [model]="field" [index]="i" [path]="path">
|
|
||||||
</table-of-contents-field>
|
|
||||||
</li>
|
|
||||||
</div>
|
|
||||||
</ul>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<a (click)="scrollToId(model.id,page)">{{path+' '+model.title}}</a>
|
|
||||||
|
|
||||||
<div *ngFor="let fieldsetModel of model.compositeFields let i = index">
|
|
||||||
<table-of-contents-fieldset [page]='page' [model]="fieldsetModel" [index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-fieldset>
|
|
||||||
</div>
|
|
|
@ -1,14 +1,6 @@
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
<a (click)="scrollToId(model.id,page)">{{path + ' ' + model.title}}</a>
|
<a (click)="scrollToId(model.id,page)">{{path + ' ' + model.title}}</a>
|
||||||
|
|
||||||
<div *ngIf="model.fieldGroups.length > 0">
|
|
||||||
<div *ngFor="let fieldsetModel of model.fieldGroups[0].compositeFields let i = index">
|
|
||||||
<table-of-contents-field *ngIf="model.fieldGroups[0].compositeFields[i].fields.length == 1" [page]='page' [model]="model.fieldGroups[0].compositeFields[i].fields[0]"
|
|
||||||
[index]="i" [path]="path+'.'+(i+1)"></table-of-contents-field>
|
|
||||||
<table-of-contents-fieldset *ngIf="model.fieldGroups[0].compositeFields[i].fields.length > 1" [page]='page' [model]="fieldsetModel"
|
|
||||||
[index]="i" [path]="path+'.'+(i+1)"> </table-of-contents-fieldset>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- All contents in the first page -->
|
<!-- All contents in the first page -->
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -25,6 +25,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
||||||
|
|
||||||
buildForm(): FormGroup {
|
buildForm(): FormGroup {
|
||||||
let formGroup = this.formBuilder.group({
|
let formGroup = this.formBuilder.group({
|
||||||
|
id: this.id,
|
||||||
ordinal: this.ordinal
|
ordinal: this.ordinal
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
||||||
let newItem: CompositeField = new CompositeField();
|
let newItem: CompositeField = new CompositeField();
|
||||||
newItem.id = 'multiple_' + this.id + '_' + index;
|
newItem.id = 'multiple_' + this.id + '_' + index;
|
||||||
this.fields.forEach(field => {
|
this.fields.forEach(field => {
|
||||||
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field)));
|
newItem.fields.push(field.cloneForMultiplicity(this.fields.indexOf(field), newItem.id + "_"));
|
||||||
});
|
});
|
||||||
newItem.ordinal = this.ordinal;
|
newItem.ordinal = this.ordinal;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||||
import { Section } from './Section';
|
import { Section } from './Section';
|
||||||
import { Serializable } from './interfaces/Serializable';
|
import { Serializable } from './interfaces/Serializable';
|
||||||
export class DatasetModel extends BaseModel implements Serializable<DatasetModel>,FormGenerator<FormGroup>{
|
export class DatasetModel extends BaseModel implements Serializable<DatasetModel>,FormGenerator<FormGroup>{
|
||||||
|
public status:number
|
||||||
public sections:Array<Section>
|
public sections:Array<Section>
|
||||||
fromJSONObject(item:any):DatasetModel{
|
fromJSONObject(item:any):DatasetModel{
|
||||||
|
this.status = item.status;
|
||||||
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections,Section);
|
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections,Section);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
||||||
public multiplicity: Multiplicity;
|
public multiplicity: Multiplicity;
|
||||||
public multiplicityItems: Array<Field> = new Array<Field>();
|
public multiplicityItems: Array<Field> = new Array<Field>();
|
||||||
public data: any;
|
public data: any;
|
||||||
|
|
||||||
fromJSONObject(item: any): Field {
|
fromJSONObject(item: any): Field {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.title = item.title;
|
this.title = item.title;
|
||||||
|
@ -30,8 +30,8 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
||||||
this.defaultVisibility = item.defaultVisibility;
|
this.defaultVisibility = item.defaultVisibility;
|
||||||
this.page = item.page;
|
this.page = item.page;
|
||||||
//this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
|
//this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
|
||||||
this.defaultValue = new JsonSerializer<DefaultValue>().fromJSONObject(item.defaultValue, DefaultValue);
|
this.defaultValue = new JsonSerializer<DefaultValue>().fromJSONObject(item.defaultValue, DefaultValue);
|
||||||
this.value = this.defaultValue.value && !item.value? this.defaultValue.value: item.value;
|
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||||
this.multiplicity = new Multiplicity();
|
this.multiplicity = new Multiplicity();
|
||||||
this.multiplicity.max = 2;
|
this.multiplicity.max = 2;
|
||||||
this.multiplicityItems = new JsonSerializer<Field>().fromJSONArray(item.multiplicityItems, Field);
|
this.multiplicityItems = new JsonSerializer<Field>().fromJSONArray(item.multiplicityItems, Field);
|
||||||
|
@ -62,10 +62,10 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneForMultiplicity(index: number): Field {
|
cloneForMultiplicity(index: number, idPath: string): Field {
|
||||||
let newItem: Field = new Field();
|
let newItem: Field = new Field();
|
||||||
|
|
||||||
newItem.id = 'multiple_' + this.id + '_' + index;
|
newItem.id = idPath ? idPath + index : 'multiple_' + this.id + '_' + index;
|
||||||
newItem.title = this.title;
|
newItem.title = this.title;
|
||||||
newItem.description = this.description;
|
newItem.description = this.description;
|
||||||
newItem.extendedDescription = this.extendedDescription;
|
newItem.extendedDescription = this.extendedDescription;
|
||||||
|
|
Loading…
Reference in New Issue