You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sidebar.controller.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Created by robin on 11/1/15.
  3. */
  4. angular.module('app')
  5. .controller('SideBarController', ['$scope', '$state', 'DataShareBusiness', 'GroupsBusiness', '$location',
  6. function($scope, $state, DataShareBusiness, GroupsBusiness, $location) {
  7. $scope.DataShareBusiness = DataShareBusiness;
  8. $scope.getCurrentGroups = function()
  9. {
  10. if (DataShareBusiness.CurrentGroups.length != 0) {
  11. var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
  12. if (e.Groups == null || e.Groups.length == 0) {
  13. return e.Parent.Groups;
  14. }
  15. return e.Groups;
  16. }
  17. return DataShareBusiness.Groups;
  18. };
  19. $scope.$watch(function(){ return Object.keys($location.search())[0] }, function(){
  20. if (DataShareBusiness.Groups != null) {
  21. DataShareBusiness.setFromSearchString(Object.keys($location.search())[0]);
  22. }
  23. });
  24. var promiseLoadGroups = {
  25. id: "promiseLoadGroups",
  26. loaderGroups: ["sidebar", "toolbar"]
  27. };
  28. GroupsBusiness.loadAll(promiseLoadGroups).then(function(data)
  29. {
  30. $scope.groups = data;
  31. DataShareBusiness.setFromSearchString(Object.keys($location.search())[0]);
  32. });
  33. }]);