summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Sufiev <tsufiev@mirantis.com>2015-08-04 13:02:16 -0700
committerTimur Sufiev <tsufiev@mirantis.com>2015-08-05 10:12:42 +0000
commitd6e2842979c6ebd4e4cfbea8509bb6f72f021f80 (patch)
tree2f34bec0bb882396999fd8145e89e3837ab6e9d3
parentc25b7d85076a574198ca91b1fbd13070c73618f9 (diff)
Remove 'type' attribute from <typed-field>
... because it's excessive and can be calculated from 'value' attribute. Change-Id: Id56024027ee455518619f1ee846d0b0735d5210d
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Timur Sufiev <tsufiev@mirantis.com> Workflow+1: Timur Sufiev <tsufiev@mirantis.com> Submitted-by: Jenkins Submitted-at: Wed, 05 Aug 2015 11:59:45 +0000 Reviewed-on: https://review.openstack.org/209253 Project: stackforge/merlin Branch: refs/heads/master
-rw-r--r--extensions/mistral/templates/mistral/create.html4
-rw-r--r--merlin/static/merlin/js/merlin.directives.js6
-rw-r--r--merlin/static/merlin/templates/fields/dictionary.html7
-rw-r--r--merlin/static/merlin/templates/fields/frozendict.html6
-rw-r--r--merlin/static/merlin/templates/fields/list.html4
-rw-r--r--merlin/test/js/merlin.directives.spec.js14
6 files changed, 20 insertions, 21 deletions
diff --git a/extensions/mistral/templates/mistral/create.html b/extensions/mistral/templates/mistral/create.html
index 69a671e..bd16db3 100644
--- a/extensions/mistral/templates/mistral/create.html
+++ b/extensions/mistral/templates/mistral/create.html
@@ -51,14 +51,14 @@
51 <div ng-repeat="(label, field) in row track by field.uid()"> 51 <div ng-repeat="(label, field) in row track by field.uid()">
52 <div ng-if="field.isAtomic()" class="col-xs-6"> 52 <div ng-if="field.isAtomic()" class="col-xs-6">
53 <labeled label="label" for="{$ field.uid() $}"> 53 <labeled label="label" for="{$ field.uid() $}">
54 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 54 <typed-field value="field"></typed-field>
55 </labeled> 55 </labeled>
56 </div> 56 </div>
57 <div ng-if="!field.isAtomic()" class="col-xs-12"> 57 <div ng-if="!field.isAtomic()" class="col-xs-12">
58 <collapsible-group content="field" title="label" 58 <collapsible-group content="field" title="label"
59 additive="{$ field.isAdditive() $}" on-add="field.add()"> 59 additive="{$ field.isAdditive() $}" on-add="field.add()">
60 <div ng-class="field.isPlainStructure() ? 'col-xs-6' : 'col-xs-12'"> 60 <div ng-class="field.isPlainStructure() ? 'col-xs-6' : 'col-xs-12'">
61 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 61 <typed-field value="field"></typed-field>
62 </div> 62 </div>
63 </collapsible-group> 63 </collapsible-group>
64 </div> 64 </div>
diff --git a/merlin/static/merlin/js/merlin.directives.js b/merlin/static/merlin/js/merlin.directives.js
index 57030b8..2b959c1 100644
--- a/merlin/static/merlin/js/merlin.directives.js
+++ b/merlin/static/merlin/js/merlin.directives.js
@@ -221,11 +221,11 @@
221 return { 221 return {
222 restrict: 'E', 222 restrict: 'E',
223 scope: { 223 scope: {
224 value: '=', 224 value: '='
225 type: '@'
226 }, 225 },
227 link: function(scope, element) { 226 link: function(scope, element) {
228 templates.templateReady(scope.type).then(function(template) { 227 var type = scope.value.getType();
228 templates.templateReady(type).then(function(template) {
229 element.append($compile(template)(scope)); 229 element.append($compile(template)(scope));
230 }); 230 });
231 } 231 }
diff --git a/merlin/static/merlin/templates/fields/dictionary.html b/merlin/static/merlin/templates/fields/dictionary.html
index 858d4dc..ed2fdd3 100644
--- a/merlin/static/merlin/templates/fields/dictionary.html
+++ b/merlin/static/merlin/templates/fields/dictionary.html
@@ -3,7 +3,7 @@
3 <div ng-repeat="(key, field) in value | extractFields track by field.uid()"> 3 <div ng-repeat="(key, field) in value | extractFields track by field.uid()">
4 <labeled ng-if="field.isAtomic()" label="field.keyValue" for="{$ field.uid() $}"> 4 <labeled ng-if="field.isAtomic()" label="field.keyValue" for="{$ field.uid() $}">
5 <div class="input-group"> 5 <div class="input-group">
6 <typed-field id="{$ field.uid() $}" value="field" type="{$ field.getType() $}"></typed-field> 6 <typed-field id="{$ field.uid() $}" value="field"></typed-field>
7 <span class="input-group-btn"> 7 <span class="input-group-btn">
8 <button class="btn btn-default" ng-click="value.removeItem(field.keyValue())"> 8 <button class="btn btn-default" ng-click="value.removeItem(field.keyValue())">
9 <i class="fa fa-minus-circle"></i> 9 <i class="fa fa-minus-circle"></i>
@@ -15,10 +15,9 @@
15 <collapsible-group ng-if="!field.inline" class="col-xs-12" title="field.keyValue" 15 <collapsible-group ng-if="!field.inline" class="col-xs-12" title="field.keyValue"
16 on-remove="value.removeItem(field.keyValue())" 16 on-remove="value.removeItem(field.keyValue())"
17 additive="{$ field.isAdditive() $}" on-add="field.add()"> 17 additive="{$ field.isAdditive() $}" on-add="field.add()">
18 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 18 <typed-field value="field"></typed-field>
19 </collapsible-group> 19 </collapsible-group>
20 <typed-field ng-if="field.inline" 20 <typed-field ng-if="field.inline" value="field"></typed-field>
21 value="field" type="{$ field.getType() $}"></typed-field>
22 </div> 21 </div>
23 </div> 22 </div>
24 </div> 23 </div>
diff --git a/merlin/static/merlin/templates/fields/frozendict.html b/merlin/static/merlin/templates/fields/frozendict.html
index f4c5264..84d0e7c 100644
--- a/merlin/static/merlin/templates/fields/frozendict.html
+++ b/merlin/static/merlin/templates/fields/frozendict.html
@@ -3,19 +3,19 @@
3 <div ng-repeat="(key, field) in row track by field.uid()"> 3 <div ng-repeat="(key, field) in row track by field.uid()">
4 <div ng-if="field.isAtomic()" class="col-xs-6"> 4 <div ng-if="field.isAtomic()" class="col-xs-6">
5 <labeled label="key" for="{$ field.uid() $}"> 5 <labeled label="key" for="{$ field.uid() $}">
6 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 6 <typed-field value="field"></typed-field>
7 </labeled> 7 </labeled>
8 </div> 8 </div>
9 <div ng-if="!field.isAtomic()"> 9 <div ng-if="!field.isAtomic()">
10 <collapsible-group ng-if="!field.inline" class="col-xs-12" title="key" 10 <collapsible-group ng-if="!field.inline" class="col-xs-12" title="key"
11 additive="{$ field.isAdditive() $}" on-add="field.add()"> 11 additive="{$ field.isAdditive() $}" on-add="field.add()">
12 <div ng-class="field.isPlainStructure() ? 'col-xs-6' : 'col-xs-12'"> 12 <div ng-class="field.isPlainStructure() ? 'col-xs-6' : 'col-xs-12'">
13 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 13 <typed-field value="field"></typed-field>
14 </div> 14 </div>
15 </collapsible-group> 15 </collapsible-group>
16 <labeled ng-if="field.inline" class="col-xs-6" 16 <labeled ng-if="field.inline" class="col-xs-6"
17 label="key" for="{$ field.uid() $}"> 17 label="key" for="{$ field.uid() $}">
18 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 18 <typed-field value="field"></typed-field>
19 </labeled> 19 </labeled>
20 </div> 20 </div>
21 </div> 21 </div>
diff --git a/merlin/static/merlin/templates/fields/list.html b/merlin/static/merlin/templates/fields/list.html
index 379c264..e5d58cf 100644
--- a/merlin/static/merlin/templates/fields/list.html
+++ b/merlin/static/merlin/templates/fields/list.html
@@ -3,7 +3,7 @@
3 <div ng-repeat="(index, field) in value | extractFields track by field.uid()"> 3 <div ng-repeat="(index, field) in value | extractFields track by field.uid()">
4 <div ng-if="field.isAtomic()" class="form-group"> 4 <div ng-if="field.isAtomic()" class="form-group">
5 <div class="input-group"> 5 <div class="input-group">
6 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 6 <typed-field value="field"></typed-field>
7 <span class="input-group-btn"> 7 <span class="input-group-btn">
8 <button class="btn btn-default" ng-click="value.remove($index)"> 8 <button class="btn btn-default" ng-click="value.remove($index)">
9 <i class="fa fa-minus-circle"></i> 9 <i class="fa fa-minus-circle"></i>
@@ -12,7 +12,7 @@
12 </div> 12 </div>
13 </div> 13 </div>
14 <div ng-if="!field.isAtomic()"> 14 <div ng-if="!field.isAtomic()">
15 <typed-field value="field" type="{$ field.getType() $}"></typed-field> 15 <typed-field value="field"></typed-field>
16 </div> 16 </div>
17 </div> 17 </div>
18 </div> 18 </div>
diff --git a/merlin/test/js/merlin.directives.spec.js b/merlin/test/js/merlin.directives.spec.js
index 00cf1b9..f6133fa 100644
--- a/merlin/test/js/merlin.directives.spec.js
+++ b/merlin/test/js/merlin.directives.spec.js
@@ -232,12 +232,12 @@ describe('merlin directives', function() {
232 '<div><typed-field ' + contents + '></typed-field></div>')($scope); 232 '<div><typed-field ' + contents + '></typed-field></div>')($scope);
233 } 233 }
234 234
235 it('type of resulting field is determined by `type` attribute', function() { 235 it('type of resulting field is determined by `value.getType` method', function() {
236 var element1, element2; 236 var element1, element2;
237 $scope.value1 = {type: 'text'}; 237 $scope.value1 = {getType: function() { return 'text'; }};
238 $scope.value2 = {type: 'number'}; 238 $scope.value2 = {getType: function() { return 'number'; }};
239 element1 = makeFieldElem('value="value1" type="{$ value1.type $}"'); 239 element1 = makeFieldElem('value="value1"');
240 element2 = makeFieldElem('value="value2" type="{$ value2.type $}"'); 240 element2 = makeFieldElem('value="value2"');
241 $httpBackend.flush(); 241 $httpBackend.flush();
242 $scope.$digest(); 242 $scope.$digest();
243 243
@@ -247,8 +247,8 @@ describe('merlin directives', function() {
247 247
248 it('field is not rendered until the corresponding template has been served', function() { 248 it('field is not rendered until the corresponding template has been served', function() {
249 var element; 249 var element;
250 $scope.value = {type: 'text'}; 250 $scope.value = {getType: function() {return 'text'; }};
251 element = makeFieldElem('value="value" type="{$ value.type $}"'); 251 element = makeFieldElem('value="value"');
252 expect(element.html()).not.toContain('<textarea'); 252 expect(element.html()).not.toContain('<textarea');
253 253
254 $httpBackend.flush(); 254 $httpBackend.flush();