Permalink
Browse files

Release 0.8.13

Maintenance release 0.8.13
Bugfix copy the initial form default on form redraw @stanimoto
Bugfix for revalidating the model after custom validation event is
broadcast @cepauskas
New event value. The form name is now passed in validate and error
events @tomsowerby & @LeonardoGentile
1 parent f73411c commit 70d55b65cf0a86b58e9c1da5ddad4a33e48e5387 @Anthropic Anthropic committed Apr 3, 2016
Showing with 143 additions and 122 deletions.
  1. +18 −12 CHANGELOG
  2. +92 −78 dist/schema-form.js
  3. +1 −1 dist/schema-form.min.js
  4. +2 −2 gulp/tasks/jscs.js
  5. +24 −24 gulp/tasks/minify.js
  6. +6 −5 package.json
View
@@ -1,3 +1,9 @@
+v0.8.13
+-------
+ * Bugfix copy the initial form default on form redraw @stanimoto
+ * Bugfix for revalidating the model after custom validation event is broadcast @cepauskas
+ * New event value. The form name is now passed in validate and error events @tomsowerby & @LeonardoGentile
+
v0.8.12
-------
* Bugfix for `condition` builder. It had a typo that broke it.
@@ -118,14 +124,14 @@ v0.7.11
v0.7.10
------
-* Accessability additions, thanks @stramel
-* Updates to the gulp tasks, thanks @stramel
-* Updated to bower, thanks @Dervisevic
-* Updates to documentation & README & Contributing.md, thanks @davidlgj @Dervisevic
-* Speed optimization, thanks @stramel
-* Call ngModel.$setDirty() when deleting from array, thanks @qstrahl
-* Don't override readonly if specified on items individually, thanks @qstrahl
-* Update to the examples, thanks @mike-marcacci
+ * Accessability additions, thanks @stramel
+ * Updates to the gulp tasks, thanks @stramel
+ * Updated to bower, thanks @Dervisevic
+ * Updates to documentation & README & Contributing.md, thanks @davidlgj @Dervisevic
+ * Speed optimization, thanks @stramel
+ * Call ngModel.$setDirty() when deleting from array, thanks @qstrahl
+ * Don't override readonly if specified on items individually, thanks @qstrahl
+ * Update to the examples, thanks @mike-marcacci
v0.7.9
------
@@ -264,7 +270,7 @@ We're celebrating actual useful functionality by bumping minor version, yay!
v0.0.4
------
-* Fieldsets now properly merge schema defaults.
-* Directives for "manual" decorator usage.
-* Basic support for buttons.
-* Basic support for custom validation error messages.
+ * Fieldsets now properly merge schema defaults.
+ * Directives for "manual" decorator usage.
+ * Basic support for buttons.
+ * Basic support for custom validation error messages.
View
@@ -65,81 +65,6 @@ angular.module('schemaForm').provider('sfPath',
};
}]);
-/**
- * @ngdoc service
- * @name sfSelect
- * @kind function
- *
- */
-angular.module('schemaForm').factory('sfSelect', ['sfPath', function(sfPath) {
- var numRe = /^\d+$/;
-
- /**
- * @description
- * Utility method to access deep properties without
- * throwing errors when things are not defined.
- * Can also set a value in a deep structure, creating objects when missing
- * ex.
- * var foo = Select('address.contact.name',obj)
- * Select('address.contact.name',obj,'Leeroy')
- *
- * @param {string} projection A dot path to the property you want to get/set
- * @param {object} obj (optional) The object to project on, defaults to 'this'
- * @param {Any} valueToSet (opional) The value to set, if parts of the path of
- * the projection is missing empty objects will be created.
- * @returns {Any|undefined} returns the value at the end of the projection path
- * or undefined if there is none.
- */
- return function(projection, obj, valueToSet) {
- if (!obj) {
- obj = this;
- }
- //Support [] array syntax
- var parts = typeof projection === 'string' ? sfPath.parse(projection) : projection;
-
- if (typeof valueToSet !== 'undefined' && parts.length === 1) {
- //special case, just setting one variable
- obj[parts[0]] = valueToSet;
- return obj;
- }
-
- if (typeof valueToSet !== 'undefined' &&
- typeof obj[parts[0]] === 'undefined') {
- // We need to look ahead to check if array is appropriate
- obj[parts[0]] = parts.length > 2 && numRe.test(parts[1]) ? [] : {};
- }
-
- var value = obj[parts[0]];
- for (var i = 1; i < parts.length; i++) {
- // Special case: We allow JSON Form syntax for arrays using empty brackets
- // These will of course not work here so we exit if they are found.
- if (parts[i] === '') {
- return undefined;
- }
- if (typeof valueToSet !== 'undefined') {
- if (i === parts.length - 1) {
- //last step. Let's set the value
- value[parts[i]] = valueToSet;
- return valueToSet;
- } else {
- // Make sure to create new objects on the way if they are not there.
- // We need to look ahead to check if array is appropriate
- var tmp = value[parts[i]];
- if (typeof tmp === 'undefined' || tmp === null) {
- tmp = numRe.test(parts[i + 1]) ? [] : {};
- value[parts[i]] = tmp;
- }
- value = tmp;
- }
- } else if (value) {
- //Just get nex value.
- value = value[parts[i]];
- }
- }
- return value;
- };
-}]);
-
// FIXME: type template (using custom builder)
angular.module('schemaForm').provider('sfBuilder', ['sfPathProvider', function(sfPathProvider) {
@@ -682,6 +607,9 @@ angular.module('schemaForm').provider('schemaFormDecorators',
scope.ngModel.$setValidity(error, validity === true);
if (validity === true) {
+ // Re-trigger model validator, that model itself would be re-validated
+ scope.ngModel.$validate();
+
// Setting or removing a validity can change the field to believe its valid
// but its not. So lets trigger its validation as well.
scope.$broadcast('schemaFormValidate');
@@ -1553,6 +1481,81 @@ angular.module('schemaForm').provider('schemaForm',
}]);
+/**
+ * @ngdoc service
+ * @name sfSelect
+ * @kind function
+ *
+ */
+angular.module('schemaForm').factory('sfSelect', ['sfPath', function(sfPath) {
+ var numRe = /^\d+$/;
+
+ /**
+ * @description
+ * Utility method to access deep properties without
+ * throwing errors when things are not defined.
+ * Can also set a value in a deep structure, creating objects when missing
+ * ex.
+ * var foo = Select('address.contact.name',obj)
+ * Select('address.contact.name',obj,'Leeroy')
+ *
+ * @param {string} projection A dot path to the property you want to get/set
+ * @param {object} obj (optional) The object to project on, defaults to 'this'
+ * @param {Any} valueToSet (opional) The value to set, if parts of the path of
+ * the projection is missing empty objects will be created.
+ * @returns {Any|undefined} returns the value at the end of the projection path
+ * or undefined if there is none.
+ */
+ return function(projection, obj, valueToSet) {
+ if (!obj) {
+ obj = this;
+ }
+ //Support [] array syntax
+ var parts = typeof projection === 'string' ? sfPath.parse(projection) : projection;
+
+ if (typeof valueToSet !== 'undefined' && parts.length === 1) {
+ //special case, just setting one variable
+ obj[parts[0]] = valueToSet;
+ return obj;
+ }
+
+ if (typeof valueToSet !== 'undefined' &&
+ typeof obj[parts[0]] === 'undefined') {
+ // We need to look ahead to check if array is appropriate
+ obj[parts[0]] = parts.length > 2 && numRe.test(parts[1]) ? [] : {};
+ }
+
+ var value = obj[parts[0]];
+ for (var i = 1; i < parts.length; i++) {
+ // Special case: We allow JSON Form syntax for arrays using empty brackets
+ // These will of course not work here so we exit if they are found.
+ if (parts[i] === '') {
+ return undefined;
+ }
+ if (typeof valueToSet !== 'undefined') {
+ if (i === parts.length - 1) {
+ //last step. Let's set the value
+ value[parts[i]] = valueToSet;
+ return valueToSet;
+ } else {
+ // Make sure to create new objects on the way if they are not there.
+ // We need to look ahead to check if array is appropriate
+ var tmp = value[parts[i]];
+ if (typeof tmp === 'undefined' || tmp === null) {
+ tmp = numRe.test(parts[i + 1]) ? [] : {};
+ value[parts[i]] = tmp;
+ }
+ value = tmp;
+ }
+ } else if (value) {
+ //Just get nex value.
+ value = value[parts[i]];
+ }
+ }
+ return value;
+ };
+}]);
+
/* Common code for validating a value against its form and schema definition */
/* global tv4 */
angular.module('schemaForm').factory('sfValidator', [function() {
@@ -2109,6 +2112,9 @@ angular.module('schemaForm').directive('sfField',
scope.ngModel.$setValidity(error, validity === true);
if (validity === true) {
+ // Re-trigger model validator, that model itself would be re-validated
+ scope.ngModel.$validate();
+
// Setting or removing a validity can change the field to believe its valid
// but its not. So lets trigger its validation as well.
scope.$broadcast('schemaFormValidate');
@@ -2677,7 +2683,7 @@ angular.module('schemaForm')
// part of the form or schema is chnaged without it being a new instance.
scope.$on('schemaFormRedraw', function() {
var schema = scope.schema;
- var form = scope.initialForm || ['*'];
+ var form = scope.initialForm ? angular.copy(scope.initialForm) : ['*'];
if (schema) {
render(schema, form);
}
@@ -2817,7 +2823,13 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
var schema = form.schema;
// A bit ugly but useful.
- scope.validateField = function() {
+ scope.validateField = function(formName) {
+
+ // If we have specified a form name, and this model is not within
+ // that form, then leave things be.
+ if(formName != undefined && ngModel.$$parentForm.$name !== formName) {
+ return;
+ }
// Special case: arrays
// TODO: Can this be generalized in a way that works consistently?
@@ -2864,7 +2876,9 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
});
// Listen to an event so we can validate the input on request
- scope.$on('schemaFormValidate', scope.validateField);
+ scope.$on('schemaFormValidate', function(event, formName) {
+ scope.validateField(formName);
+ });
scope.schemaError = function() {
return error;
Oops, something went wrong.
View
@@ -1,5 +1,5 @@
-var gulp = require('gulp'),
- jscs = require('gulp-jscs');
+var gulp = require('gulp');
+var jscs = require('gulp-jscs');
gulp.task('jscs', function() {
gulp.src('./src/**/*.js')
View
@@ -1,30 +1,30 @@
-var gulp = require('gulp'),
- concat = require('gulp-concat'),
- rename = require('gulp-rename'),
- umd = require('gulp-umd'),
- uglify = require('gulp-uglify');
+var gulp = require('gulp');
+var concat = require('gulp-concat');
+var rename = require('gulp-rename');
+var umd = require('gulp-umd');
+var uglify = require('gulp-uglify');
gulp.task('minify', function() {
gulp.src([
- './src/module.js',
- './src/sfPath.js',
- './src/services/*.js',
- './src/directives/*.js'
+ './src/module.js',
+ './src/sfPath.js',
+ './src/services/*.js',
+ './src/directives/*.js'
])
- .pipe(concat('schema-form.js'))
- .pipe(umd({
- dependencies: function() {
- return [
- {name: 'angular'},
- {name: 'objectpath'},
- {name: 'tv4'},
- ];
- },
- exports: function() {return 'schemaForm';},
- namespace: function() {return 'schemaForm';}
+ .pipe(concat('schema-form.js'))
+ .pipe(umd({
+ dependencies: function() {
+ return [
+ {name: 'angular'},
+ {name: 'objectpath'},
+ {name: 'tv4'},
+ ];
+ },
+ exports: function() {return 'schemaForm';},
+ namespace: function() {return 'schemaForm';}
}))
- .pipe(gulp.dest('./dist/'))
- .pipe(uglify())
- .pipe(rename('schema-form.min.js'))
- .pipe(gulp.dest('./dist/'));
+ .pipe(gulp.dest('./dist/'))
+ .pipe(uglify())
+ .pipe(rename('schema-form.min.js'))
+ .pipe(gulp.dest('./dist/'));
});
View
@@ -1,6 +1,6 @@
{
"name": "angular-schema-form",
- "version": "0.8.12",
+ "version": "0.8.13",
"description": "Create complex forms from a JSON schema with angular.",
"repository": "Textalk/angular-schema-form",
"main": "dist/schema-form.min.js",
@@ -14,7 +14,8 @@
"David Jensen <david.lgj@gmail.com> (https://github.com/davidlgj)",
"Denis Dervisevic <denis@dervisevic.se> (https://github.com/Dervisevic)",
"Cameron Edwards (https://github.com/cameronprattedwards)",
- "Mike Marcacci (https://github.com/mike-marcacci)"
+ "Mike Marcacci (https://github.com/mike-marcacci)",
+ "Marcel Bennett (https://github.com/Anthropic)"
],
"license": "MIT",
"dependencies": {
@@ -29,6 +30,8 @@
"form",
"json",
"json-schema",
+ "json-schema-form",
+ "ui-schema",
"schema"
],
"devDependencies": {
@@ -68,9 +71,7 @@
"basePath": "/dist/",
"files": [
"schema-form.min.js",
- "schema-form.js",
- "bootstrap-decorator.min.js",
- "bootstrap-decorator.js"
+ "schema-form.js"
]
}
}

0 comments on commit 70d55b6

Please sign in to comment.