Skip to content

Commit d3524cc

Browse files
committed
Re-add examples temporarily
Temporarily use the example app again until core is working and I have an easy way to test versions of it within the decorator
1 parent 75964d1 commit d3524cc

25 files changed

+1507
-2877
lines changed

dist/bootstrap-decorator.js

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

dist/schema-form.js

+46-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*!
2+
* angular-schema-form
3+
* @version 1.0.0-alpha.1
4+
* @license MIT
5+
* Copyright (c) 2016 JSON Schema Form
6+
*/
17
(function webpackUniversalModuleDefinition(root, factory) {
28
if(typeof exports === 'object' && typeof module === 'object')
39
module.exports = factory(require("angular"), require("tv4"));
@@ -282,7 +288,7 @@ return /******/ (function(modules) { // webpackBootstrap
282288
if (args.form.key) {
283289
var strKey = sfPathProvider.stringify(args.form.key);
284290
evalExpr = 'evalExpr(' + args.path + '.condition,{ model: model, "arrayIndex": $index, ' + '"modelValue": model' + (strKey[0] === '[' ? '' : '.') + strKey + '})';
285-
}
291+
};
286292

287293
var children = args.fieldFrag.children || args.fieldFrag.childNodes;
288294
for (var i = 0; i < children.length; i++) {
@@ -295,8 +301,8 @@ return /******/ (function(modules) { // webpackBootstrap
295301
array: function array(args) {
296302
var items = args.fieldFrag.querySelector('[schema-form-array-items]');
297303
if (items) {
298-
state = angular.copy(args.state);
299-
state.keyRedaction = state.keyRedaction || 0;
304+
var state = angular.copy(args.state);
305+
state.keyRedaction = 0;
300306
state.keyRedaction += args.form.key.length + 1;
301307

302308
// Special case, an array with just one item in it that is not an object.
@@ -323,7 +329,6 @@ return /******/ (function(modules) { // webpackBootstrap
323329
this.stdBuilders = stdBuilders;
324330

325331
this.$get = ['$templateCache', 'schemaFormDecorators', 'sfPath', function ($templateCache, schemaFormDecorators, sfPath) {
326-
327332
var checkForSlot = function checkForSlot(form, slots) {
328333
// Finally append this field to the frag.
329334
// Check for slots
@@ -368,8 +373,9 @@ return /******/ (function(modules) { // webpackBootstrap
368373
state.arrayCompatFlag = false;
369374

370375
// TODO: Create a couple fo testcases, small and large and
371-
// measure optmization. A good start is probably a cache of DOM nodes for a particular
372-
// template that can be cloned instead of using innerHTML
376+
// measure optmization. A good start is probably a
377+
// cache of DOM nodes for a particular template
378+
// that can be cloned instead of using innerHTML
373379
var div = document.createElement('div');
374380
var template = templateFn(f, field) || templateFn(f, decorator['default']);
375381
div.innerHTML = template;
@@ -822,11 +828,11 @@ return /******/ (function(modules) { // webpackBootstrap
822828
* @param {string} name directive name (CamelCased)
823829
* @param {Object} fields, an object that maps "type" => `{ template, builder, replace}`.
824830
attributes `builder` and `replace` are optional, and replace defaults to true.
825-
`template` should be the key of the template to load and it should be pre-loaded
831+
`template` should be the key of the template to load and it should be pre-loaded
826832
in `$templateCache`.
827-
`builder` can be a function or an array of functions. They will be called in
833+
`builder` can be a function or an array of functions. They will be called in
828834
the order they are supplied.
829-
`replace` (DEPRECATED) is for backwards compatability. If false the builder
835+
`replace` (DEPRECATED) is for backwards compatability. If false the builder
830836
will use the "old" way of building that form field using a <sf-decorator>
831837
directive.
832838
*/
@@ -1066,6 +1072,12 @@ return /******/ (function(modules) { // webpackBootstrap
10661072
/* 6 */
10671073
/***/ function(module, exports, __webpack_require__) {
10681074

1075+
/*!
1076+
* json-schema-form
1077+
* @version 1.0.0-alpha.1
1078+
* @license MIT
1079+
* Copyright 2016 JSON Schema Form
1080+
*/
10691081
(function webpackUniversalModuleDefinition(root, factory) {
10701082
if(true)
10711083
module.exports = factory();
@@ -1277,7 +1289,7 @@ return /******/ (function(modules) { // webpackBootstrap
12771289
// Since have to ternary state we need a default
12781290
if (obj.type === 'checkbox' && obj.schema['default'] === undefined) {
12791291
obj.schema['default'] = false;
1280-
}
1292+
};
12811293

12821294
// Special case: template type with tempplateUrl that's needs to be loaded before rendering
12831295
// TODO: this is not a clean solution. Maybe something cleaner can be made when $ref support
@@ -1654,9 +1666,13 @@ return /******/ (function(modules) { // webpackBootstrap
16541666
/* Utils */
16551667
var stripNullType = function stripNullType(type) {
16561668
if (Array.isArray(type) && type.length == 2) {
1657-
if (type[0] === 'null') return type[1];
1658-
if (type[1] === 'null') return type[0];
1659-
}
1669+
if (type[0] === 'null') {
1670+
return type[1];
1671+
};
1672+
if (type[1] === 'null') {
1673+
return type[0];
1674+
};
1675+
};
16601676
return type;
16611677
};
16621678

@@ -1676,8 +1692,12 @@ return /******/ (function(modules) { // webpackBootstrap
16761692
var rules = schemaTypes[stripNullType(schema.type)];
16771693
if (rules) {
16781694
var def = void 0;
1695+
// We give each rule a possibility to recurse it's children.
1696+
var innerDefaultFormDefinition = function innerDefaultFormDefinition(childName, childSchema, childOptions) {
1697+
return defaultFormDefinition(schemaTypes, childName, childSchema, childOptions);
1698+
};
16791699
for (var i = 0; i < rules.length; i++) {
1680-
def = rules[i](name, schema, options);
1700+
def = rules[i](name, schema, options, innerDefaultFormDefinition);
16811701

16821702
//first handler in list that actually returns something is our handler!
16831703
if (def) {
@@ -1744,7 +1764,7 @@ return /******/ (function(modules) { // webpackBootstrap
17441764
f.ngModelOptions = f.ngModelOptions || {};
17451765

17461766
return f;
1747-
}
1767+
};
17481768

17491769
/*** Schema types to form type mappings, with defaults ***/
17501770
function text(name, schema, options) {
@@ -1815,14 +1835,15 @@ return /******/ (function(modules) { // webpackBootstrap
18151835
}
18161836
}
18171837

1818-
function fieldset(name, schema, options) {
1838+
function fieldset(name, schema, options, defaultFormDef) {
18191839
if (stripNullType(schema.type) === 'object') {
18201840
var _ret = function () {
18211841
var f = stdFormObj(name, schema, options);
18221842
f.type = 'fieldset';
18231843
f.items = [];
18241844
options.lookup[(0, _sfPath.stringify)(options.path)] = f;
18251845

1846+
console.log('fieldset', f, schema);
18261847
//recurse down into properties
18271848
if (schema.properties) {
18281849
Object.keys(schema.properties).forEach(function (key) {
@@ -1832,7 +1853,7 @@ return /******/ (function(modules) { // webpackBootstrap
18321853
if (options.ignore[(0, _sfPath.stringify)(path)] !== true) {
18331854
var required = schema.required && schema.required.indexOf(key) !== -1;
18341855

1835-
var def = defaultFormDefinition(key, value, {
1856+
var def = defaultFormDef(key, value, {
18361857
path: path,
18371858
required: required || false,
18381859
lookup: options.lookup,
@@ -1854,7 +1875,7 @@ return /******/ (function(modules) { // webpackBootstrap
18541875
}
18551876
}
18561877

1857-
function array(name, schema, options) {
1878+
function array(name, schema, options, defaultFormDef) {
18581879
if (stripNullType(schema.type) === 'array') {
18591880
var f = stdFormObj(name, schema, options);
18601881
f.type = 'array';
@@ -1871,7 +1892,7 @@ return /******/ (function(modules) { // webpackBootstrap
18711892
var arrPath = options.path.slice();
18721893
arrPath.push('');
18731894

1874-
f.items = [defaultFormDefinition(name, schema.items, {
1895+
f.items = [defaultFormDef(name, schema.items, {
18751896
path: arrPath,
18761897
required: required || false,
18771898
lookup: options.lookup,
@@ -1892,9 +1913,10 @@ return /******/ (function(modules) { // webpackBootstrap
18921913
number: [number],
18931914
integer: [integer],
18941915
boolean: [checkbox],
1895-
array: [checkboxes, array]
1916+
array: [array],
1917+
defaultForm: defaultForm
18961918
};
1897-
}
1919+
};
18981920

18991921
/**
19001922
* Create form defaults from schema
@@ -3474,10 +3496,12 @@ return /******/ (function(modules) { // webpackBootstrap
34743496
}
34753497
};
34763498

3499+
var first = true;
34773500
ngModel.$formatters.push(function (val) {
34783501
// When a form first loads this will be called for each field.
34793502
// we usually don't want that.
3480-
if (ngModel.$pristine && scope.firstDigest && (!scope.options || scope.options.validateOnRender !== true)) {
3503+
if (ngModel.$pristine && first && (!scope.options || scope.options.validateOnRender !== true)) {
3504+
first = false;
34813505
return val;
34823506
}
34833507
validate(ngModel.$modelValue);

0 commit comments

Comments
 (0)