選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

sidebar.controller.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Created by robin on 11/1/15.
  3. */
  4. angular.module('app')
  5. .controller('SideBarController', ['$scope', '$state', 'DataShareBusiness', '$mdDialog', '$mdSidenav',
  6. function($scope, $state, DataShareBusiness, $mdDialog, $mdSidenav) {
  7. $scope.DataShareBusiness = DataShareBusiness;
  8. $scope.Search = {
  9. value: "",
  10. selected: null
  11. };
  12. $scope.getStateName = function()
  13. {
  14. if ($state.current.name.length == 0) {
  15. return "home";
  16. }
  17. return $state.current.name;
  18. };
  19. $scope.getCurrentGroups = function()
  20. {
  21. if (DataShareBusiness.CurrentGroups.length != 0) {
  22. var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
  23. if (e[DataShareBusiness.EntitiesType] == null || e[DataShareBusiness.EntitiesType].length == 0) {
  24. return e.Parent[DataShareBusiness.EntitiesType];
  25. }
  26. return e[DataShareBusiness.EntitiesType];
  27. }
  28. return DataShareBusiness[DataShareBusiness.EntitiesType];
  29. };
  30. $scope.search = function()
  31. {
  32. var groups = [];
  33. function searchRec(group)
  34. {
  35. if (group.Name.toLowerCase().indexOf($scope.Search.value.toLowerCase()) > -1) {
  36. groups.push(group);
  37. }
  38. if (group[DataShareBusiness.EntitiesType] != null) {
  39. group[DataShareBusiness.EntitiesType].forEach(searchRec);
  40. }
  41. }
  42. DataShareBusiness[DataShareBusiness.EntitiesType].forEach(searchRec);
  43. return groups;
  44. };
  45. $scope.goTo = function(group)
  46. {
  47. if (group != null) {
  48. $mdSidenav('left').toggle();
  49. $scope.Search.value = "";
  50. DataShareBusiness.goToGroup(group);
  51. }
  52. };
  53. $scope.goToFirstMatch = function()
  54. {
  55. if ($scope.Search.value.length != 0) {
  56. var groups = $scope.search();
  57. if (groups.length > 0) {
  58. $scope.goTo(groups[0]);
  59. }
  60. }
  61. };
  62. $scope.isInState = function(state)
  63. {
  64. return $state.current.name == state;
  65. };
  66. }]);