Skip to content

Commit 3c5680a

Browse files
authored
Merge pull request #874 from mnzaki/formKeyFixes
Fix form.key issues
2 parents db73b4e + dead8ab commit 3c5680a

7 files changed

+188
-260
lines changed

dist/angular-schema-form.js

+56-55
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-schema-form
33
* @version 1.0.0-alpha.5
4-
* @date Wed, 26 Apr 2017 14:49:08 GMT
4+
* @date Mon, 01 May 2017 08:39:39 GMT
55
* @link https://github.com/json-schema-form/angular-schema-form
66
* @license MIT
77
* Copyright (c) 2014-2017 JSON Schema Form
@@ -14,9 +14,9 @@
1414
/******/ function __webpack_require__(moduleId) {
1515
/******/
1616
/******/ // Check if module is in cache
17-
/******/ if(installedModules[moduleId])
17+
/******/ if(installedModules[moduleId]) {
1818
/******/ return installedModules[moduleId].exports;
19-
/******/
19+
/******/ }
2020
/******/ // Create a new module (and put it into the cache)
2121
/******/ var module = installedModules[moduleId] = {
2222
/******/ i: moduleId,
@@ -2729,33 +2729,34 @@ module.exports = __webpack_require__(4);
27292729
/***/ })
27302730
/******/ ]);
27312731
//# sourceMappingURL=json-schema-form-core.js.map
2732+
27322733
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(19).setImmediate))
27332734

27342735
/***/ }),
27352736
/* 2 */
27362737
/***/ (function(module, exports) {
27372738

2738-
var g;
2739-
2740-
// This works in non-strict mode
2741-
g = (function() {
2742-
return this;
2743-
})();
2744-
2745-
try {
2746-
// This works if eval is allowed (see CSP)
2747-
g = g || Function("return this")() || (1,eval)("this");
2748-
} catch(e) {
2749-
// This works if the window reference is available
2750-
if(typeof window === "object")
2751-
g = window;
2752-
}
2753-
2754-
// g can still be undefined, but nothing to do about it...
2755-
// We return undefined, instead of nothing here, so it's
2756-
// easier to handle this case. if(!global) { ...}
2757-
2758-
module.exports = g;
2739+
var g;
2740+
2741+
// This works in non-strict mode
2742+
g = (function() {
2743+
return this;
2744+
})();
2745+
2746+
try {
2747+
// This works if eval is allowed (see CSP)
2748+
g = g || Function("return this")() || (1,eval)("this");
2749+
} catch(e) {
2750+
// This works if the window reference is available
2751+
if(typeof window === "object")
2752+
g = window;
2753+
}
2754+
2755+
// g can still be undefined, but nothing to do about it...
2756+
// We return undefined, instead of nothing here, so it's
2757+
// easier to handle this case. if(!global) { ...}
2758+
2759+
module.exports = g;
27592760

27602761

27612762
/***/ }),
@@ -2842,7 +2843,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
28422843
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);
28432844

28442845

2845-
/* harmony default export */ __webpack_exports__["a"] = function (sfValidator, $parse, sfSelect, $interpolate) {
2846+
/* harmony default export */ __webpack_exports__["a"] = (function (sfValidator, $parse, sfSelect, $interpolate) {
28462847
return {
28472848
restrict: 'A',
28482849
scope: false,
@@ -3032,7 +3033,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
30323033
};
30333034
}
30343035
};
3035-
};
3036+
});
30363037

30373038
/***/ }),
30383039
/* 6 */
@@ -3048,7 +3049,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
30483049
/**
30493050
* Directive that handles the model arrays
30503051
*/
3051-
/* harmony default export */ __webpack_exports__["a"] = function (sfSelect, sfPath, schemaForm) {
3052+
/* harmony default export */ __webpack_exports__["a"] = (function (sfSelect, sfPath, schemaForm) {
30523053
return {
30533054
scope: true,
30543055
controller: ['$scope', function SFArrayController($scope) {
@@ -3279,7 +3280,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
32793280
};
32803281
}
32813282
};
3282-
};
3283+
});
32833284

32843285
/***/ }),
32853286
/* 7 */
@@ -3297,7 +3298,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
32973298
* Takes the form definition as argument.
32983299
* If the form definition has a "onChange" defined as either a function or
32993300
*/
3300-
/* harmony default export */ __webpack_exports__["a"] = function () {
3301+
/* harmony default export */ __webpack_exports__["a"] = (function () {
33013302
return {
33023303
require: 'ngModel',
33033304
restrict: 'AC',
@@ -3325,7 +3326,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
33253326
}
33263327
}
33273328
};
3328-
};
3329+
});
33293330

33303331
/***/ }),
33313332
/* 8 */
@@ -3338,7 +3339,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
33383339

33393340

33403341

3341-
/* harmony default export */ __webpack_exports__["a"] = function ($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage, sfPath, sfSelect) {
3342+
/* harmony default export */ __webpack_exports__["a"] = (function ($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage, sfPath, sfSelect) {
33423343

33433344
var keyFormat = {
33443345
COMPLETE: '*',
@@ -3383,17 +3384,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
33833384
if (scope.completeKey !== scope.form.key) {
33843385
if (typeof scope.$index === 'number') {
33853386
key = key.concat(scope.$index);
3386-
};
3387+
}
33873388

33883389
if (scope.form.key && scope.form.key.length) {
33893390
if (typeof key[key.length - 1] === 'number' && scope.form.key.length >= 1) {
33903391
var trim = scope.form.key.length - key.length;
3391-
scope.completeKey = key.concat(scope.form.key.slice(-trim));
3392+
scope.completeKey = trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
33923393
} else {
33933394
scope.completeKey = scope.form.key.slice();
3394-
};
3395-
};
3396-
};
3395+
}
3396+
}
3397+
}
33973398

33983399
// If there is no key then there's nothing to return
33993400
if (!Array.isArray(scope.completeKey)) {
@@ -3659,7 +3660,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
36593660
}
36603661
}
36613662
};
3662-
};
3663+
});
36633664

36643665
/***/ }),
36653666
/* 9 */
@@ -3669,7 +3670,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
36693670
/**
36703671
* Directive that handles keys and array indexes
36713672
*/
3672-
/* harmony default export */ __webpack_exports__["a"] = function (schemaForm, sfPath) {
3673+
/* harmony default export */ __webpack_exports__["a"] = (function (schemaForm, sfPath) {
36733674
return {
36743675
scope: true,
36753676
require: ['?^^sfNewArray'],
@@ -3698,7 +3699,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
36983699
}
36993700
}
37003701
};
3701-
};;
3702+
});;
37023703

37033704
/***/ }),
37043705
/* 10 */
@@ -3709,7 +3710,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
37093710
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);
37103711

37113712

3712-
/* harmony default export */ __webpack_exports__["a"] = function ($injector, sfErrorMessage) {
3713+
/* harmony default export */ __webpack_exports__["a"] = (function ($injector, sfErrorMessage) {
37133714

37143715
//Inject sanitizer if it exists
37153716
var $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : function (html) {
@@ -3802,7 +3803,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
38023803
});
38033804
}
38043805
};
3805-
};
3806+
});
38063807

38073808
/***/ }),
38083809
/* 11 */
@@ -3818,7 +3819,7 @@ FIXME: real documentation
38183819
<form sf-form="form" sf-schema="schema" sf-decorator="foobar"></form>
38193820
*/
38203821

3821-
/* harmony default export */ __webpack_exports__["a"] = function ($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators, sfSelect, sfPath, sfBuilder) {
3822+
/* harmony default export */ __webpack_exports__["a"] = (function ($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators, sfSelect, sfPath, sfBuilder) {
38223823

38233824
return {
38243825
scope: {
@@ -4032,7 +4033,7 @@ FIXME: real documentation
40324033
};
40334034
}
40344035
};
4035-
};
4036+
});
40364037

40374038
/***/ }),
40384039
/* 12 */
@@ -4043,7 +4044,7 @@ FIXME: real documentation
40434044
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);
40444045

40454046

4046-
/* harmony default export */ __webpack_exports__["a"] = function ($compileProvider, sfPathProvider) {
4047+
/* harmony default export */ __webpack_exports__["a"] = (function ($compileProvider, sfPathProvider) {
40474048
var defaultDecorator = '';
40484049
var decorators = {};
40494050

@@ -4463,11 +4464,11 @@ FIXME: real documentation
44634464
* @param {string} name directive name (CamelCased)
44644465
* @param {Object} fields, an object that maps "type" => `{ template, builder, replace}`.
44654466
attributes `builder` and `replace` are optional, and replace defaults to true.
4466-
`template` should be the key of the template to load and it should be pre-loaded
4467+
`template` should be the key of the template to load and it should be pre-loaded
44674468
in `$templateCache`.
4468-
`builder` can be a function or an array of functions. They will be called in
4469+
`builder` can be a function or an array of functions. They will be called in
44694470
the order they are supplied.
4470-
`replace` (DEPRECATED) is for backwards compatability. If false the builder
4471+
`replace` (DEPRECATED) is for backwards compatability. If false the builder
44714472
will use the "old" way of building that form field using a <sf-decorator>
44724473
directive.
44734474
*/
@@ -4575,7 +4576,7 @@ FIXME: real documentation
45754576

45764577
//Create a default directive
45774578
createDirective('sfDecorator');
4578-
};;
4579+
});;
45794580

45804581
/***/ }),
45814582
/* 13 */
@@ -4593,7 +4594,7 @@ FIXME: real documentation
45934594
/**
45944595
* Schema form service.
45954596
*/
4596-
/* harmony default export */ __webpack_exports__["a"] = function () {
4597+
/* harmony default export */ __webpack_exports__["a"] = (function () {
45974598
var postProcessFn = function postProcessFn(form) {
45984599
return form;
45994600
};
@@ -4714,7 +4715,7 @@ FIXME: real documentation
47144715

47154716
return service;
47164717
};
4717-
};
4718+
});
47184719

47194720
/***/ }),
47204721
/* 14 */
@@ -4723,7 +4724,7 @@ FIXME: real documentation
47234724
"use strict";
47244725

47254726
// FIXME: type template (using custom builder)
4726-
/* harmony default export */ __webpack_exports__["a"] = function (sfPathProvider) {
4727+
/* harmony default export */ __webpack_exports__["a"] = (function (sfPathProvider) {
47274728

47284729
var SNAKE_CASE_REGEXP = /[A-Z]/g;
47294730
var snakeCase = function snakeCase(name, separator) {
@@ -5042,7 +5043,7 @@ FIXME: real documentation
50425043
internalBuild: _build
50435044
};
50445045
}];
5045-
};
5046+
});
50465047

50475048
/***/ }),
50485049
/* 15 */
@@ -5053,7 +5054,7 @@ FIXME: real documentation
50535054
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);
50545055

50555056

5056-
/* harmony default export */ __webpack_exports__["a"] = function () {
5057+
/* harmony default export */ __webpack_exports__["a"] = (function () {
50575058

50585059
// The codes are tv4 error codes.
50595060
// Not all of these can actually happen in a field, but for
@@ -5179,7 +5180,7 @@ FIXME: real documentation
51795180

51805181
return service;
51815182
}];
5182-
};
5183+
});
51835184

51845185
/***/ }),
51855186
/* 16 */
@@ -5219,7 +5220,7 @@ var sfPathProviderClass = function () {
52195220
return sfPathProviderClass;
52205221
}();
52215222

5222-
/* harmony default export */ __webpack_exports__["a"] = sfPathProviderClass;
5223+
/* harmony default export */ __webpack_exports__["a"] = (sfPathProviderClass);
52235224

52245225
/***/ }),
52255226
/* 17 */

dist/angular-schema-form.min.js

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

karma.conf.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ module.exports = function(config) {
3434

3535
// test results reporter to use
3636
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
37-
reporters: ['dots','progress','coverage','growler'],
37+
reporters: ['mocha','coverage','growler'],
38+
39+
mochaReporter: {
40+
showDiff: true
41+
},
3842

3943
preprocessors: {
4044
'src/**/*.js': ['coverage']

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@
5151
"babel-polyfill": "^6.16.0",
5252
"babel-preset-es2015": "^6.18.0",
5353
"chai": "^3.5.0",
54+
"diff": "^3.2.0",
5455
"html-webpack-externals-plugin": "^2.1.2",
5556
"karma": "^1.3.0",
5657
"karma-babel-preprocessor": "^6.0.1",
5758
"karma-chai-sinon": "^0.1.5",
5859
"karma-coverage": "^1.1.1",
5960
"karma-growler-reporter": "0.0.1",
6061
"karma-mocha": "^1.3.0",
62+
"karma-mocha-reporter": "^2.2.3",
6163
"karma-phantomjs-launcher": "^1.0.2",
6264
"karma-webpack": "^1.8.0",
6365
"mocha": "^3.2.0",

src/directives/sf-field.directive.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ sfPath, sfSelect) {
4646
if(scope.completeKey !== scope.form.key) {
4747
if (typeof scope.$index === 'number') {
4848
key = key.concat(scope.$index);
49-
};
49+
}
5050

5151
if(scope.form.key && scope.form.key.length) {
5252
if(typeof key[key.length-1] === 'number' && scope.form.key.length >= 1) {
5353
let trim = scope.form.key.length - key.length;
54-
scope.completeKey = key.concat(scope.form.key.slice(-trim));
55-
}
56-
else {
54+
scope.completeKey =
55+
trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
56+
} else {
5757
scope.completeKey = scope.form.key.slice();
58-
};
59-
};
60-
};
58+
}
59+
}
60+
}
6161

6262
// If there is no key then there's nothing to return
6363
if(!Array.isArray(scope.completeKey)) {

0 commit comments

Comments
 (0)