mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Refactor and additional permissions checks
Don't include non-permitted enterprises in existin product count Tweaked feedback
This commit is contained in:
committed by
Rob Harrington
parent
91fc3f33a0
commit
cc5a335fb7
@@ -1,15 +1,15 @@
|
||||
angular.module("ofn.admin").controller "ImportOptionsFormCtrl", ($scope, $timeout, $rootScope, ProductImportService) ->
|
||||
angular.module("ofn.admin").controller "ImportOptionsFormCtrl", ($scope, $rootScope, ProductImportService) ->
|
||||
|
||||
$scope.toggleResetAbsent = () ->
|
||||
confirmed = confirm 'This will set stock level to zero on all products for this \n' +
|
||||
'enterprise that are not present in the uploaded file.' if $scope.resetAbsent
|
||||
|
||||
if confirmed or !$scope.resetAbsent
|
||||
ProductImportService.updateResetAbsent($scope.supplierId, $scope.nonUpdated, $scope.resetAbsent)
|
||||
ProductImportService.updateResetAbsent($scope.supplierId, $scope.resetCount, $scope.resetAbsent)
|
||||
else
|
||||
$scope.resetAbsent = false
|
||||
|
||||
$scope.resetCount = ProductImportService.resetCount
|
||||
$scope.resetTotal = ProductImportService.resetTotal
|
||||
|
||||
$rootScope.$watch 'resetCount', (newValue) ->
|
||||
$scope.resetCount = newValue if newValue || newValue == 0
|
||||
$rootScope.$watch 'resetTotal', (newValue) ->
|
||||
$scope.resetTotal = newValue if newValue || newValue == 0
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
angular.module("ofn.admin").factory "ProductImportService", ($rootScope, $timeout) ->
|
||||
angular.module("ofn.admin").factory "ProductImportService", ($rootScope) ->
|
||||
new class ProductImportService
|
||||
suppliers: {}
|
||||
resetCount: 0
|
||||
resetTotal: 0
|
||||
|
||||
updateResetAbsent: (supplierId, nonUpdated, resetAbsent) ->
|
||||
updateResetAbsent: (supplierId, resetCount, resetAbsent) ->
|
||||
if resetAbsent
|
||||
@suppliers[supplierId] = nonUpdated
|
||||
@resetCount += nonUpdated
|
||||
@suppliers[supplierId] = resetCount
|
||||
@resetTotal += resetCount
|
||||
else
|
||||
@suppliers[supplierId] = null
|
||||
@resetCount -= nonUpdated
|
||||
@resetTotal -= resetCount
|
||||
|
||||
$rootScope.resetCount = @resetCount
|
||||
$rootScope.resetTotal = @resetTotal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user