mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make side menu item visibility declarative
This commit is contained in:
@@ -44,25 +44,3 @@ angular.module("admin.enterprises")
|
||||
count++ if shipping_method.selected
|
||||
count
|
||||
, 0
|
||||
|
||||
$scope.$watch "Enterprise.is_primary_producer", (newValue, oldValue) ->
|
||||
if !newValue && $scope.Enterprise.sells == "none"
|
||||
$scope.menu.hide_item_by_name('Enterprise Fees')
|
||||
else
|
||||
$scope.menu.show_item_by_name('Enterprise Fees')
|
||||
|
||||
|
||||
$scope.$watch "Enterprise.sells", (newValue, oldValue) ->
|
||||
if newValue == "none"
|
||||
$scope.menu.hide_item_by_name('Shipping Methods')
|
||||
$scope.menu.hide_item_by_name('Payment Methods')
|
||||
$scope.menu.hide_item_by_name('Shop Preferences')
|
||||
if $scope.Enterprise.is_primary_producer
|
||||
$scope.menu.show_item_by_name('Enterprise Fees')
|
||||
else
|
||||
$scope.menu.hide_item_by_name('Enterprise Fees')
|
||||
else
|
||||
$scope.menu.show_item_by_name('Shipping Methods')
|
||||
$scope.menu.show_item_by_name('Payment Methods')
|
||||
$scope.menu.show_item_by_name('Shop Preferences')
|
||||
$scope.menu.show_item_by_name('Enterprise Fees')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.enterprises")
|
||||
.controller "sideMenuCtrl", ($scope, Enterprise, SideMenu) ->
|
||||
.controller "sideMenuCtrl", ($scope, $parse, Enterprise, SideMenu) ->
|
||||
$scope.Enterprise = Enterprise.enterprise
|
||||
$scope.menu = SideMenu
|
||||
$scope.select = SideMenu.select
|
||||
@@ -12,10 +12,23 @@ angular.module("admin.enterprises")
|
||||
{ name: 'About', icon_class: "icon-pencil" }
|
||||
{ name: 'Business Details', icon_class: "icon-briefcase" }
|
||||
{ name: 'Images', icon_class: "icon-picture" }
|
||||
{ name: "Shipping Methods", icon_class: "icon-truck" }
|
||||
{ name: "Payment Methods", icon_class: "icon-money" }
|
||||
{ name: "Enterprise Fees", icon_class: "icon-tasks" }
|
||||
{ name: "Shop Preferences", icon_class: "icon-shopping-cart" }
|
||||
{ name: "Shipping Methods", icon_class: "icon-truck", show: "showExtraPrefs()" }
|
||||
{ name: "Payment Methods", icon_class: "icon-money", show: "showExtraPrefs()" }
|
||||
{ name: "Enterprise Fees", icon_class: "icon-tasks", show: "showEnterpriseFees()" }
|
||||
{ name: "Shop Preferences", icon_class: "icon-shopping-cart", show: "showExtraPrefs()" }
|
||||
]
|
||||
|
||||
$scope.select(0)
|
||||
|
||||
|
||||
$scope.showItem = (item) ->
|
||||
if item.show?
|
||||
$parse(item.show)($scope)
|
||||
else
|
||||
true
|
||||
|
||||
$scope.showExtraPrefs = ->
|
||||
$scope.Enterprise.sells != "none"
|
||||
|
||||
$scope.showEnterpriseFees = ->
|
||||
$scope.Enterprise.sells != "none" || $scope.Enterprise.is_primary_producer
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
%a.menu_item{ href: "", id: "{{ item.name.toLowerCase().replace(' ', '_') }}",
|
||||
ng: { repeat: '(index,item) in menu.items | filter:{visible:true}',
|
||||
click: 'select(index)',
|
||||
show: 'showItem(item)',
|
||||
class: '{ selected: item.selected}',
|
||||
'class-odd' => "'odd'",
|
||||
'class-even' => "'even'" } }
|
||||
%i{ class: "{{item.icon_class}}" }
|
||||
%span {{ item.name }}
|
||||
%span {{ item.name }}
|
||||
|
||||
Reference in New Issue
Block a user