Mercurial > hg > isophonics-drupal-site
comparison core/modules/quickedit/js/models/EntityModel.es6.js @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
187 case 'opened': | 187 case 'opened': |
188 // The entity is now ready for editing! | 188 // The entity is now ready for editing! |
189 this.set('isActive', true); | 189 this.set('isActive', true); |
190 break; | 190 break; |
191 | 191 |
192 case 'committing': | 192 case 'committing': { |
193 // The user indicated they want to save the entity. | 193 // The user indicated they want to save the entity. |
194 var fields = this.get('fields'); | 194 const fields = this.get('fields'); |
195 // For fields that are in an active state, transition them to | 195 // For fields that are in an active state, transition them to |
196 // candidate. | 196 // candidate. |
197 fields.chain() | 197 fields.chain() |
198 .filter(fieldModel => _.intersection([fieldModel.get('state')], ['active']).length) | 198 .filter(fieldModel => _.intersection([fieldModel.get('state')], ['active']).length) |
199 .each((fieldModel) => { | 199 .each((fieldModel) => { |
205 .filter(fieldModel => _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length) | 205 .filter(fieldModel => _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length) |
206 .each((fieldModel) => { | 206 .each((fieldModel) => { |
207 fieldModel.set('state', 'saving'); | 207 fieldModel.set('state', 'saving'); |
208 }); | 208 }); |
209 break; | 209 break; |
210 | 210 } |
211 case 'deactivating': | 211 |
212 var changedFields = this.get('fields') | 212 case 'deactivating': { |
213 const changedFields = this.get('fields') | |
213 .filter(fieldModel => _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length); | 214 .filter(fieldModel => _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length); |
214 // If the entity contains unconfirmed or unsaved changes, return the | 215 // If the entity contains unconfirmed or unsaved changes, return the |
215 // entity to an opened state and ask the user if they would like to | 216 // entity to an opened state and ask the user if they would like to |
216 // save the changes or discard the changes. | 217 // save the changes or discard the changes. |
217 // 1. One of the fields is in a changed state. The changed field | 218 // 1. One of the fields is in a changed state. The changed field |
248 fieldModel.set('state', 'candidate', options); | 249 fieldModel.set('state', 'candidate', options); |
249 } | 250 } |
250 }); | 251 }); |
251 } | 252 } |
252 break; | 253 break; |
254 } | |
253 | 255 |
254 case 'closing': | 256 case 'closing': |
255 // Set all fields to the 'inactive' state. | 257 // Set all fields to the 'inactive' state. |
256 options.reason = 'stop'; | 258 options.reason = 'stop'; |
257 this.get('fields').each((fieldModel) => { | 259 this.get('fields').each((fieldModel) => { |
362 else { | 364 else { |
363 this._updateInTempStoreAttributes(entityModel, fieldModel); | 365 this._updateInTempStoreAttributes(entityModel, fieldModel); |
364 } | 366 } |
365 break; | 367 break; |
366 | 368 |
367 case 'committing': | 369 case 'committing': { |
368 // If the field save returned a validation error, set the state of the | 370 // If the field save returned a validation error, set the state of the |
369 // entity back to 'opened'. | 371 // entity back to 'opened'. |
370 if (fieldState === 'invalid') { | 372 if (fieldState === 'invalid') { |
371 // A state change in reaction to another state change must be | 373 // A state change in reaction to another state change must be |
372 // deferred. | 374 // deferred. |
378 this._updateInTempStoreAttributes(entityModel, fieldModel); | 380 this._updateInTempStoreAttributes(entityModel, fieldModel); |
379 } | 381 } |
380 | 382 |
381 // Attempt to save the entity. If the entity's fields are not yet all | 383 // Attempt to save the entity. If the entity's fields are not yet all |
382 // in a ready state, the save will not be processed. | 384 // in a ready state, the save will not be processed. |
383 var options = { | 385 const options = { |
384 'accept-field-states': Drupal.quickedit.app.readyFieldStates, | 386 'accept-field-states': Drupal.quickedit.app.readyFieldStates, |
385 }; | 387 }; |
386 if (entityModel.set('isCommitting', true, options)) { | 388 if (entityModel.set('isCommitting', true, options)) { |
387 entityModel.save({ | 389 entityModel.save({ |
388 success() { | 390 success() { |
402 Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message); | 404 Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message); |
403 }, | 405 }, |
404 }); | 406 }); |
405 } | 407 } |
406 break; | 408 break; |
409 } | |
407 | 410 |
408 case 'deactivating': | 411 case 'deactivating': |
409 // When setting the entity to 'closing', require that all fieldModels | 412 // When setting the entity to 'closing', require that all fieldModels |
410 // are in either the 'candidate' or 'highlighted' state. | 413 // are in either the 'candidate' or 'highlighted' state. |
411 // A state change in reaction to another state change must be | 414 // A state change in reaction to another state change must be |