123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * Created by robin on 11/1/15.
- */
-
- angular.module('app')
- .controller('SideBarController', ['$scope', '$state', 'DataShareBusiness', '$mdDialog',
- function($scope, $state, DataShareBusiness, $mdDialog) {
-
- $scope.DataShareBusiness = DataShareBusiness;
-
- $scope.Search = {
- value: "",
- selected: null
- };
-
- $scope.getCurrentGroups = function()
- {
- if (DataShareBusiness.CurrentGroups.length != 0) {
- var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
- if (e.Groups == null || e.Groups.length == 0) {
- return e.Parent.Groups;
- }
- return e.Groups;
- }
- return DataShareBusiness.Groups;
- };
-
- $scope.search = function()
- {
- var groups = [];
- function searchRec(group)
- {
- if (group.Name.toLowerCase().indexOf($scope.Search.value.toLowerCase()) > -1) {
- groups.push(group);
- }
- if (group.Groups != null) {
- group.Groups.forEach(searchRec);
- }
- }
- DataShareBusiness.Groups.forEach(searchRec);
- return groups;
- };
-
- $scope.goTo = function(group)
- {
- if (group != null) {
- $scope.Search.value = "";
- DataShareBusiness.goToGroup(group);
- }
- };
-
- $scope.goToFirstMatch = function()
- {
- if ($scope.Search.value.length != 0) {
- var groups = $scope.search();
- if (groups.length > 0) {
- $scope.goTo(groups[0]);
- }
- }
- };
-
- $scope.isInState = function(state)
- {
- return $state.current.name == state;
- };
- }]);
|