Skip to content

Commit

Permalink
Merge branch 'hotfix/checkboxes'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlgj committed Sep 24, 2015
2 parents b37f208 + a3d630d commit 9d2868e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
v0.8.10
-------
* Bugfix for checkboxes when model array is undefined.

v0.8.9
------
* Bugfix for radios and radios-inline. Validation should now work.
Expand Down
22 changes: 14 additions & 8 deletions dist/schema-form.js
Expand Up @@ -2293,6 +2293,18 @@ function(sel, sfPath, schemaForm) {
}
};

// If model is undefined make sure it gets set.
var getOrCreateModel = function() {
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
return model;
};

// We need the form definition to make a decision on how we should listen.
var once = scope.$watch('form', function(form) {
if (!form) {
Expand Down Expand Up @@ -2363,7 +2375,7 @@ function(sel, sfPath, schemaForm) {
//To get two way binding we also watch our titleMapValues
scope.$watchCollection('titleMapValues', function(vals, old) {
if (vals && vals !== old) {
var arr = scope.modelArray;
var arr = getOrCreateModel();

// Apparently the fastest way to clear an array, readable too.
// http://jsperf.com/array-destroy/32
Expand Down Expand Up @@ -2392,13 +2404,7 @@ function(sel, sfPath, schemaForm) {
var empty;

// Create and set an array if needed.
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
var model = getOrCreateModel();

// Same old add empty things to the array hack :(
if (scope.form && scope.form.schema && scope.form.schema.items) {
Expand Down
2 changes: 1 addition & 1 deletion dist/schema-form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "angular-schema-form",
"version": "0.8.9",
"version": "0.8.10",
"description": "Create complex forms from a JSON schema with angular.",
"repository": "Textalk/angular-schema-form",
"main": "dist/schema-form.min.js",
Expand Down
22 changes: 14 additions & 8 deletions src/directives/newArray.js
Expand Up @@ -33,6 +33,18 @@ function(sel, sfPath, schemaForm) {
}
};

// If model is undefined make sure it gets set.
var getOrCreateModel = function() {
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
return model;
};

// We need the form definition to make a decision on how we should listen.
var once = scope.$watch('form', function(form) {
if (!form) {
Expand Down Expand Up @@ -103,7 +115,7 @@ function(sel, sfPath, schemaForm) {
//To get two way binding we also watch our titleMapValues
scope.$watchCollection('titleMapValues', function(vals, old) {
if (vals && vals !== old) {
var arr = scope.modelArray;
var arr = getOrCreateModel();

// Apparently the fastest way to clear an array, readable too.
// http://jsperf.com/array-destroy/32
Expand Down Expand Up @@ -132,13 +144,7 @@ function(sel, sfPath, schemaForm) {
var empty;

// Create and set an array if needed.
var model = scope.modelArray;
if (!model) {
var selection = sfPath.parse(attrs.sfNewArray);
model = [];
sel(selection, scope, model);
scope.modelArray = model;
}
var model = getOrCreateModel();

// Same old add empty things to the array hack :(
if (scope.form && scope.form.schema && scope.form.schema.items) {
Expand Down

0 comments on commit 9d2868e

Please sign in to comment.