| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 | 2×
2×
2×
2×
2×
684×
2×
2×
2×
| var CrudConfig, LOADED, RosterConfig, _, actions, extendConfig, makeSimpleStore, ref, ref1, store;
ref = require('./helpers'), CrudConfig = ref.CrudConfig, makeSimpleStore = ref.makeSimpleStore, extendConfig = ref.extendConfig;
_ = require('underscore');
LOADED = 'loaded';
RosterConfig = {
_asyncStatus: {},
create: function(courseId, params) {},
created: function(student, courseId) {
this._local[courseId].push(student);
return this.emitChange();
},
saved: function(newProps, studentId) {
var courseId, ref1, roster, student, students;
this._asyncStatus[studentId] = LOADED;
ref1 = this._local;
for (courseId in ref1) {
roster = ref1[courseId];
students = roster.students;
student = _.findWhere(students, {
id: studentId
});
if (student) {
_.extend(student, newProps);
}
}
return this.emitChange();
},
deleted: function(unused, studentId) {
var courseId, index, ref1, roster, students;
ref1 = this._local;
for (courseId in ref1) {
roster = ref1[courseId];
students = roster.students;
index = _.findIndex(students, {
id: studentId
});
if (-1 !== index) {
students.splice(index, 1);
}
}
return this.emitChange();
},
exports: {
getActiveStudentsForPeriod: function(courseId, periodId) {
return _.where(this._get(courseId).students, {
period_id: periodId,
is_active: true
});
}
}
};
extendConfig(RosterConfig, new CrudConfig());
ref1 = makeSimpleStore(RosterConfig), actions = ref1.actions, store = ref1.store;
module.exports = {
RosterActions: actions,
RosterStore: store
};
|