mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Only show change warning for open order cycles
This commit is contained in:
@@ -9,10 +9,14 @@ angular.module("admin.orderCycles").directive "changeWarning", (ConfirmDialog) -
|
||||
msg = 'admin.order_cycles.date_warning.msg'
|
||||
options = { cancel: t(cancel), confirm: t(proceed) }
|
||||
|
||||
isOpen = (orderCycle) ->
|
||||
moment(orderCycle.orders_open_at, "YYYY-MM-DD HH:mm:SS Z").isBefore() &&
|
||||
moment(orderCycle.orders_close_at, "YYYY-MM-DD HH:mm:SS Z").isAfter()
|
||||
|
||||
element.focus ->
|
||||
count = scope.orderCycle.subscriptions_count
|
||||
return if acknowledged
|
||||
return if moment(scope.orderCycle.orders_close_at).isBefore()
|
||||
return unless isOpen(scope.orderCycle)
|
||||
return if count < 1
|
||||
ConfirmDialog.open('info', t(msg, n: count), options).then ->
|
||||
acknowledged = true
|
||||
|
||||
Reference in New Issue
Block a user