-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·49 lines (48 loc) · 1.58 KB
/
app.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
const API_URL = 'https://cms.kommunity.com/api/events/phpkonf-2021?with[]=speakers&with[]=sessions&with[]=days&with[]=tracks&with[]=sponsorships&with[]=photos'
var App = new Vue({
el: '#app',
data: {
days: [],
speakers: [],
sessions: [],
sponsors: [],
},
mounted() {
this.getData()
},
methods: {
getData: function () {
axios.get(API_URL).then(response => {
const {days, speakers, sponsors} = response.data.data;
this.speakers = speakers;
this.sponsors = sponsors;
this.days = days
this.days[0].isSelected = true;
this.days[0].tracks[0].isSelected = true;
this.getAllSessions();
this.addSessionsForSpeakers();
}
);
},
getAllSessions: function () {
this.days.forEach(day => {
this.sessions = [...day.sessions, ...this.sessions]
});
},
addSessionsForSpeakers: function () {
this.speakers.forEach(speaker => {
speaker.sessions = this.sessions.filter(session => {
if (session.speaker.id === speaker.id) {
return session;
}
})
});
},
getSortedSpeakers: function () {
return _.sortBy(this.speakers, 'name')
},
getRandomSpeakers: function() {
return _.sampleSize(this.speakers, 6);
}
}
});