Enterprise users can create tag rules

This commit is contained in:
Rob Harrington
2016-03-11 15:56:54 +11:00
parent 066190c16f
commit 4c2552e0bf
15 changed files with 232 additions and 41 deletions

View File

@@ -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: [] }

View File

@@ -1 +1 @@
angular.module("admin.enterprises", [
angular.module("admin.enterprises", [