schedule page update: multiple schedules, prettify, other changes
This commit is contained in:
1 parent
a22820c278
commit
f747ce17f3
3 files changed
+62
-19
No files matched your search
@@ -15,6 +15,10 @@
|
||||
padding-bottom: 50px;
|
||||
text-align: center;
|
||||
|
||||
& > p{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.schedule-block{
|
||||
overflow-x: scroll;
|
||||
}
|
||||
@@ -90,10 +94,6 @@
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
p{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
a{
|
||||
color: black;
|
||||
|
||||
|
||||
+49
-11
@@ -6,20 +6,58 @@ module.exports = function (app) {
|
||||
var now = new Date();
|
||||
var dates = getDates(now);
|
||||
|
||||
var sem = "autumn";
|
||||
$scope.sem = [["spring", "весеннего"], ["autumn", "осеннего"]].reduce(function (s, word) {
|
||||
if (word[0] === sem) return word[1];
|
||||
});
|
||||
$scope.year = "2014-2015";
|
||||
$http.get("/schedules")
|
||||
.success(function (schedules) {
|
||||
//return ;
|
||||
var last = schedules.length - 1;
|
||||
|
||||
$http.get("/schedule/2014-2015/spring")
|
||||
.success(function (s) {
|
||||
$scope.schedule = schedule.populate(s.schedule, [
|
||||
populate(team.short, "teacher"),
|
||||
populate(course.name, "lesson")
|
||||
]);
|
||||
$scope.schedules = schedules.map(function (schedule) {
|
||||
var sem = [["spring", "весеннего"], ["autumn", "осеннего"]].reduce(function (s, word) {
|
||||
if (word[0] === schedule.semester) return word[1];
|
||||
else return s[1];
|
||||
});
|
||||
|
||||
schedule.text = 'Расписание {{sem}} семестра {{period}} года'
|
||||
.replace('{{sem}}', sem)
|
||||
.replace('{{period}}', schedule.period);
|
||||
|
||||
return schedule;
|
||||
});
|
||||
$scope.schedules[last].selected = true;
|
||||
$scope.currentSchedule = $scope.schedules[last]._id;
|
||||
$scope.loadSchedule();
|
||||
});
|
||||
|
||||
$scope.$watch('currentSchedule', function (newValue) {
|
||||
|
||||
});
|
||||
|
||||
$scope.loadSchedule = function (id) {
|
||||
var schedule_item = getScheduleByID(id || $scope.currentSchedule);
|
||||
|
||||
if(schedule_item) {
|
||||
var sem = schedule_item.semester;
|
||||
var period = schedule_item.period;
|
||||
|
||||
$http.get("/schedule/" + period + "/" + sem)
|
||||
.success(function (scheduleRecord) {
|
||||
$scope.groups = schedule.populate(scheduleRecord.schedule, [
|
||||
populate(team.short, "teacher"),
|
||||
populate(course.name, "lesson")
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function getScheduleByID(id) {
|
||||
var schedules = $scope.schedules;
|
||||
for (var i in schedules) {
|
||||
var s = schedules[i];
|
||||
if (id === s._id) return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
$scope.isToday = function (weekDayIndex) {
|
||||
return (now.getDay() - 1) === weekDayIndex;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<div class="schedule" ng-controller="ScheduleController">
|
||||
<p> Расписание {{sem}} семестра {{year}} года</p>
|
||||
<div class="schedule-block">
|
||||
<p>
|
||||
<select ng-model="currentSchedule" ng-change="loadSchedule(currentSchedule)">
|
||||
<option ng-repeat="s in schedules" value="{{s._id}}" selected="{{s.selected}}">{{s.text}}</option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<div class="schedule-block" ng-show="groups">
|
||||
<table>
|
||||
<thead class="">
|
||||
<tr>
|
||||
@@ -37,8 +42,8 @@
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="">
|
||||
<tr ng-repeat="group in schedule">
|
||||
<tbody>
|
||||
<tr ng-repeat="group in groups">
|
||||
<td class="group">
|
||||
<p class="name">{{group.name}}</p>
|
||||
|
||||
|
||||
Reference in new issue
Block a user