Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

home.controller.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.getSheetCount = function()
  7. {
  8. var sheetCount = function(group)
  9. {
  10. var c = (group.Groups == null || group.Groups.length == 0) ? 1 : 0;
  11. if (group.Groups != null) {
  12. group.Groups.forEach(function (group) {
  13. c += sheetCount(group);
  14. });
  15. }
  16. return c;
  17. };
  18. return sheetCount(DataShareBusiness.getCurrentGroupOrRoot())
  19. };
  20. $scope.$watch(function(){return DataShareBusiness.CurrentGroups}, function()
  21. {
  22. var group = DataShareBusiness.getCurrentGroup();
  23. if (group != null && $scope.getSheetCount() < 5) {
  24. var promiseLoadCourses = {
  25. id: "promiseLoadCourses",
  26. groups: ["coursesView"]
  27. };
  28. WeeksBusiness.getCurrentWeek({group_id: group.Id, type_id: group.Type}, promiseLoadCourses)
  29. .then(function(data)
  30. {
  31. $scope.courses = data;
  32. });
  33. }
  34. else {
  35. $scope.courses = null;
  36. }
  37. });
  38. }]);