Adding pause and unpause actions to standing orders

This commit is contained in:
Rob Harrington
2016-12-08 08:31:02 +11:00
parent 8ff9ffbc38
commit 8d1899b13d
4 changed files with 28 additions and 0 deletions

View File

@@ -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) =>

View File

@@ -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)

View File

@@ -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'}" }

View File

@@ -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: