mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Enterprise users can create tag rules
This commit is contained in:
@@ -1,7 +1,26 @@
|
||||
angular.module("admin.enterprises").controller "TagRulesCtrl", ($scope) ->
|
||||
$scope.groupedTagRules = $scope.Enterprise.tag_rules.reduce (groupedTagRules, rule) ->
|
||||
key = rule.preferred_customer_tags
|
||||
groupedTagRules[key] ||= []
|
||||
groupedTagRules[key].push rule
|
||||
groupedTagRules
|
||||
, {}
|
||||
$scope.tagGroups = $scope.Enterprise.tag_groups
|
||||
|
||||
updateRuleCounts = ->
|
||||
index = 0
|
||||
for tagGroup in $scope.tagGroups
|
||||
tagGroup.startIndex = index
|
||||
index = index + tagGroup.rules.length
|
||||
|
||||
updateRuleCounts()
|
||||
|
||||
$scope.updateTagsRulesFor = (tagGroup) ->
|
||||
for tagRule in tagGroup.rules
|
||||
tagRule.preferred_customer_tags = (tag.text for tag in tagGroup.tags).join(",")
|
||||
|
||||
$scope.addNewRuleTo = (tagGroup) ->
|
||||
tagGroup.rules.push
|
||||
id: null
|
||||
preferred_customer_tags: (tag.text for tag in tagGroup.tags).join(",")
|
||||
type: "TagRule::DiscountOrder"
|
||||
calculator:
|
||||
preferred_flat_percent: 0
|
||||
updateRuleCounts()
|
||||
|
||||
$scope.addNewTag = ->
|
||||
$scope.tagGroups.push { tags: [], rules: [] }
|
||||
|
||||
@@ -1 +1 @@
|
||||
angular.module("admin.enterprises", [
|
||||
angular.module("admin.enterprises", [
|
||||
Reference in New Issue
Block a user