diff --git a/app/assets/javascripts/admin/standing_orders/services/standing_order_prototype.js.coffee b/app/assets/javascripts/admin/standing_orders/services/standing_order_prototype.js.coffee index f3e1cb3f4f..231be61165 100644 --- a/app/assets/javascripts/admin/standing_orders/services/standing_order_prototype.js.coffee +++ b/app/assets/javascripts/admin/standing_orders/services/standing_order_prototype.js.coffee @@ -41,6 +41,18 @@ angular.module("admin.standingOrders").factory 'StandingOrderPrototype', ($http, , -> InfoDialog.open 'error', t('admin.standing_orders.cancel_failure_msg') + pause: -> + ConfirmDialog.open('error', t('admin.standing_orders.confirm_pause_msg'), {confirm: t('yes_i_am_sure')}) + .then => + @$pause().then angular.noop, -> + InfoDialog.open 'error', t('admin.standing_orders.pause_failure_msg') + + unpause: -> + ConfirmDialog.open('error', t('admin.standing_orders.confirm_unpause_msg'), {confirm: t('yes_i_am_sure')}) + .then => + @$unpause().then angular.noop, -> + InfoDialog.open 'error', t('admin.standing_orders.unpause_failure_msg') + cancelOrder: (order) -> if order.id? $http.put("/admin/standing_order_orders/#{order.id}/cancel").then (response) => diff --git a/app/assets/javascripts/admin/standing_orders/services/standing_order_resource.js.coffee b/app/assets/javascripts/admin/standing_orders/services/standing_order_resource.js.coffee index 9b7a164fd9..1bc1c3a42f 100644 --- a/app/assets/javascripts/admin/standing_orders/services/standing_order_resource.js.coffee +++ b/app/assets/javascripts/admin/standing_orders/services/standing_order_resource.js.coffee @@ -12,6 +12,16 @@ angular.module("admin.standingOrders").factory 'StandingOrderResource', ($resour params: id: '@id' action: 'cancel' + 'pause': + method: 'PUT' + params: + id: '@id' + action: 'pause' + 'unpause': + method: 'PUT' + params: + id: '@id' + action: 'unpause' }) angular.extend(resource.prototype, StandingOrderPrototype) diff --git a/app/views/admin/standing_orders/_table.html.haml b/app/views/admin/standing_orders/_table.html.haml index 9d940f4ab4..4a97fb9cc4 100644 --- a/app/views/admin/standing_orders/_table.html.haml +++ b/app/views/admin/standing_orders/_table.html.haml @@ -47,6 +47,8 @@ %td.shipping_method{ ng: { show: 'columns.shipping_method.visible', bind: '::shippingMethodsByID[standingOrder.shipping_method_id].name' } } %td.actions %a.edit-standing-order.icon-edit.no-text{ ng: { href: '{{standingOrder.edit_path}}'} } + %a.pause-standing-order.icon-pause.no-text{ ng: { click: 'standingOrder.pause()', hide: '!!standingOrder.paused_at' } } + %a.unpause-standing-order.icon-play.no-text{ ng: { click: 'standingOrder.unpause()', show: '!!standingOrder.paused_at' } } %a.cancel-standing-order.icon-remove.no-text{ ng: { click: 'standingOrder.cancel()'} } %tr.panel-row{ object: "standingOrder", panels: "{products: 'standing_order_products', orders: 'standing_order_orders'}" } diff --git a/config/locales/en.yml b/config/locales/en.yml index ece02644b7..3df677c212 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -814,6 +814,10 @@ en: status: Status confirm_cancel_msg: Are you sure you want to cancel this standing order? This action cannot be undone. cancel_failure_msg: 'Sorry, cancellation failed!'
 + confirm_pause_msg: Are you sure you want to pause this standing order? + pause_failure_msg: 'Sorry, pausing failed!' + confirm_unpause_msg: Are you sure you want to unpause this standing order? + unpause_failure_msg: 'Sorry, unpausing failed!' stripe_connect_settings: edit: