-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.js
98 lines (87 loc) · 4.18 KB
/
api.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { Meteor } from 'meteor/meteor'
import { ReactiveVar } from 'meteor/reactive-var'
import { Roles } from 'meteor/alanning:roles'
import moment from 'moment-timezone'
import { initMethods } from './both/methods/methods'
import { initCollections } from './both/collections/initCollections'
import { initServices } from './both/services'
import { initServerMethods } from './server/methods'
import { initClient, reactContext } from './client/clientInit'
export { MongoBackedQueue } from './server/queue'
export * from './both/utils/helpers'
export { useMethodCallData } from './client/utils/useMethodCallData'
export { meteorCall, methodCallback } from './client/utils/methodUtils'
export { BookedTable } from './client/components/volunteers/BookedTable.jsx'
export { SignupApproval } from './client/components/teamLeads/SignupApproval.jsx'
export { TeamShiftsTable } from './client/components/teamLeads/TeamShiftsTable.jsx'
export { TeamProjectsTable } from './client/components/teamLeads/TeamProjectsTable.jsx'
export { PublicDeptView } from './client/components/teamLeads/PublicDeptView.jsx'
export { PublicTeamView } from './client/components/teamLeads/PublicTeamView.jsx'
export { ShiftDateInline } from './client/components/common/ShiftDateInline.jsx'
export { DutiesListItem } from './client/components/shifts/DutiesListItem.jsx'
export { SignupShiftButtons } from './client/components/shifts/SignupShiftButtons.jsx'
export { SignupsList } from './client/components/shifts/SignupsList.jsx'
export { SignupProjectRow } from './client/components/shifts/SignupProjectRow.jsx'
export { FilteredSignupList } from './client/components/volunteers/FilteredSignupList.jsx'
export { UserInfoList } from './client/components/common/UserInfoList.jsx'
export { Loading } from './client/components/common/Loading.jsx'
export { DisplayName } from './client/components/common/DisplayName.jsx'
export { ShiftDate } from './client/components/common/ShiftDate.jsx'
export { TextField } from './client/components/forms/TextField.jsx'
export { BuildAndStrikeVolunteerReport } from './client/components/public/BuildAndStrikeVolunteerReport.jsx'
export class VolunteersClass {
/** dontShare is used to start an instance without weird coffeescript global effects */
constructor(settings, dontShare) {
this.eventName = settings.eventName
this.previousEventName = settings.previousEventName
// This allows us to use the settings but without having to refactor everything not to auto
// import
this.settings = new ReactiveVar()
settings.SettingsCollection.find().observe({
added: (setting) => { this.settings.set(setting) },
changed: (setting) => { this.settings.set(setting) },
})
// establish a hierarchy among roles
if (Meteor.isServer) {
const roles = ['admin', 'manager']
roles.forEach((role) => Roles.createRole(role, { unlessExists: true }))
Roles.addRolesToParent('manager', 'admin')
}
const { collections, schemas } = initCollections(this.eventName)
this.schemas = schemas
this.collections = collections
const { collections: prevEventCollections } = initCollections(this.previousEventName)
this.prevEventCollections = prevEventCollections
this.services = initServices(this)
// TODO deprecated
this.auth = this.services.auth
let methods = {}
let methodBodies = {}
// TODO this can most likely be removed but annual rota migration needs to be tested
if (!dontShare) {
({ methodBodies, ...methods } = initMethods(this))
if (Meteor.isServer) {
initServerMethods(this)
}
if (Meteor.isServer) {
import('./server/publications')
.then(({ initPublications }) => initPublications(this))
.catch(err => console.error('Error importing server publications', err))
}
}
this.methods = methods
this.methodBodies = methodBodies
if (Meteor.isClient) {
initClient()
this.reactContext = reactContext
this.userId = Meteor.userId()
}
}
setTimeZone = (timezone) => {
moment.tz.setDefault(timezone)
if (Meteor.isClient) {
// eslint-disable-next-line global-require
require('meteor/abate:autoform-datetimepicker').setPickerTimezone(timezone)
}
}
}