Skip to content

Commit fcda5cc

Browse files
committed
Merge branch 'revert-418-t push origin developmentfeature-select-options-trackBy' into development
2 parents 8d4af0a + fa6a039 commit fcda5cc

File tree

4 files changed

+3
-88
lines changed

4 files changed

+3
-88
lines changed

src/directives/decorators/bootstrap/select.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
sf-changed="form"
1010
class="form-control {{form.fieldHtmlClass}}"
1111
schema-validate="form"
12-
ng-options="item.value as item.name group by item.group for item in form.titleMap track by item[form.trackBy]"
12+
ng-options="item.value as item.name group by item.group for item in form.titleMap"
1313
name="{{form.key.slice(-1)[0]}}">
1414
</select>
1515
<div class="help-block" sf-message="form.description"></div>

src/services/schema-form.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ angular.module('schemaForm').provider('schemaForm',
1313
return type[0];
1414
}
1515
return type;
16-
};
16+
}
1717

1818
//Creates an default titleMap list from an enum, i.e. a list of strings.
1919
var enumToTitleMap = function(enm) {
@@ -146,7 +146,6 @@ angular.module('schemaForm').provider('schemaForm',
146146
if (!f.titleMap) {
147147
f.titleMap = enumToTitleMap(schema['enum']);
148148
}
149-
f.trackBy = 'value';
150149
options.lookup[sfPathProvider.stringify(options.path)] = f;
151150
return f;
152151
}
@@ -340,10 +339,6 @@ angular.module('schemaForm').provider('schemaForm',
340339
obj.titleMap = canonicalTitleMap(obj.titleMap);
341340
}
342341

343-
if(obj.type === 'select') {
344-
obj.trackBy = obj.trackBy || 'value';
345-
}
346-
347342
//
348343
if (obj.itemForm) {
349344
obj.items = [];

test/directives/schema-form-test.js

-79
Original file line numberDiff line numberDiff line change
@@ -1649,85 +1649,6 @@ describe('directive',function(){
16491649
});
16501650

16511651

1652-
it('should show the correct option selected', function() {
1653-
inject(function($compile,$rootScope){
1654-
var scope = $rootScope.$new();
1655-
scope.thing = { id: 2, a: 1};
1656-
1657-
scope.schema = {
1658-
"type": "object",
1659-
"properties": {
1660-
"thing": {
1661-
"title": "Thing"
1662-
}
1663-
}
1664-
};
1665-
1666-
scope.form = [{
1667-
key: "thing",
1668-
type: 'select',
1669-
titleMap: [{
1670-
name: 'abc', value: { id: 1, a: 2 }
1671-
},{
1672-
name: 'def', value: { id: 2, a: 1 }
1673-
},{
1674-
name: 'ghi', value: { id: 3, a: 3 }
1675-
}]
1676-
}];
1677-
1678-
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="thing"></form>');
1679-
1680-
$compile(tmpl)(scope);
1681-
$rootScope.$apply();
1682-
1683-
setTimeout(function() {
1684-
tmpl.children().eq(0).find('select').eq(0).val().should.be.eq(2);
1685-
}, 0);
1686-
1687-
});
1688-
});
1689-
1690-
1691-
it('should show the correct option selected with `track by`', function() {
1692-
inject(function($compile,$rootScope){
1693-
var scope = $rootScope.$new();
1694-
scope.thing = { id: 2, a: 1, b: 2 };
1695-
1696-
scope.schema = {
1697-
"type": "object",
1698-
"properties": {
1699-
"thing": {
1700-
"title": "Thing"
1701-
}
1702-
}
1703-
};
1704-
1705-
scope.form = [{
1706-
key: "thing",
1707-
type: 'select',
1708-
titleMap: [{
1709-
id: 1, name: 'abc', value: { id: 1 }
1710-
},{
1711-
id: 2, name: 'def', value: { id: 2 }
1712-
},{
1713-
id: 3, name: 'ghi', value: { id: 3 }
1714-
}],
1715-
trackBy: 'id'
1716-
}];
1717-
1718-
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="thing"></form>');
1719-
1720-
$compile(tmpl)(scope);
1721-
$rootScope.$apply();
1722-
1723-
setTimeout(function() {
1724-
tmpl.children().eq(0).find('select').eq(0).val().should.be.eq(2);
1725-
}, 0);
1726-
1727-
});
1728-
});
1729-
1730-
17311652
it('should update array form on model array ref change',function(){
17321653

17331654
inject(function($compile,$rootScope){

test/services/schema-form-test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ describe('schemaForm', function() {
9191
"name": "NaN",
9292
"value": "NaN"
9393
}
94-
],
95-
"trackBy": "value"
94+
]
9695
},
9796
{
9897
"title": "Are you over 18 years old?",

0 commit comments

Comments
 (0)