File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed
app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ define([
18
18
meta : { } ,
19
19
errorMessage : null ,
20
20
displayMetadata : true ,
21
+ initialValue : { } ,
21
22
messages : {
22
23
UNKOWN_ERROR : $t ( 'Sorry, there was an error getting requested content. ' +
23
24
'Please contact the store owner.' ) ,
@@ -48,12 +49,47 @@ define([
48
49
}
49
50
} ,
50
51
52
+ /**
53
+ * Invokes initialize method of parent class,
54
+ * contains initialization logic
55
+ */
56
+ initialize : function ( ) {
57
+ _ . bindAll ( this , 'reset' ) ;
58
+
59
+ this . _super ( )
60
+ . setInitialValue ( ) ;
61
+
62
+ return this ;
63
+ } ,
64
+
65
+ /**
66
+ * Sets initial value of the element and subscribes to it's changes.
67
+ *
68
+ * @returns {Abstract } Chainable.
69
+ */
70
+ setInitialValue : function ( ) {
71
+ if ( this . id ( ) ) {
72
+ this . initialValue ( false ) ;
73
+ }
74
+ return this ;
75
+ } ,
76
+
51
77
/**
52
78
* @inheritdoc
53
79
*/
54
80
initObservable : function ( ) {
55
81
return this . _super ( )
56
- . observe ( 'id meta errorMessage displayMetadata' ) ;
82
+ . observe ( 'id meta errorMessage displayMetadata initialValue' ) ;
83
+ } ,
84
+
85
+ /**
86
+ * Resets metadata
87
+ *
88
+ * @returns void
89
+ */
90
+ reset : function ( ) {
91
+ this . meta ( this . initialValue ( ) ) ;
92
+ this . errorMessage ( null ) ;
57
93
} ,
58
94
59
95
/**
@@ -100,6 +136,9 @@ define([
100
136
}
101
137
102
138
this . meta ( response ) ;
139
+ if ( this . initialValue ( ) === false ) {
140
+ this . initialValue ( response )
141
+ }
103
142
} . bind ( this ) )
104
143
. fail ( function ( ) {
105
144
this . meta ( { } ) ;
You can’t perform that action at this time.
0 commit comments