mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
BOM: view information about max quantities ordered
This commit is contained in:
@@ -230,6 +230,11 @@ orderManagementModule.controller "AdminOrderMgmtCtrl", [
|
||||
sum = sum + lineItem.quantity * lineItem.units_variant.unit_value
|
||||
, 0
|
||||
|
||||
$scope.sumMaxUnitValues = ->
|
||||
sum = $scope.filteredLineItems.reduce (sum,lineItem) ->
|
||||
sum = sum + Math.max(lineItem.max_quantity,lineItem.quantity) * lineItem.units_variant.unit_value
|
||||
, 0
|
||||
|
||||
$scope.allUnitValuesPresent = ->
|
||||
for i,lineItem of $scope.filteredLineItems
|
||||
return false if !lineItem.units_variant.hasOwnProperty('unit_value') || !(lineItem.units_variant.unit_value > 0)
|
||||
@@ -262,12 +267,12 @@ orderManagementModule.controller "AdminOrderMgmtCtrl", [
|
||||
else
|
||||
''
|
||||
|
||||
$scope.fulfilled = ->
|
||||
$scope.fulfilled = (sumOfUnitValues) ->
|
||||
# A Units Variant is an API object which holds unit properies of a variant
|
||||
if $scope.selectedUnitsProduct.hasOwnProperty("group_buy_unit_size") && $scope.selectedUnitsProduct.group_buy_unit_size > 0 &&
|
||||
$scope.selectedUnitsProduct.hasOwnProperty("variant_unit") &&
|
||||
( $scope.selectedUnitsProduct.variant_unit == "weight" || $scope.selectedUnitsProduct.variant_unit == "volume" )
|
||||
Math.round( $scope.sumUnitValues() / $scope.selectedUnitsProduct.group_buy_unit_size * 1000)/1000
|
||||
Math.round( sumOfUnitValues / $scope.selectedUnitsProduct.group_buy_unit_size * 1000)/1000
|
||||
else
|
||||
''
|
||||
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
sharedDirectivesModule = angular.module("ofn.shared_directives", [])
|
||||
|
||||
sharedDirectivesModule.directive "datetimepicker", [
|
||||
"$parse"
|
||||
($parse) ->
|
||||
return (
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
element.datetimepicker
|
||||
dateFormat: "yy-mm-dd"
|
||||
timeFormat: "HH:mm:ss"
|
||||
stepMinute: 15
|
||||
onSelect: (dateText, inst) ->
|
||||
scope.$apply (scope) ->
|
||||
# Fires ngModel.$parsers
|
||||
ngModel.$setViewValue dateText
|
||||
)
|
||||
]
|
||||
sharedDirectivesModule.directive "datetimepicker", ->
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
element.datetimepicker
|
||||
dateFormat: "yy-mm-dd"
|
||||
timeFormat: "HH:mm:ss"
|
||||
stepMinute: 15
|
||||
onSelect: (dateText, inst) ->
|
||||
scope.$apply (scope) ->
|
||||
# Fires ngModel.$parsers
|
||||
ngModel.$setViewValue dateText
|
||||
|
||||
sharedDirectivesModule.directive "ofnSelect2MinSearch", [
|
||||
->
|
||||
|
||||
Reference in New Issue
Block a user