Skip to content

Commit 764599d

Browse files
committed
Merge branch 'release/v0.7.3'
2 parents 204d5bb + 5adc770 commit 764599d

16 files changed

+175
-85
lines changed

CHANGELOG

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
v0.7.3
2+
------
3+
* Fix for regression in enum order in selects, thanks @adamschwartz
4+
* Descriptons in fieldsets, thanks @mike-marcacci
5+
* Evaluate sfModel in the parent scope, thanks @mike-marcacci
6+
* 'defaultFormDefinition' is now exported on the schemaForm provider making it possible to create
7+
addons that have arbitrary forms inside them, i.e. like fieldset.
8+
* A couple of bugs, required should now work fine, tabarrays behave, list tags be mathed etc
9+
110
v0.7.2
211
------
312
* Add-ons now have their own repos, and there is a colorpicker!

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dist/bootstrap-decorator.min.js",
66
"dist/bootstrap-datepicker.min.js"
77
],
8-
"version": "0.7.2",
8+
"version": "0.7.3",
99
"authors": [
1010
"Textalk",
1111
"David Jensen <[email protected]>"

dist/bootstrap-datepicker.min.js

-1
This file was deleted.

dist/bootstrap-decorator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/schema-form.js

+37-18
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,18 @@ angular.module('schemaForm').provider('schemaForm',
456456

457457
// Takes a titleMap in either object or list format and returns one in
458458
// in the list format.
459-
var canonicalTitleMap = function(titleMap) {
459+
var canonicalTitleMap = function(titleMap, originalEnum) {
460460
if (!angular.isArray(titleMap)) {
461461
var canonical = [];
462-
angular.forEach(titleMap, function(name, value) {
463-
canonical.push({name: name, value: value});
464-
});
462+
if (originalEnum) {
463+
angular.forEach(originalEnum, function(value, index) {
464+
canonical.push({name: titleMap[value], value: value});
465+
});
466+
} else {
467+
angular.forEach(titleMap, function(name, value) {
468+
canonical.push({name: name, value: value});
469+
});
470+
}
465471
return canonical;
466472
}
467473
return titleMap;
@@ -502,7 +508,7 @@ angular.module('schemaForm').provider('schemaForm',
502508

503509
//Non standard attributes
504510
if (schema.validationMessage) { f.validationMessage = schema.validationMessage; }
505-
if (schema.enumNames) { f.titleMap = canonicalTitleMap(schema.enumNames); }
511+
if (schema.enumNames) { f.titleMap = canonicalTitleMap(schema.enumNames, schema.enum); }
506512
f.schema = schema;
507513

508514
// Ng model options doesn't play nice with undefined, might be defined
@@ -658,8 +664,9 @@ angular.module('schemaForm').provider('schemaForm',
658664
/**
659665
* Provider API
660666
*/
661-
this.defaults = defaults;
662-
this.stdFormObj = stdFormObj;
667+
this.defaults = defaults;
668+
this.stdFormObj = stdFormObj;
669+
this.defaultFormDefinition = defaultFormDefinition;
663670

664671
/**
665672
* Register a post process function.
@@ -718,7 +725,6 @@ angular.module('schemaForm').provider('schemaForm',
718725
options = options || {};
719726

720727
var stdForm = service.defaults(schema, ignore, options);
721-
722728
//simple case, we have a "*", just put the stdForm there
723729
var idx = form.indexOf('*');
724730
if (idx !== -1) {
@@ -738,11 +744,29 @@ angular.module('schemaForm').provider('schemaForm',
738744
obj = {key: obj};
739745
}
740746

747+
if (obj.key) {
748+
if (typeof obj.key === 'string') {
749+
obj.key = sfPathProvider.parse(obj.key);
750+
}
751+
}
752+
741753
//If it has a titleMap make sure it's a list
742754
if (obj.titleMap) {
743755
obj.titleMap = canonicalTitleMap(obj.titleMap);
744756
}
745757

758+
//
759+
if (obj.itemForm) {
760+
obj.items = [];
761+
var str = sfPathProvider.stringify(obj.key);
762+
var stdForm = lookup[str];
763+
angular.forEach(stdForm.items, function(item) {
764+
var o = angular.copy(obj.itemForm);
765+
o.key = item.key;
766+
obj.items.push(o);
767+
});
768+
}
769+
746770
//if it's a type with items, merge 'em!
747771
if (obj.items) {
748772
obj.items = service.merge(schema, obj.items, ignore);
@@ -757,10 +781,6 @@ angular.module('schemaForm').provider('schemaForm',
757781

758782
//extend with std form from schema.
759783
if (obj.key) {
760-
if (typeof obj.key === 'string') {
761-
obj.key = sfPathProvider.parse(obj.key);
762-
}
763-
764784
var str = sfPathProvider.stringify(obj.key);
765785
if (lookup[str]) {
766786
obj = angular.extend(lookup[str], obj);
@@ -789,7 +809,7 @@ angular.module('schemaForm').provider('schemaForm',
789809
if (schema.type === 'object') {
790810
angular.forEach(schema.properties, function(v, k) {
791811
if (ignore[k] !== true) {
792-
var required = schema.required && schema.required.indexOf(k[k.length - 1]) !== -1;
812+
var required = schema.required && schema.required.indexOf(k) !== -1;
793813
var def = defaultFormDefinition(k, v, {
794814
path: [k], // Path to this property in bracket notation.
795815
lookup: lookup, // Extra map to register with. Optimization for merger.
@@ -1019,6 +1039,7 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf
10191039
if (scope.validateArray) {
10201040
scope.validateArray();
10211041
}
1042+
return list;
10221043
};
10231044

10241045
// Always start with one empty form unless configured otherwise.
@@ -1178,7 +1199,8 @@ angular.module('schemaForm')
11781199
scope: {
11791200
schema: '=sfSchema',
11801201
initialForm: '=sfForm',
1181-
model: '=sfModel'
1202+
model: '=sfModel',
1203+
options: '=sfOptions'
11821204
},
11831205
controller: ['$scope', function($scope) {
11841206
this.evalInParentScope = function(expr, locals) {
@@ -1231,10 +1253,7 @@ angular.module('schemaForm')
12311253
lastDigest.schema = schema;
12321254
lastDigest.form = form;
12331255

1234-
// Check for options
1235-
var options = scope.$eval(attrs.sfOptions);
1236-
1237-
var merged = schemaForm.merge(schema, form, ignore, options);
1256+
var merged = schemaForm.merge(schema, form, ignore, scope.options);
12381257
var frag = document.createDocumentFragment();
12391258

12401259
//make the form available to decorators

0 commit comments

Comments
 (0)