mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-07 22:46:06 +00:00
Moving angularjs tag rule logic into its own module
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
//= require ./products/products
|
||||
//= require ./shipping_methods/shipping_methods
|
||||
//= require ./side_menu/side_menu
|
||||
//= require ./tag_rules/tag_rules
|
||||
//= require ./taxons/taxons
|
||||
//= require ./utils/utils
|
||||
//= require ./users/users
|
||||
|
||||
@@ -1 +1 @@
|
||||
angular.module("admin.enterprises", [
|
||||
angular.module("admin.enterprises", [
|
||||
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.enterprises").controller "TagRulesCtrl", ($scope, $http) ->
|
||||
$scope.tagGroups = $scope.Enterprise.tag_groups
|
||||
angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, enterprise) ->
|
||||
$scope.tagGroups = enterprise.tag_groups
|
||||
|
||||
updateRuleCounts = ->
|
||||
index = 0
|
||||
@@ -35,7 +35,7 @@ angular.module("admin.enterprises").controller "TagRulesCtrl", ($scope, $http) -
|
||||
if confirm("Are you sure?")
|
||||
$http
|
||||
method: "DELETE"
|
||||
url: "/admin/enterprises/#{$scope.Enterprise.id}/tag_rules/#{tagRule.id}.json"
|
||||
url: "/admin/enterprises/#{enterprise.id}/tag_rules/#{tagRule.id}.json"
|
||||
.success ->
|
||||
tagGroup.rules.splice(index, 1)
|
||||
updateRuleCounts()
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module("admin.enterprises").directive "invertNumber", ->
|
||||
angular.module("admin.tagRules").directive "invertNumber", ->
|
||||
restrict: "A"
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module("admin.enterprises").directive "discountOrder", ->
|
||||
angular.module("admin.tagRules").directive "discountOrder", ->
|
||||
restrict: "E"
|
||||
replace: true
|
||||
templateUrl: "admin/tag_rules/discount_order.html"
|
||||
@@ -0,0 +1 @@
|
||||
angular.module("admin.tagRules", ['ngTagsInput'])
|
||||
@@ -4,7 +4,7 @@ describe "TagRulesCtrl", ->
|
||||
enterprise = null
|
||||
|
||||
beforeEach ->
|
||||
module('admin.enterprises')
|
||||
module('admin.tagRules')
|
||||
enterprise =
|
||||
id: 45
|
||||
tag_groups: [
|
||||
@@ -14,8 +14,7 @@ describe "TagRulesCtrl", ->
|
||||
|
||||
inject ($rootScope, $controller) ->
|
||||
scope = $rootScope
|
||||
scope.Enterprise = enterprise
|
||||
ctrl = $controller 'TagRulesCtrl', {$scope: scope}
|
||||
ctrl = $controller 'TagRulesCtrl', {$scope: scope, enterprise: enterprise}
|
||||
|
||||
describe "tagGroup start indices", ->
|
||||
it "updates on initialization", ->
|
||||
Reference in New Issue
Block a user