Browse Source

working calendar

tags/1.0.0
Robin Thoni 8 years ago
parent
commit
7356bc8c7f
4 changed files with 53 additions and 7 deletions
  1. 1
    2
      app/controllers/home.controller.js
  2. 14
    2
      app/less/app.less
  3. 10
    3
      app/views/home.html
  4. 28
    0
      sdk/Business/WeeksBusiness.js

+ 1
- 2
app/controllers/home.controller.js View File

@@ -48,8 +48,7 @@ angular.module('app')
48 48
                 }
49 49
                 return $scope.courses.DayList.find(function(day)
50 50
                 {
51
-                    var d = new Date(day.DateTime);
52
-                    return d.getTime() == date.getTime();
51
+                    return day.DateTime.getTime() == date.getTime();
53 52
                 });
54 53
             };
55 54
 

+ 14
- 2
app/less/app.less View File

@@ -62,10 +62,14 @@ footer {
62 62
   }
63 63
 }
64 64
 
65
+@calendar-height: 24*30px;
66
+
65 67
 .day-column {
66 68
   .text-center();
67
-  border: solid #505050 1px;
68
-  height: 24*30px;
69
+  border-left: solid #505050 1px;
70
+  border-top: solid #505050 1px;
71
+  border-bottom: solid #505050 1px;
72
+  height: @calendar-height;
69 73
   padding: 0;
70 74
 }
71 75
 
@@ -87,4 +91,12 @@ footer {
87 91
   position: absolute;
88 92
   background-color: cadetblue;
89 93
   width: 100%;
94
+  border-top: solid #505050 1px;
95
+  border-bottom: solid #505050 1px;
96
+  overflow: hidden;
97
+}
98
+
99
+.day-column-courses {
100
+  height: @calendar-height - 50px;
101
+  position: relative;
90 102
 }

+ 10
- 3
app/views/home.html View File

@@ -9,11 +9,18 @@
9 9
     </p>
10 10
 
11 11
     <div lu-busy="coursesView" class="col-xs-12 seven-cols">
12
-        <div ng-repeat="day in days" class="col-sm-1 day-column">
12
+        <div ng-repeat="day in days" class="col-sm-1 day-column"
13
+            ng-style="{'border-right': $last ? 'solid #505050 1px' : ''}">
13 14
             <div class="day-column-header day-column-header-day">{{ day.day }}</div>
14 15
             <div class="day-column-header day-column-header-date">{{ day.date | date : dateFormat }}</div>
15
-            <div class="day-column-course" ng-repeat="course in getCoursesByDate(day.date)" ng-style="{'height': (course.EndPercent - course.BeginPercent) + '%', 'top' : course.BeginPercent + '%'}">
16
-                {{ course.Name }}
16
+            <div class="day-column-courses">
17
+                <div class="day-column-course" ng-repeat="course in getCoursesByDate(day.date)"
18
+                     ng-style="{'height': (course.EndPercent - course.BeginPercent) + '%',
19
+                     'top' : course.BeginPercent + '%', 'width': (100 / course.ParallelCoursesCount)+'%',
20
+                     'left': (course.ParallelCoursesPosition * (100 / course.ParallelCoursesCount)) + '%',
21
+                     'border-left': (course.ParallelCoursesPosition != 0) ? 'solid #505050 1px' : ''}">
22
+                    {{ course.Name }}
23
+                </div>
17 24
             </div>
18 25
         </div>
19 26
     </div>

+ 28
- 0
sdk/Business/WeeksBusiness.js View File

@@ -3,23 +3,51 @@
3 3
     angular.module('appSdk')
4 4
         .factory('WeeksBusiness', ['WeeksDataAccess', '$q', function (WeeksDataAccess, $q) {
5 5
 
6
+            function isDateInCourse(course, date)
7
+            {
8
+                return course.BeginDate < date && course.EndDate > date;
9
+            }
10
+
6 11
             var Business = {};
7 12
 
8 13
             Business.formatWeek = function(data)
9 14
             {
10 15
                 data.DayList.forEach(function(day) {
16
+                    day.DateTime = new Date(day.DateTime);
11 17
                     day.CourseList.forEach(function (course) {
18
+
19
+                        course.BeginDate = new Date(course.BeginDate);
12 20
                         var dt = new Date(course.BeginDate);
13 21
                         var secs = dt.getSeconds() + (60 * dt.getMinutes()) + (60 * 60 * dt.getHours());
14 22
                         course.BeginPercent = secs / (60 * 60 * 24) * 100;
15 23
                         course.BeginSeconds = secs;
16 24
 
25
+                        course.EndDate = new Date(course.EndDate);
17 26
                         dt = new Date(course.EndDate);
18 27
                         secs = dt.getSeconds() + (60 * dt.getMinutes()) + (60 * 60 * dt.getHours());
19 28
                         course.EndPercent = secs / (60 * 60 * 24) * 100;
20 29
                         course.EndSeconds = secs;
21 30
                     });
22 31
                 });
32
+                data.DayList.forEach(function(day) {
33
+                    day.CourseList.forEach(function (course) {
34
+                        course.ParallelCoursesCount = 1;
35
+                        course.ParallelCoursesPosition = 0;
36
+                        day.CourseList.forEach(function (course2) {
37
+                            if (course.Id == course2.Id) {
38
+                                return;
39
+                            }
40
+                            var beginBeforeEndIn = (course2.BeginDate <= course.BeginDate && isDateInCourse(course, course2.EndDate));
41
+                            var beginInEndAfter = (course2.EndDate >= course.EndDate && isDateInCourse(course, course2.BeginDate));
42
+                            var beginBeforeEndAfter = (course2.BeginDate <= course.BeginDate && course2.EndDate >= course.EndDate);
43
+                            var beginInEndIn = (isDateInCourse(course, course2.EndDate) && isDateInCourse(course, course2.BeginDate));
44
+                            if (beginBeforeEndIn || beginInEndAfter || beginBeforeEndAfter || beginInEndIn) {
45
+                                ++course.ParallelCoursesCount;
46
+                                course2.ParallelCoursesPosition = Math.max(course.ParallelCoursesPosition, course2.ParallelCoursesPosition) + 1
47
+                            }
48
+                        });
49
+                    });
50
+                });
23 51
             };
24 52
 
25 53
             Business.getWeek = function(data, promise)

Loading…
Cancel
Save