@@ -123,7 +123,7 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) {
123123 checkFormulaImageFields ( ) {
124124 if ( this . formulaImageFields ) {
125125 this . columns . forEach ( ( col ) => {
126- if ( this . formulaImageFields . indexOf ( col . fieldName ) != - 1 ) {
126+ if ( this . formulaImageFields . indexOf ( col . fieldName ) !== - 1 ) {
127127 col . type = 'image' ;
128128 }
129129 } ) ;
@@ -136,7 +136,9 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) {
136136 this . updateDraftValues (
137137 {
138138 Id : dataReceived . context ,
139- [ dataReceived . fieldName ] : ( dataReceived . value ) ? dataReceived . value : null
139+ [ dataReceived . fieldName ] : dataReceived . value
140+ ? dataReceived . value
141+ : null
140142 } ,
141143 dataReceived . fieldName
142144 ) ;
@@ -156,22 +158,29 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) {
156158 }
157159 } ) ;
158160
159-
160161 if ( hasNewDraftValueRecord ) {
161162 this . draftValuesCustomDatatypes = [ ...copyDraftValuesCustomTypes ] ;
162- this . draftValuesCustomDatatypes = this . mergeDraftValues ( [ ...this . draftValues , ...this . draftValuesCustomDatatypes ] ) ;
163-
163+ this . draftValuesCustomDatatypes = this . mergeDraftValues ( [
164+ ...this . draftValues ,
165+ ...this . draftValuesCustomDatatypes
166+ ] ) ;
164167 } else {
165- this . draftValuesCustomDatatypes = [ ...copyDraftValuesCustomTypes , updateItem ] ;
168+ this . draftValuesCustomDatatypes = [
169+ ...copyDraftValuesCustomTypes ,
170+ updateItem
171+ ] ;
166172 }
167-
168- this . draftValues = this . mergeDraftValues ( [ ...this . template . querySelector ( 'c-extended-datatable' ) . draftValues , ...this . draftValuesCustomDatatypes ] ) ;
173+
174+ this . draftValues = this . mergeDraftValues ( [
175+ ...this . template . querySelector ( 'c-extended-datatable' ) . draftValues ,
176+ ...this . draftValuesCustomDatatypes
177+ ] ) ;
169178 }
170179
171180 mergeDraftValues ( arr ) {
172181 return arr . reduce ( ( merged , current ) => {
173- let found = merged . find ( val => val . Id === current . Id ) ;
174- if ( found ) {
182+ let found = merged . find ( ( val ) => val . Id === current . Id ) ;
183+ if ( found ) {
175184 // merge the current object with the existing object
176185 Object . assign ( found , current ) ;
177186 } else {
@@ -197,7 +206,10 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) {
197206 }
198207
199208 handleSave ( event ) {
200- const mergedValues = this . mergeDraftValues ( [ ...event . detail . draftValues , ...this . draftValuesCustomDatatypes ] ) ;
209+ const mergedValues = this . mergeDraftValues ( [
210+ ...event . detail . draftValues ,
211+ ...this . draftValuesCustomDatatypes
212+ ] ) ;
201213
202214 const recordInputs = mergedValues . slice ( ) . map ( ( draft ) => {
203215 const fields = Object . assign ( { } , draft ) ;
@@ -507,4 +519,4 @@ export default class LwcDatatable extends NavigationMixin(LightningElement) {
507519 } ) ;
508520 }
509521 }
510- }
522+ }
0 commit comments