mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
When order cycle is updated, display message instead of reloading the page
This commit is contained in:
@@ -84,6 +84,7 @@ angular.module('admin.orderCycles')
|
||||
$scope.supplied_products = Enterprise.supplied_products
|
||||
$scope.enterprise_fees = EnterpriseFee.index(order_cycle_id: order_cycle_id)
|
||||
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.order_cycle = OrderCycle.load(order_cycle_id)
|
||||
|
||||
$scope.loaded = ->
|
||||
|
||||
@@ -4,6 +4,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
|
||||
|
||||
$scope.enterprises = Enterprise.index(order_cycle_id: $scope.orderCycleId())
|
||||
$scope.enterprise_fees = EnterpriseFee.index(order_cycle_id: $scope.orderCycleId())
|
||||
$scope.OrderCycle = OrderCycle
|
||||
$scope.order_cycle = OrderCycle.load $scope.orderCycleId(), (order_cycle) =>
|
||||
$scope.init()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window) ->
|
||||
angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window, $timeout) ->
|
||||
OrderCycle = $resource '/admin/order_cycles/:action_name/:order_cycle_id.json', {}, {
|
||||
'index': { method: 'GET', isArray: true}
|
||||
'new' : { method: 'GET', params: { action_name: "new" } }
|
||||
@@ -127,15 +127,18 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window) -
|
||||
oc = new OrderCycle({order_cycle: this.dataForSubmit()})
|
||||
oc.$create (data) ->
|
||||
if data['success']
|
||||
$window.location = destination
|
||||
$window.location = destination
|
||||
else
|
||||
console.log('Failed to create order cycle')
|
||||
|
||||
update: (destination) ->
|
||||
oc = new OrderCycle({order_cycle: this.dataForSubmit()})
|
||||
oc.$update {order_cycle_id: this.order_cycle.id}, (data) ->
|
||||
oc.$update {order_cycle_id: this.order_cycle.id}, (data) =>
|
||||
if data['success']
|
||||
$window.location = destination
|
||||
if destination?
|
||||
$window.location = destination
|
||||
else
|
||||
this.displayMessage 'Your order cycle has been updated.'
|
||||
else
|
||||
console.log('Failed to update order cycle')
|
||||
|
||||
@@ -200,4 +203,11 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window) -
|
||||
|
||||
for id, active of incoming.variants
|
||||
outgoing.variants[id] = active
|
||||
|
||||
displayMessage: (message) ->
|
||||
this.message = message
|
||||
$timeout =>
|
||||
this.message = null
|
||||
, 5000
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user