@@ -168,41 +168,41 @@ function askForFieldsToRemove() {
168168 const context = this . context ;
169169 // prompt only if data is imported from a file
170170 if ( ! context . useConfigurationFile || context . updateEntity !== 'remove' || this . entityConfig . fields . length === 0 ) {
171- return undefined ;
171+ return undefined ;
172172 }
173-
173+
174174 const prompts = [
175- {
176- type : 'checkbox' ,
177- name : 'fieldsToRemove' ,
178- message : 'Please choose the fields you want to remove' ,
179- choices : ( ) =>
180- this . entityConfig . fields . map ( field => {
181- return { name : field . fieldName , value : field . fieldName } ;
182- } ) ,
183- } ,
184- {
185- when : response => response . fieldsToRemove . length !== 0 ,
186- type : 'confirm' ,
187- name : 'confirmRemove' ,
188- message : 'Are you sure to remove these fields?' ,
189- default : true ,
190- } ,
175+ {
176+ type : 'checkbox' ,
177+ name : 'fieldsToRemove' ,
178+ message : 'Please choose the fields you want to remove' ,
179+ choices : ( ) =>
180+ this . entityConfig . fields . map ( field => {
181+ return { name : field . fieldName , value : field . fieldName } ;
182+ } ) ,
183+ } ,
184+ {
185+ when : response => response . fieldsToRemove . length !== 0 ,
186+ type : 'confirm' ,
187+ name : 'confirmRemove' ,
188+ message : 'Are you sure to remove these fields?' ,
189+ default : true ,
190+ } ,
191191 ] ;
192192 return this . prompt ( prompts ) . then ( props => {
193- if ( props . confirmRemove ) {
194- this . log ( chalk . red ( `\nRemoving fields: ${ props . fieldsToRemove } \n` ) ) ;
195- const fields = this . entityConfig . fields ;
196- for ( let i = fields . length - 1 ; i >= 0 ; i -= 1 ) {
197- const field = this . entityConfig . fields [ i ] ;
198- if ( props . fieldsToRemove . filter ( val => val === field . fieldName ) . length > 0 ) {
199- fields . splice ( i , 1 ) ;
200- }
193+ if ( props . confirmRemove ) {
194+ this . log ( chalk . red ( `\nRemoving fields: ${ props . fieldsToRemove } \n` ) ) ;
195+ const fields = this . entityConfig . fields ;
196+ for ( let i = fields . length - 1 ; i >= 0 ; i -= 1 ) {
197+ const field = this . entityConfig . fields [ i ] ;
198+ if ( props . fieldsToRemove . filter ( val => val === field . fieldName ) . length > 0 ) {
199+ fields . splice ( i , 1 ) ;
200+ }
201+ }
202+ this . entityConfig . fields = fields ;
201203 }
202- this . entityConfig . fields = fields ;
203- }
204204 } ) ;
205- }
205+ }
206206
207207function askForRelationships ( ) {
208208 const context = this . context ;
@@ -223,44 +223,44 @@ function askForRelationsToRemove() {
223223 const context = this . context ;
224224 // prompt only if data is imported from a file
225225 if ( ! context . useConfigurationFile || context . updateEntity !== 'remove' || this . entityConfig . relationships . length === 0 ) {
226- return undefined ;
226+ return undefined ;
227227 }
228-
228+
229229 const prompts = [
230- {
231- type : 'checkbox' ,
232- name : 'relsToRemove' ,
233- message : 'Please choose the relationships you want to remove' ,
234- choices : ( ) =>
235- this . entityConfig . relationships . map ( rel => {
236- return {
237- name : `${ rel . relationshipName } :${ rel . relationshipType } ` ,
238- value : `${ rel . relationshipName } :${ rel . relationshipType } ` ,
239- } ;
240- } ) ,
241- } ,
242- {
243- when : response => response . relsToRemove . length !== 0 ,
244- type : 'confirm' ,
245- name : 'confirmRemove' ,
246- message : 'Are you sure to remove these relationships?' ,
247- default : true ,
248- } ,
230+ {
231+ type : 'checkbox' ,
232+ name : 'relsToRemove' ,
233+ message : 'Please choose the relationships you want to remove' ,
234+ choices : ( ) =>
235+ this . entityConfig . relationships . map ( rel => {
236+ return {
237+ name : `${ rel . relationshipName } :${ rel . relationshipType } ` ,
238+ value : `${ rel . relationshipName } :${ rel . relationshipType } ` ,
239+ } ;
240+ } ) ,
241+ } ,
242+ {
243+ when : response => response . relsToRemove . length !== 0 ,
244+ type : 'confirm' ,
245+ name : 'confirmRemove' ,
246+ message : 'Are you sure to remove these relationships?' ,
247+ default : true ,
248+ } ,
249249 ] ;
250250 return this . prompt ( prompts ) . then ( props => {
251- if ( props . confirmRemove ) {
252- this . log ( chalk . red ( `\nRemoving relationships: ${ props . relsToRemove } \n` ) ) ;
253- const relationships = this . entityConfig . relationships ;
254- for ( let i = relationships . length - 1 ; i >= 0 ; i -= 1 ) {
255- const rel = relationships [ i ] ;
256- if ( props . relsToRemove . filter ( val => val === `${ rel . relationshipName } :${ rel . relationshipType } ` ) . length > 0 ) {
257- relationships . splice ( i , 1 ) ;
258- }
251+ if ( props . confirmRemove ) {
252+ this . log ( chalk . red ( `\nRemoving relationships: ${ props . relsToRemove } \n` ) ) ;
253+ const relationships = this . entityConfig . relationships ;
254+ for ( let i = relationships . length - 1 ; i >= 0 ; i -= 1 ) {
255+ const rel = relationships [ i ] ;
256+ if ( props . relsToRemove . filter ( val => val === `${ rel . relationshipName } :${ rel . relationshipType } ` ) . length > 0 ) {
257+ relationships . splice ( i , 1 ) ;
258+ }
259+ }
260+ this . entityConfig . relationships = relationships ;
259261 }
260- this . entityConfig . relationships = relationships ;
261- }
262262 } ) ;
263- }
263+ }
264264
265265function askForTableName ( ) {
266266 const context = this . context ;
0 commit comments