comparison test_create/test_core.js @ 2853:f75db4482006

More test-creator work. Finished global surveys
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Wed, 26 Apr 2017 16:38:34 +0100
parents d1cde8698cc6
children 6625f4ad24f4
comparison
equal deleted inserted replaced
2852:8372c220db7a 2853:f75db4482006
109 $s.schema = $s.globalSchema.querySelector("[name=setup]"); 109 $s.schema = $s.globalSchema.querySelector("[name=setup]");
110 } 110 }
111 } 111 }
112 $s.schema = undefined; 112 $s.schema = undefined;
113 $s.attributes = []; 113 $s.attributes = [];
114 $s.model = specification;
115 114
116 $s.$watch("globalSchema", initialise); 115 $s.$watch("globalSchema", initialise);
116 $s.$watch("specification.metrics.enabled.length", function () {
117 var metricsNode = document.getElementById("metricsNode");
118 if (!$s.specification.metrics) {
119 return;
120 }
121 metricsNode.querySelectorAll("input").forEach(function (DOM) {
122 DOM.checked = false;
123 });
124 $s.specification.metrics.enabled.forEach(function (metric) {
125 var DOM = metricsNode.querySelector("[value=" + metric + "]");
126 if (DOM) {
127 DOM.checked = true;
128 }
129 });
130 })
131
132 $s.enableMetric = function ($event) {
133 var metric = $event.currentTarget.value;
134 var index = specification.metrics.enabled.findIndex(function (a) {
135 return a == metric;
136 });
137 if ($event.currentTarget.checked) {
138 if (index == -1) {
139 specification.metrics.enabled.push(metric);
140 }
141 } else {
142 if (index >= 0) {
143 specification.metrics.enabled.splice(index, 1);
144 }
145 }
146 }
117 }]); 147 }]);
148
149 AngularInterface.controller("surveyOption", ['$scope', '$element', '$window', function ($s, $e, $w) {
150
151 $s.removeOption = function (option) {
152 var index = $s.opt.options.findIndex(function (a) {
153 return a == option;
154 });
155 if (index === -1) {
156 throw ("Invalid option");
157 }
158 $s.opt.options.splice(index, 1);
159 };
160 $s.addOption = function () {
161 $s.opt.options.push({
162 name: "",
163 text: ""
164 });
165 }
166 }]);