new statuses, dmp change status after checking the datasets status, datatype in dataModelBuilder

This commit is contained in:
annampak 2017-11-10 17:29:57 +02:00
parent fd6dc2c936
commit 37573cb729
8 changed files with 86 additions and 22 deletions

View File

@ -86,7 +86,7 @@ export class DatasetsComponent implements OnInit {
this.datasetProfileDropDown.options = []; this.datasetProfileDropDown.options = [];
this.saveAndDescribe = false; this.saveAndDescribe = false;
this.statusDropDown = new DropdownField(); this.statusDropDown = new DropdownField();
this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}] this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}, {key:'2', value:"Submitted"}, {key:'3', value:"Cancel"}]
} }

View File

@ -75,7 +75,7 @@ export class DmpComponent implements OnInit{
this.projectsDropDown = new DropdownField(); this.projectsDropDown = new DropdownField();
this.projectsDropDown.options = []; this.projectsDropDown.options = [];
this.statusDropDown = new DropdownField(); this.statusDropDown = new DropdownField();
this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}] this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}, {key:'2', value:"Submitted"}, {key:'3', value:"Cancel"}]
//this.projects = []; //this.projects = [];
this.dmpTableVisible = false; this.dmpTableVisible = false;
this.dataSetVisibe = false; this.dataSetVisibe = false;
@ -269,12 +269,36 @@ deleteRow(dmp){
} }
clickFilters(element){ clickFilters(element){
console.log(element); if(element.textContent == "More filters")
if(element.textContent == "More filters") element.textContent = "Less Filters";
element.textContent = "Less Filters"; else
else element.textContent = "More Filters";
element.textContent = "More Filters"; }
SelectDMPStatus(dmp, event, oldValue){
console.log(dmp);
let cannotChangeStatus:boolean;
if(dmp.status == 2){
this.serverService.getDatasetForDmp({ "id": dmp.id }).subscribe(
response => {
response.forEach(dataset => {
if(dataset.status !==2 || dataset.status !==3){
cannotChangeStatus=true;
}
return;
});
if(cannotChangeStatus == true){
dmp.status = 0;
$("#messageForChangingStatus").modal("show");
}
},
error => {
console.log("could not retrieve dataset for dpm: "+dmp.id);
}
);
}
} }

View File

@ -115,7 +115,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="status-name" class="col-form-label">Status:</label> <label for="status-name" class="col-form-label">Status:</label>
<select class="form-control" id="statusid" [(ngModel)]="dmp.status" name="statusDropDown"> <select class="form-control" id="statusid" [(ngModel)]="dmp.status" name="statusDropDown" (change)="SelectDMPStatus(dmp, $event, oldValue);">
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option> <option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select> </select>
</div> </div>
@ -197,6 +197,25 @@
</div> </div>
</div> </div>
<div class="modal" tabindex="-1" id="messageForChangingStatus" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Change Staus</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>The submitted status is available only when all the DMP's datasets are "Submitted" or "Cancel"</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<!--Modal for DMPs--> <!--Modal for DMPs-->
<!-- <modal *ngIf="item && show" [(show)]="show" [item]="item" [(dataSetVisibe)]="dataSetVisibe"></modal> --> <!-- <modal *ngIf="item && show" [(show)]="show" [item]="item" [(dataSetVisibe)]="dataSetVisibe"></modal> -->

View File

@ -31,8 +31,8 @@
</div> --> </div> -->
<div> <div>
<button type="submit" class="btn btn-default btncustom" [disabled]="!form.valid">Save</button> <button type="submit" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus">Save</button>
<button type="button" class="btn btn-default btncustom" [disabled]="!form.valid" data-toggle="modal" data-target="#confirmModal">Finalize</button> <button type="button" class="btn btn-default btncustom" [disabled]="!form.valid || finalizeStatus" data-toggle="modal" data-target="#confirmModal">Finalize</button>
</div> </div>
<div *ngIf="payLoad" class="form-row"> <div *ngIf="payLoad" class="form-row">

View File

@ -47,6 +47,7 @@ export class DynamicFormComponent implements OnInit {
@Input() dirtyValues: number = 0; @Input() dirtyValues: number = 0;
// pagination object // pagination object
@Input() pagination: any = {}; @Input() pagination: any = {};
finalizeStatus:boolean = false;
id: string; id: string;
datasetId: string; datasetId: string;
//datasetProperties:string; //datasetProperties:string;
@ -71,11 +72,7 @@ export class DynamicFormComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.route.fragment.subscribe(fragment => { this.fragment = fragment; }); //navigate to certain section of the page //this.route.fragment.subscribe(fragment => { this.fragment = fragment; }); //navigate to certain section of the page, it doesn't use anymore
//let id = this.route.snapshot.paramMap.get('id'); //get the project id
let sub = this.route.params.subscribe(params => { let sub = this.route.params.subscribe(params => {
this.id = params.id; this.id = params.id;
this.datasetId = params.datasetId; this.datasetId = params.datasetId;
@ -93,6 +90,7 @@ export class DynamicFormComponent implements OnInit {
formValues = JSON.parse(data.properties); formValues = JSON.parse(data.properties);
flatList = flatten(formValues); flatList = flatten(formValues);
//this.patchForm(flatList); //this.patchForm(flatList);
if(data.status == 2) this.finalizeStatus=true;
} }
//η κληση για το dataset profile pou htan prin pio panw anexarthth //η κληση για το dataset profile pou htan prin pio panw anexarthth
@ -213,10 +211,10 @@ export class DynamicFormComponent implements OnInit {
} catch (e) { } } catch (e) { }
} }
submitForm(){ submitForm(final){
this.serverService.getDatasetByID(this.datasetId).subscribe( this.serverService.getDatasetByID(this.datasetId).subscribe(
(data) => { (data) => {
if (final) data.status = 2;
//is xml, so transform them to xml (it's json) //is xml, so transform them to xml (it's json)
//data.properties = this.xml2jsonOBJ.json2xml_str(JSON.stringify(this.form.value)); //data.properties = this.xml2jsonOBJ.json2xml_str(JSON.stringify(this.form.value));
data.properties = JSON.stringify(this.form.value); data.properties = JSON.stringify(this.form.value);
@ -237,14 +235,16 @@ export class DynamicFormComponent implements OnInit {
} }
onSubmit() { onSubmit() {
this.submitForm(); let final = false;
this.submitForm(false);
this.payLoad = JSON.stringify(this.form.value); this.payLoad = JSON.stringify(this.form.value);
} }
SaveFinalize(){ SaveFinalize(){
$("#confirmModal").modal("hide"); $("#confirmModal").modal("hide");
this.submitForm(); let final = true;
this.submitForm(final);
} }
shouldIShow(element) { //pagination , pages are declared in xml for every groupfield shouldIShow(element) { //pagination , pages are declared in xml for every groupfield

View File

@ -15,6 +15,7 @@ export class FieldBase<T>{
attributes: Attribute; attributes: Attribute;
regex:string; regex:string;
url: string; url: string;
datatype: string;
constructor(options: { constructor(options: {
value?: T, value?: T,
@ -29,7 +30,8 @@ export class FieldBase<T>{
description?: string, description?: string,
attributes?: Attribute, attributes?: Attribute,
regex?:string, regex?:string,
url?: string url?: string,
datatype?:string
} = {}) { } = {}) {
this.value = options.value; this.value = options.value;
this.key = options.key || ''; this.key = options.key || '';
@ -44,5 +46,6 @@ export class FieldBase<T>{
this.attributes = options.attributes || new Attribute(); this.attributes = options.attributes || new Attribute();
this.regex = options.regex || ''; this.regex = options.regex || '';
this.url = options.url || ""; this.url = options.url || "";
this.datatype = options.datatype || "";
} }
} }

View File

@ -17,6 +17,12 @@ export class StatusToString implements PipeTransform {
else if(input == 1) { else if(input == 1) {
return "Inactive"; return "Inactive";
} }
else if(input == 2) {
return "Submitted";
}
else if(input == 3) {
return "Cancel";
}
else { else {
return input.toString(); return input.toString();
} }

View File

@ -33,6 +33,7 @@ export class dataModelBuilder {
this.dataModel.semanticAttr = new Array(new Attribute); this.dataModel.semanticAttr = new Array(new Attribute);
this.dataModel.semanticAttr = this.getFieldsAttributes(data.definition.root.fields.field, data.ruleset.definition.root.functions.function, this.fields); this.dataModel.semanticAttr = this.getFieldsAttributes(data.definition.root.fields.field, data.ruleset.definition.root.functions.function, this.fields);
this.dataModel.sections = this.getSections(data.viewstyle.definition.root.sections.section, this.dataModel.groups); this.dataModel.sections = this.getSections(data.viewstyle.definition.root.sections.section, this.dataModel.groups);
//this.getDatatypes(data.definition.root);
this.dataModel.buildIndex(); this.dataModel.buildIndex();
this.checkDuplicateInObject('order', this.dataModel.groups[13].groupFields); //for future use , for composite field this.checkDuplicateInObject('order', this.dataModel.groups[13].groupFields); //for future use , for composite field
@ -298,6 +299,17 @@ export class dataModelBuilder {
return sects; return sects;
} }
private getDatatypes(dataTypes){
if (dataTypes.datatypes.datatype.id == "compositeField"){
dataTypes.datatypes.datatype.fields.forEach(field => {
this.dataModel.fields.forEach(fieldinModel=>{
if (field.id == fieldinModel.key)
fieldinModel.datatype = "compositeField";
});
});
}
}
checkDuplicateInObject(propertyName, inputArray) { checkDuplicateInObject(propertyName, inputArray) {
let DuplicateArray = []; let DuplicateArray = [];
inputArray.forEach(item => { inputArray.forEach(item => {