@@ -10,21 +10,6 @@ define([
10
10
] , function ( DynamicRows , _ , utils ) {
11
11
'use strict' ;
12
12
13
- var maxId = 0 ,
14
-
15
- /**
16
- * Stores max option_id value of the options from recordData once on initialization
17
- * @param {Array } data - array with records data
18
- */
19
- initMaxId = function ( data ) {
20
- if ( data && data . length ) {
21
- maxId = _ . max ( data , function ( record ) {
22
- return parseInt ( record [ 'option_id' ] , 10 ) || 0 ;
23
- } ) [ 'option_id' ] ;
24
- maxId = parseInt ( maxId , 10 ) || 0 ;
25
- }
26
- } ;
27
-
28
13
return DynamicRows . extend ( {
29
14
defaults : {
30
15
mappingSettings : {
@@ -39,14 +24,6 @@ define([
39
24
identificationDRProperty : 'option_id'
40
25
} ,
41
26
42
- /** @inheritdoc */
43
- initialize : function ( ) {
44
- this . _super ( ) ;
45
- initMaxId ( this . recordData ( ) ) ;
46
-
47
- return this ;
48
- } ,
49
-
50
27
/** @inheritdoc */
51
28
processingInsertData : function ( data ) {
52
29
var options = [ ] ,
@@ -65,7 +42,16 @@ define([
65
42
if ( currentOption . hasOwnProperty ( 'sort_order' ) ) {
66
43
delete currentOption [ 'sort_order' ] ;
67
44
}
68
- currentOption [ 'option_id' ] = ++ maxId ;
45
+ if ( currentOption . hasOwnProperty ( 'option_id' ) ) {
46
+ delete currentOption [ 'option_id' ] ;
47
+ }
48
+ if ( currentOption . values . length > 0 ) {
49
+ currentOption . values . each ( function ( optionValue ) {
50
+ delete optionValue [ 'option_id' ] ;
51
+ delete optionValue [ 'option_type_id' ] ;
52
+ } )
53
+ }
54
+
69
55
options . push ( currentOption ) ;
70
56
} ) ;
71
57
} ) ;
@@ -90,9 +76,7 @@ define([
90
76
91
77
/** @inheritdoc */
92
78
processingAddChild : function ( ctx , index , prop ) {
93
- if ( ctx && ! _ . isNumber ( ctx [ 'option_id' ] ) ) {
94
- ctx [ 'option_id' ] = ++ maxId ;
95
- } else if ( ! ctx ) {
79
+ if ( ! ctx ) {
96
80
this . showSpinner ( true ) ;
97
81
this . addChild ( ctx , index , prop ) ;
98
82
0 commit comments