From 374b4315f0568e45019d4af177d88926d791c429 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 2 Sep 2013 21:00:08 +0200 Subject: [PATCH] Moved to build in confirm dialog. --- .../_application_controller_generic.js.coffee | 25 ++++++++++++++++++- test/browser/manage_test.rb | 4 +-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 530565c56..8acc101d1 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -167,7 +167,9 @@ class App.ControllerGenericIndex extends App.ControllerContent destroy: (e) -> item = $(e.target).item( App[ @genericObject ] ) - item.destroy() if confirm('Sure?') + new DestroyConfirm( + item: item + ) new: (e) -> e.preventDefault() @@ -176,6 +178,27 @@ class App.ControllerGenericIndex extends App.ControllerContent genericObject: @genericObject ) +class DestroyConfirm extends App.ControllerModal + constructor: -> + super + @render() + + render: -> + @html App.view('modal')( + title: 'Confirm' + message: 'Sure to delete this object?' + cancel: true + button: 'Yes' + ) + @modalShow( + backdrop: true, + keyboard: true, + ) + + submit: (e) => + @modalHide() + @item.destroy() + class App.ControllerLevel2 extends App.ControllerContent events: 'click [data-toggle="tabnav"]': 'toggle', diff --git a/test/browser/manage_test.rb b/test/browser/manage_test.rb index 682abbea6..4699a7f8d 100644 --- a/test/browser/manage_test.rb +++ b/test/browser/manage_test.rb @@ -184,8 +184,8 @@ class ManageTest < TestCase :value => 2, }, { - :execute => 'accept', - :element => :alert, + :execute => 'click', + :css => '.modal .submit', }, { :execute => 'wait',