# HG changeset patch # User Nicholas Jillings # Date 1473328497 -3600 # Node ID 26045169b4b56d31dc448ebd1a167fc761207cf9 # Parent b2df2be58fc23800cffcb2f3a11015dd8c4a3cef Completing adding of nodes to test_creator #5 diff -r b2df2be58fc2 -r 26045169b4b5 test_create/attributes.json --- a/test_create/attributes.json Fri Sep 02 14:56:01 2016 +0100 +++ b/test_create/attributes.json Thu Sep 08 10:54:57 2016 +0100 @@ -27,5 +27,9 @@ "postSilence": "Post Silence", "poolSize": "Pool Size", "alwaysInclude": "Always Include", - "crossFade": "Cross Fade" + "crossFade": "Cross Fade", + "check": "Check", + "value": "Value", + "jumpToOnPass": "Jump To ID On Pass", + "jumpToOnFail": "Jump To ID On Fail" } diff -r b2df2be58fc2 -r 26045169b4b5 test_create/test_core.js --- a/test_create/test_core.js Fri Sep 02 14:56:01 2016 +0100 +++ b/test_create/test_core.js Thu Sep 08 10:54:57 2016 +0100 @@ -1965,6 +1965,88 @@ } this.build(); + var Conditional = function(parent, rootObject) { + this.type = "surveyEntryConditionalNode"; + this.rootDOM = document.createElement("div"); + this.titleDOM = document.createElement("span"); + this.attributeDOM = document.createElement("div"); + this.attributes = []; + this.childrenDOM = document.createElement("div"); + this.children = []; + this.buttonDOM = document.createElement("div"); + this.parent = parent; + this.specification = rootObject; + this.schema = specification.schema.getAllElementsByName("conditional")[0]; + + this.rootDOM.className = "node"; + this.rootDOM.style.minWidth = "50%"; + + var titleDiv = document.createElement('div'); + titleDiv.className = "node-title"; + this.titleDOM.className = "node-title"; + titleDiv.appendChild(this.titleDOM); + + this.attributeDOM.className = "node-attributes"; + this.childrenDOM.className = "node-children"; + this.buttonDOM.className = "node-buttons"; + + this.rootDOM.appendChild(titleDiv); + this.rootDOM.appendChild(this.attributeDOM); + this.rootDOM.appendChild(this.childrenDOM); + this.rootDOM.appendChild(this.buttonDOM); + + var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); + + for (var i=0; i= 0) { + this.parent.parent.children.splice(index,1); + } + } + } + this.deleteNode.root.textContent = "Delete"; + this.deleteNode.root.addEventListener("click",this.deleteNode); + + this.buttonDOM.appendChild(this.deleteNode.root); + } + + this.addConditional = { + root: document.createElement("button"), + parent: this, + handleEvent: function(event) { + var spec = { + check: null, + value: null, + jumpToOnPass: null, + jumpToOnFail: null + }; + this.parent.specification.conditions.push(spec); + var condition = new Conditional(this.parent,spec); + this.parent.children.push(condition); + this.parent.childrenDOM.appendChild(condition.rootDOM); + } + } + this.addConditional.root.addEventListener("click",this.addConditional); + this.addConditional.root.textContent = "Add Condition"; + this.buttonDOM.appendChild(this.addConditional.root); + this.editNode = { root: document.createElement("button"), parent: this, @@ -2073,6 +2155,12 @@ this.moveButtons.root_down.textContent = "Move Down"; this.buttonDOM.appendChild(this.moveButtons.root_up); this.buttonDOM.appendChild(this.moveButtons.root_down); + + for (var condition of this.specification.conditions) { + var newNode = new Conditional(this,condition); + this.children.push(newNode); + this.childrenDOM.appendChild(newNode.rootDOM); + } } this.addNode = { root: document.createElement("button"),