|
1 | 1 | /*!
|
2 | 2 | * angular-schema-form
|
3 | 3 | * @version 1.0.0-alpha.5
|
4 |
| - * @date Sun, 25 Jun 2017 09:09:24 GMT |
| 4 | + * @date Sun, 25 Jun 2017 11:12:48 GMT |
5 | 5 | * @link https://github.com/json-schema-form/angular-schema-form
|
6 | 6 | * @license MIT
|
7 | 7 | * Copyright (c) 2014-2017 JSON Schema Form
|
@@ -87,7 +87,7 @@ module.exports = angular;
|
87 | 87 | /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
|
88 | 88 | * json-schema-form-core
|
89 | 89 | * @version 1.0.0-alpha.5
|
90 |
| - * @date Sat, 24 Jun 2017 14:16:26 GMT |
| 90 | + * @date Sun, 25 Jun 2017 10:52:17 GMT |
91 | 91 | * @link https://github.com/json-schema-form/json-schema-form-core
|
92 | 92 | * @license MIT
|
93 | 93 | * Copyright (c) 2014-2017 JSON Schema Form
|
@@ -3239,10 +3239,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
3239 | 3239 | model.splice(index, 1);
|
3240 | 3240 | }
|
3241 | 3241 |
|
3242 |
| - if (item.$$hashKey) { |
3243 |
| - scope.destroyed = item.$$hashKey; |
3244 |
| - } |
3245 |
| - |
3246 | 3242 | return model;
|
3247 | 3243 | };
|
3248 | 3244 |
|
@@ -3638,36 +3634,42 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
3638 | 3634 | var destroyStrategy = form.destroyStrategy || scope.options && scope.options.destroyStrategy || 'remove';
|
3639 | 3635 | // No key no model, and we might have strategy 'retain'
|
3640 | 3636 | if (key && destroyStrategy !== 'retain') {
|
3641 |
| - // Get the object that has the property we wan't to clear. |
3642 |
| - var obj = scope.model; |
3643 |
| - if (key.length > 1) { |
3644 |
| - obj = sfSelect(key.slice(0, key.length - 1), obj); |
3645 |
| - } |
3646 |
| - |
3647 |
| - if (obj && scope.destroyed && obj.$$hashKey && obj.$$hashKey !== scope.destroyed) { |
3648 |
| - return; |
3649 |
| - } |
3650 |
| - |
3651 |
| - // We can get undefined here if the form hasn't been filled out entirely |
3652 |
| - if (obj === undefined) { |
3653 |
| - return; |
3654 |
| - } |
3655 | 3637 |
|
3656 | 3638 | // Type can also be a list in JSON Schema
|
3657 | 3639 | var type = form.schema && form.schema.type || '';
|
3658 | 3640 |
|
3659 | 3641 | // Empty means '',{} and [] for appropriate types and undefined for the rest
|
3660 |
| - // console.log('destroy', destroyStrategy, key, type, obj); |
3661 |
| - if (destroyStrategy === 'empty' && type.indexOf('string') !== -1) { |
3662 |
| - obj[key.slice(-1)] = ''; |
3663 |
| - } else if (destroyStrategy === 'empty' && type.indexOf('object') !== -1) { |
3664 |
| - obj[key.slice(-1)] = {}; |
3665 |
| - } else if (destroyStrategy === 'empty' && type.indexOf('array') !== -1) { |
3666 |
| - obj[key.slice(-1)] = []; |
| 3642 | + var value = void 0; |
| 3643 | + if (destroyStrategy === 'empty') { |
| 3644 | + value = type.indexOf('string') !== -1 ? '' : type.indexOf('object') !== -1 ? {} : type.indexOf('array') !== -1 ? [] : undefined; |
3667 | 3645 | } else if (destroyStrategy === 'null') {
|
3668 |
| - obj[key.slice(-1)] = null; |
| 3646 | + value = null; |
| 3647 | + } |
| 3648 | + |
| 3649 | + if (value !== undefined) { |
| 3650 | + sfSelect(key, scope.model, value); |
3669 | 3651 | } else {
|
3670 |
| - delete obj[key.slice(-1)]; |
| 3652 | + // Get the object parent object |
| 3653 | + var obj = scope.model; |
| 3654 | + if (key.length > 1) { |
| 3655 | + obj = sfSelect(key.slice(0, key.length - 1), obj); |
| 3656 | + } |
| 3657 | + |
| 3658 | + // parent can be undefined if the form hasn't been filled out |
| 3659 | + // entirely |
| 3660 | + if (obj === undefined) { |
| 3661 | + return; |
| 3662 | + } |
| 3663 | + |
| 3664 | + // if parent is an array, then we have already been removed. |
| 3665 | + // set flag to all children (who are about to recieve a $destroy |
| 3666 | + // event as well) that we have already been destroyed |
| 3667 | + if (__WEBPACK_IMPORTED_MODULE_0_angular___default.a.isArray(obj)) { |
| 3668 | + scope.externalDestructionInProgress = true; |
| 3669 | + return; |
| 3670 | + } |
| 3671 | + |
| 3672 | + delete obj[key[key.length - 1]]; |
3671 | 3673 | }
|
3672 | 3674 | }
|
3673 | 3675 | }
|
|
0 commit comments