do not require confirm action on destroyRecord from a modal for new non persisted records

This commit is contained in:
2018-05-31 20:36:55 -03:00
parent 466d67e14a
commit 1c285f8299
+14 -8
View File
@@ -118,14 +118,20 @@ export default Ember.Component.extend
if my_scope.get('router.globals.current_route.path')?.match("^#{flat_model_name}.show")
my_scope.get('router').transitionTo flat_model_name
@modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.are_you_sure'
model: @get('model')
ok: ->
model = @get("model")
model = model.get("_content") if model.__changeset__
model.destroyRecord().then -> destroy_callback.call(my_scope, model)
@send 'closeModal' unless @preventClose
if @get('model.isNew')
model = @get('model')
model = model.get("_content") if model.__changeset__
model.destroyRecord().then -> destroy_callback.call(my_scope, model)
@send 'closeModal' unless @preventClose
else
@modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.are_you_sure'
model: @get('model')
ok: ->
model = @get("model")
model = model.get("_content") if model.__changeset__
model.destroyRecord().then -> destroy_callback.call(my_scope, model)
@send 'closeModal' unless @preventClose
closeModal: ->
container = Ember.getOwner(@)