Skip to content

Commit 10e7595

Browse files
committed
makes private methods of the module private methods of the class.
this is more straightforward.
1 parent c2484c6 commit 10e7595

1 file changed

Lines changed: 39 additions & 49 deletions

File tree

  • packages/ilios-common/addon/classes

packages/ilios-common/addon/classes/event.js

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,6 @@ import { cached } from '@glimmer/tracking';
22
import { DateTime } from 'luxon';
33
import { sortBy } from 'ilios-common/utils/array-helpers';
44

5-
/**
6-
* Generates a slug from given user event data.
7-
* @method getSlugForUserEvent
8-
* @param { String } startDate The event's start date
9-
* @param { Number|undefined } offeringId The event's offering ID
10-
* @param { Number|undefined } ilmSessionId The event's ILM session ID
11-
* @return { String }
12-
*/
13-
function getSlugForUserEvent(startDate, offeringId, ilmSessionId) {
14-
let slug = 'U';
15-
slug += DateTime.fromISO(startDate).toFormat('yyyyMMdd');
16-
if (offeringId) {
17-
slug += 'O' + offeringId;
18-
}
19-
if (ilmSessionId) {
20-
slug += 'I' + ilmSessionId;
21-
}
22-
return slug;
23-
}
24-
25-
/**
26-
* Generates a slug for a given school event.
27-
* @method getSlugForSchoolEvent
28-
* @param { String } startDate The event's start date
29-
* @param { Number } schoolId The event's school ID
30-
* @param { Number|undefined } offeringId The event's offering ID
31-
* @param { Number|undefined } ilmSessionId The event's ILM session ID
32-
* @return { String }
33-
*/
34-
function getSlugForSchoolEvent(startDate, schoolId, offeringId, ilmSessionId) {
35-
let slug = 'S';
36-
schoolId = parseInt(schoolId, 10).toString();
37-
//always use a two digit schoolId
38-
if (schoolId.length === 1) {
39-
schoolId = '0' + schoolId;
40-
}
41-
slug += schoolId;
42-
slug += DateTime.fromISO(startDate).toFormat('yyyyMMdd');
43-
if (offeringId) {
44-
slug += 'O' + offeringId;
45-
}
46-
if (ilmSessionId) {
47-
slug += 'I' + ilmSessionId;
48-
}
49-
return slug;
50-
}
51-
525
/**
536
* This is an object representation of an event, to be used in the
547
* various calendars and week-at-a-glance.
@@ -147,7 +100,44 @@ export default class Event {
147100
@cached
148101
get slug() {
149102
return this.isUserEvent
150-
? getSlugForUserEvent(this.startDate, this.offering, this.ilmSession)
151-
: getSlugForSchoolEvent(this.startDate, this.school, this.offering, this.ilmSession);
103+
? this.#getSlugForUserEvent(this.startDate, this.offering, this.ilmSession)
104+
: this.#getSlugForSchoolEvent(this.startDate, this.school, this.offering, this.ilmSession);
105+
}
106+
/**
107+
* Generates a slug from given user event data.
108+
* @return { String }
109+
*/
110+
#getSlugForUserEvent() {
111+
let slug = 'U';
112+
slug += DateTime.fromISO(this.startDate).toFormat('yyyyMMdd');
113+
if (this.offering) {
114+
slug += 'O' + this.offering;
115+
}
116+
if (this.ilmSession) {
117+
slug += 'I' + this.ilmSession;
118+
}
119+
return slug;
120+
}
121+
122+
/**
123+
* Generates a slug for a given school event.
124+
* @return { String }
125+
*/
126+
#getSlugForSchoolEvent() {
127+
let slug = 'S';
128+
let schoolId = parseInt(this.school, 10).toString();
129+
//always use a two digit schoolId
130+
if (schoolId.length === 1) {
131+
schoolId = '0' + schoolId;
132+
}
133+
slug += schoolId;
134+
slug += DateTime.fromISO(this.startDate).toFormat('yyyyMMdd');
135+
if (this.offering) {
136+
slug += 'O' + this.offering;
137+
}
138+
if (this.ilmSession) {
139+
slug += 'I' + this.ilmSession;
140+
}
141+
return slug;
152142
}
153143
}

0 commit comments

Comments
 (0)