mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
Adding UI to require action from user when pausing/cancelling standing order with open orders
This commit is contained in:
@@ -30,14 +30,24 @@ angular.module("admin.standingOrders").factory 'StandingOrderPrototype', ($http,
|
||||
cancel: ->
|
||||
ConfirmDialog.open('error', t('admin.standing_orders.confirm_cancel_msg'), {cancel: t('back'), confirm: t('yes_i_am_sure')})
|
||||
.then =>
|
||||
@$cancel().then angular.noop, ->
|
||||
InfoDialog.open 'error', t('admin.standing_orders.cancel_failure_msg')
|
||||
@$cancel().then angular.noop, (response) =>
|
||||
if response.data?.errors?.open_orders?
|
||||
options = {cancel: t('admin.standing_orders.no_keep_them'), confirm: t('admin.standing_orders.yes_cancel_them')}
|
||||
ConfirmDialog.open('error', response.data.errors.open_orders, options)
|
||||
.then (=> @$cancel(open_orders: 'cancel')), (=> @$cancel(open_orders: 'keep'))
|
||||
else
|
||||
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')
|
||||
@$pause().then angular.noop, (response) =>
|
||||
if response.data?.errors?.open_orders?
|
||||
options = {cancel: t('admin.standing_orders.no_keep_them'), confirm: t('admin.standing_orders.yes_cancel_them')}
|
||||
ConfirmDialog.open('error', response.data.errors.open_orders, options)
|
||||
.then (=> @$pause(open_orders: 'cancel')), (=> @$pause(open_orders: 'keep'))
|
||||
else
|
||||
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')})
|
||||
|
||||
@@ -12,11 +12,13 @@ angular.module("admin.standingOrders").factory 'StandingOrderResource', ($resour
|
||||
params:
|
||||
id: '@id'
|
||||
action: 'cancel'
|
||||
open_orders: '@open_orders'
|
||||
'pause':
|
||||
method: 'PUT'
|
||||
params:
|
||||
id: '@id'
|
||||
action: 'pause'
|
||||
open_orders: '@open_orders'
|
||||
'unpause':
|
||||
method: 'PUT'
|
||||
params:
|
||||
|
||||
Reference in New Issue
Block a user