11/*!
22 * angular-schema-form-bootstrap
3- * @version 1.0.0-alpha.3
4- * @date Sun, 02 Apr 2017 13:11:20 GMT
3+ * @version 1.0.0-alpha.4
4+ * @date Mon, 03 Apr 2017 13:11:24 GMT
55 * @link https://github.com/json-schema-form/angular-schema-form-bootstrap
66 * @license MIT
77 * Copyright (c) 2014-2017 JSON Schema Form
@@ -175,7 +175,7 @@ module.exports = path;
175175/***/ function ( module , exports ) {
176176
177177var path = '/bootstrap/array.html' ;
178- var html = "<div class=\"schema-form-array {{::form.htmlClass + ' ' + idClass}}\"\r\n sf-field-model=\"sf-new-array\"\r\n sf-new-array>\r\n <label class=\"control-label\" ng-show=\"showTitle()\">{{ form.title }}</label>\r\n <ol class=\"list-group\" sf-field-model ui-sortable=\"form.sortOptions\">\r\n <li class=\"list-group-item {{::form.fieldHtmlClass}}\"\r\n sf-field-model=\"ng-repeat\"\r\n ng-repeat=\"item in $$value$$ track by $id(item)\">\r\n <button ng-hide=\"form.readonly || form.remove === null\"\r\n ng-click=\"deleteFromArray($index)\"\r\n ng-disabled=\"form.schema.minItems >= modelArray.length\"\r\n style=\"position: relative; z-index: 20;\"\r\n type=\"button\" class=\"close pull-right\">\r\n <span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span>\r\n </button>\r\n <div schema-form-array-items sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\"></div>\r\n </li>\r\n </ol>\r\n <div class=\"clearfix\" style=\"padding: 15px;\" ng-model=\"modelArray\" schema-validate=\"form\">\r\n <div class=\"help-block\"\r\n ng-show=\"(hasError() && errorMessage(schemaError())) || form.description\"\r\n ng-bind-html=\"(hasError() && errorMessage(schemaError())) || form.description\"></div>\r\n\r\n <button ng-hide=\"form.readonly || form.add === null\"\r\n ng-click=\"appendToArray()\"\r\n ng-disabled=\"form.schema.maxItems <= modelArray.length\"\r\n type=\"button\"\r\n class=\"btn {{ form.style.add || 'btn-default' }} pull-right\">\r\n <i class=\"glyphicon glyphicon-plus\"></i>\r\n {{ form.add || 'Add'}}\r\n </button>\r\n </div>\r\n</div>\r\n" ;
178+ var html = "<div class=\"schema-form-array {{::form.htmlClass + ' ' + idClass}}\"\r\n sf-field-model=\"sf-new-array\"\r\n sf-new-array>\r\n <label class=\"control-label\" ng-show=\"showTitle()\">{{ form.title }}</label>\r\n <ol class=\"list-group\" sf-field-model ui-sortable=\"form.sortOptions\">\r\n <li class=\"list-group-item {{::form.fieldHtmlClass}}\"\r\n sf-field-model=\"ng-repeat\"\r\n ng-repeat=\"item in $$value$$ track by $id(trackBy(item, $index))\">\r\n <button ng-hide=\"form.readonly || form.remove === null\"\r\n ng-click=\"deleteFromArray(item)\"\r\n ng-disabled=\"form.schema.minItems >= modelArray.length\"\r\n style=\"position: relative; z-index: 20;\"\r\n type=\"button\" class=\"close pull-right\">\r\n <span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span>\r\n </button>\r\n <div schema-form-array-items sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\"></div>\r\n </li>\r\n </ol>\r\n <div class=\"clearfix\" style=\"padding: 15px;\" ng-model=\"modelArray\" schema-validate=\"form\">\r\n <div class=\"help-block\"\r\n ng-show=\"(hasError() && errorMessage(schemaError())) || form.description\"\r\n ng-bind-html=\"(hasError() && errorMessage(schemaError())) || form.description\"></div>\r\n\r\n <button ng-hide=\"form.readonly || form.add === null\"\r\n ng-click=\"appendToArray()\"\r\n ng-disabled=\"form.schema.maxItems <= modelArray.length\"\r\n type=\"button\"\r\n class=\"btn {{ form.style.add || 'btn-default' }} pull-right\">\r\n <i class=\"glyphicon glyphicon-plus\"></i>\r\n {{ form.add || 'Add'}}\r\n </button>\r\n </div>\r\n</div>\r\n" ;
179179window . angular . module ( 'ng' ) . run ( [ '$templateCache' , function ( c ) { c . put ( path , html ) } ] ) ;
180180module . exports = path ;
181181
@@ -463,8 +463,8 @@ function bootstrapDecoratorConfig(
463463
464464/* WEBPACK VAR INJECTION */ ( function ( setImmediate , clearImmediate ) { /*!
465465 * angular-schema-form
466- * @version 1.0.0-alpha.3
467- * @date Sun, 02 Apr 2017 13:00:09 GMT
466+ * @version 1.0.0-alpha.4
467+ * @date Mon, 03 Apr 2017 12:57:49 GMT
468468 * @link https://github.com/json-schema-form/angular-schema-form
469469 * @license MIT
470470 * Copyright (c) 2014-2017 JSON Schema Form
@@ -534,7 +534,7 @@ function bootstrapDecoratorConfig(
534534/******/ __webpack_require__ . p = "" ;
535535/******/
536536/******/ // Load entry module and return exports
537- /******/ return __webpack_require__ ( __webpack_require__ . s = 21 ) ;
537+ /******/ return __webpack_require__ ( __webpack_require__ . s = 19 ) ;
538538/******/ } )
539539/************************************************************************/
540540/******/ ( [
@@ -3192,7 +3192,7 @@ module.exports = __webpack_require__(4);
31923192/***/ } )
31933193/******/ ] ) ;
31943194//# sourceMappingURL=json-schema-form-core.js.map
3195- /* WEBPACK VAR INJECTION */ } . call ( exports , __webpack_require__ ( 2 ) , __webpack_require__ ( 19 ) . setImmediate ) )
3195+ /* WEBPACK VAR INJECTION */ } . call ( exports , __webpack_require__ ( 2 ) , __webpack_require__ ( 18 ) . setImmediate ) )
31963196
31973197/***/ } ) ,
31983198/* 2 */
@@ -3222,8 +3222,7 @@ module.exports = g;
32223222
32233223
32243224/***/ } ) ,
3225- /* 3 */ ,
3226- /* 4 */
3225+ /* 3 */
32273226/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
32283227
32293228"use strict" ;
@@ -3232,18 +3231,18 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
32323231/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_json_schema_form_core___default = __webpack_require__ . n ( __WEBPACK_IMPORTED_MODULE_0_json_schema_form_core__ ) ;
32333232/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_angular__ = __webpack_require__ ( 0 ) ;
32343233/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_angular___default = __webpack_require__ . n ( __WEBPACK_IMPORTED_MODULE_1_angular__ ) ;
3235- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_sf_builder_provider__ = __webpack_require__ ( 14 ) ;
3236- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_schema_form_decorators_provider__ = __webpack_require__ ( 12 ) ;
3237- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_schema_form_provider__ = __webpack_require__ ( 13 ) ;
3238- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_sf_error_message_provider__ = __webpack_require__ ( 15 ) ;
3239- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_sf_path_provider__ = __webpack_require__ ( 16 ) ;
3240- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_sf_changed_directive__ = __webpack_require__ ( 7 ) ;
3241- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_sf_field_directive__ = __webpack_require__ ( 8 ) ;
3242- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_sf_message_directive__ = __webpack_require__ ( 10 ) ;
3243- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_sf_array_directive__ = __webpack_require__ ( 6 ) ;
3244- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_sf_key_directive__ = __webpack_require__ ( 9 ) ;
3245- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_sf_schema_directive__ = __webpack_require__ ( 11 ) ;
3246- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_schema_validate_directive__ = __webpack_require__ ( 5 ) ;
3234+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_sf_builder_provider__ = __webpack_require__ ( 13 ) ;
3235+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_schema_form_decorators_provider__ = __webpack_require__ ( 11 ) ;
3236+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_schema_form_provider__ = __webpack_require__ ( 12 ) ;
3237+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_sf_error_message_provider__ = __webpack_require__ ( 14 ) ;
3238+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_sf_path_provider__ = __webpack_require__ ( 15 ) ;
3239+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_sf_changed_directive__ = __webpack_require__ ( 6 ) ;
3240+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_sf_field_directive__ = __webpack_require__ ( 7 ) ;
3241+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_sf_message_directive__ = __webpack_require__ ( 9 ) ;
3242+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_sf_array_directive__ = __webpack_require__ ( 5 ) ;
3243+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_sf_key_directive__ = __webpack_require__ ( 8 ) ;
3244+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_sf_schema_directive__ = __webpack_require__ ( 10 ) ;
3245+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_schema_validate_directive__ = __webpack_require__ ( 4 ) ;
32473246
32483247
32493248
@@ -3297,7 +3296,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
32973296. directive ( 'sfChanged' , __WEBPACK_IMPORTED_MODULE_7_sf_changed_directive__ [ "a" /* default */ ] ) . directive ( 'sfField' , [ '$parse' , '$compile' , '$http' , '$templateCache' , '$interpolate' , '$q' , 'sfErrorMessage' , 'sfPath' , 'sfSelect' , __WEBPACK_IMPORTED_MODULE_8_sf_field_directive__ [ "a" /* default */ ] ] ) . directive ( 'sfMessage' , [ '$injector' , 'sfErrorMessage' , __WEBPACK_IMPORTED_MODULE_9_sf_message_directive__ [ "a" /* default */ ] ] ) . directive ( 'sfNewArray' , [ 'sfSelect' , 'sfPath' , 'schemaForm' , __WEBPACK_IMPORTED_MODULE_10_sf_array_directive__ [ "a" /* default */ ] ] ) . directive ( 'sfSchema' , [ '$compile' , '$http' , '$templateCache' , '$q' , 'schemaForm' , 'schemaFormDecorators' , 'sfSelect' , 'sfPath' , 'sfBuilder' , __WEBPACK_IMPORTED_MODULE_12_sf_schema_directive__ [ "a" /* default */ ] ] ) . directive ( 'schemaValidate' , [ 'sfValidator' , '$parse' , 'sfSelect' , __WEBPACK_IMPORTED_MODULE_13_schema_validate_directive__ [ "a" /* default */ ] ] ) . directive ( 'sfKeyController' , [ 'schemaForm' , 'sfPath' , __WEBPACK_IMPORTED_MODULE_11_sf_key_directive__ [ "a" /* default */ ] ] ) ;
32983297
32993298/***/ } ) ,
3300- /* 5 */
3299+ /* 4 */
33013300/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
33023301
33033302"use strict" ;
@@ -3487,12 +3486,14 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
34873486} ;
34883487
34893488/***/ } ) ,
3490- /* 6 */
3489+ /* 5 */
34913490/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
34923491
34933492"use strict" ;
34943493/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular__ = __webpack_require__ ( 0 ) ;
34953494/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__ . n ( __WEBPACK_IMPORTED_MODULE_0_angular__ ) ;
3495+ var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
3496+
34963497
34973498
34983499/**
@@ -3507,6 +3508,11 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
35073508 link : function link ( scope , element , attrs ) {
35083509 scope . min = 0 ;
35093510
3511+ scope . trackBy = function ( item , index ) {
3512+ if ( item && ( typeof item === 'undefined' ? 'undefined' : _typeof ( item ) ) === 'object' ) return item ;
3513+ return index ;
3514+ } ;
3515+
35103516 scope . modelArray = scope . $eval ( attrs . sfNewArray ) ;
35113517
35123518 // We need to have a ngModel to hook into validation. It doesn't really play well with
@@ -3664,11 +3670,17 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
36643670 return model ;
36653671 } ;
36663672
3667- scope . deleteFromArray = function ( index ) {
3673+ scope . deleteFromArray = function ( item ) {
3674+ var index = scope . modelArray . indexOf ( item ) ;
36683675 var model = scope . modelArray ;
36693676 if ( model ) {
36703677 model . splice ( index , 1 ) ;
36713678 }
3679+
3680+ if ( item . $$hashKey ) {
3681+ scope . destroyed = item . $$hashKey ;
3682+ }
3683+
36723684 return model ;
36733685 } ;
36743686
@@ -3718,7 +3730,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
37183730} ;
37193731
37203732/***/ } ) ,
3721- /* 7 */
3733+ /* 6 */
37223734/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
37233735
37243736"use strict" ;
@@ -3764,7 +3776,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
37643776} ;
37653777
37663778/***/ } ) ,
3767- /* 8 */
3779+ /* 7 */
37683780/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
37693781
37703782"use strict" ;
@@ -4049,9 +4061,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
40494061 // in the form definition.
40504062 scope . $on ( '$destroy' , function ( ) {
40514063 var key = scope . getKey ( ) ;
4064+ var arrayIndex = typeof scope . arrayIndex == 'number' ? scope . arrayIndex + 1 : 0 ;
40524065
40534066 // If the entire schema form is destroyed we don't touch the model
4054- if ( ! scope . externalDestructionInProgress ) {
4067+ if ( ! scope . externalDestructionInProgress && ( ! scope . model . $$hashKey || scope . model . $$hashKey === scope . destroyed ) ) {
40554068 var destroyStrategy = form . destroyStrategy || scope . options && scope . options . destroyStrategy || 'remove' ;
40564069 // No key no model, and we might have strategy 'retain'
40574070 if ( key && destroyStrategy !== 'retain' ) {
@@ -4093,7 +4106,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
40934106} ;
40944107
40954108/***/ } ) ,
4096- /* 9 */
4109+ /* 8 */
40974110/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
40984111
40994112"use strict" ;
@@ -4132,7 +4145,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
41324145} ; ;
41334146
41344147/***/ } ) ,
4135- /* 10 */
4148+ /* 9 */
41364149/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
41374150
41384151"use strict" ;
@@ -4236,7 +4249,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
42364249} ;
42374250
42384251/***/ } ) ,
4239- /* 11 */
4252+ /* 10 */
42404253/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
42414254
42424255"use strict" ;
@@ -4466,7 +4479,7 @@ FIXME: real documentation
44664479} ;
44674480
44684481/***/ } ) ,
4469- /* 12 */
4482+ /* 11 */
44704483/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
44714484
44724485"use strict" ;
@@ -5009,7 +5022,7 @@ FIXME: real documentation
50095022} ; ;
50105023
50115024/***/ } ) ,
5012- /* 13 */
5025+ /* 12 */
50135026/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
50145027
50155028"use strict" ;
@@ -5148,7 +5161,7 @@ FIXME: real documentation
51485161} ;
51495162
51505163/***/ } ) ,
5151- /* 14 */
5164+ /* 13 */
51525165/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
51535166
51545167"use strict" ;
@@ -5476,7 +5489,7 @@ FIXME: real documentation
54765489} ;
54775490
54785491/***/ } ) ,
5479- /* 15 */
5492+ /* 14 */
54805493/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
54815494
54825495"use strict" ;
@@ -5613,7 +5626,7 @@ FIXME: real documentation
56135626} ;
56145627
56155628/***/ } ) ,
5616- /* 16 */
5629+ /* 15 */
56175630/***/ ( function ( module , __webpack_exports__ , __webpack_require__ ) {
56185631
56195632"use strict" ;
@@ -5653,7 +5666,7 @@ var sfPathProviderClass = function () {
56535666/* harmony default export */ __webpack_exports__ [ "a" ] = sfPathProviderClass ;
56545667
56555668/***/ } ) ,
5656- /* 17 */
5669+ /* 16 */
56575670/***/ ( function ( module , exports ) {
56585671
56595672// shim for using process in browser
@@ -5839,7 +5852,7 @@ process.umask = function() { return 0; };
58395852
58405853
58415854/***/ } ) ,
5842- /* 18 */
5855+ /* 17 */
58435856/***/ ( function ( module , exports , __webpack_require__ ) {
58445857
58455858/* WEBPACK VAR INJECTION */ ( function ( global , process ) { ( function ( global , undefined ) {
@@ -6029,10 +6042,10 @@ process.umask = function() { return 0; };
60296042 attachTo . clearImmediate = clearImmediate ;
60306043} ( typeof self === "undefined" ? typeof global === "undefined" ? this : global : self ) ) ;
60316044
6032- /* WEBPACK VAR INJECTION */ } . call ( exports , __webpack_require__ ( 2 ) , __webpack_require__ ( 17 ) ) )
6045+ /* WEBPACK VAR INJECTION */ } . call ( exports , __webpack_require__ ( 2 ) , __webpack_require__ ( 16 ) ) )
60336046
60346047/***/ } ) ,
6035- /* 19 */
6048+ /* 18 */
60366049/***/ ( function ( module , exports , __webpack_require__ ) {
60376050
60386051var apply = Function . prototype . apply ;
@@ -6085,18 +6098,17 @@ exports._unrefActive = exports.active = function(item) {
60856098} ;
60866099
60876100// setimmediate attaches itself to the global object
6088- __webpack_require__ ( 18 ) ;
6101+ __webpack_require__ ( 17 ) ;
60896102exports . setImmediate = setImmediate ;
60906103exports . clearImmediate = clearImmediate ;
60916104
60926105
60936106/***/ } ) ,
6094- /* 20 */ ,
6095- /* 21 */
6107+ /* 19 */
60966108/***/ ( function ( module , exports , __webpack_require__ ) {
60976109
60986110__webpack_require__ ( 1 ) ;
6099- module . exports = __webpack_require__ ( 4 ) ;
6111+ module . exports = __webpack_require__ ( 3 ) ;
61006112
61016113
61026114/***/ } )
0 commit comments