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.

home.controller.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. angular.module('app')
  2. .controller('HomeController', ['$scope', '$state', 'DataShareBusiness', 'WeeksBusiness',
  3. function($scope, $state, DataShareBusiness, WeeksBusiness) {
  4. $scope.DataShareBusiness = DataShareBusiness;
  5. $scope.courses = null;
  6. $scope.days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
  7. $scope.getSheetCount = function()
  8. {
  9. var sheetCount = function(group)
  10. {
  11. var c = (group.Groups == null || group.Groups.length == 0) ? 1 : 0;
  12. if (group.Groups != null) {
  13. group.Groups.forEach(function (group) {
  14. c += sheetCount(group);
  15. });
  16. }
  17. return c;
  18. };
  19. return sheetCount(DataShareBusiness.getCurrentGroupOrRoot())
  20. };
  21. $scope.$watch(function(){return DataShareBusiness.CurrentGroups}, function()
  22. {
  23. var group = DataShareBusiness.getCurrentGroup();
  24. if (group != null && $scope.getSheetCount() < 5) {
  25. var promiseLoadCourses = {
  26. id: "promiseLoadCourses",
  27. groups: ["coursesView"]
  28. };
  29. WeeksBusiness.getCurrentWeek({group_id: group.Id, type_id: group.Type}, promiseLoadCourses)
  30. .then(function(data)
  31. {
  32. $scope.courses = data;
  33. });
  34. }
  35. else {
  36. $scope.courses = null;
  37. }
  38. });
  39. }]);