forked from IstanbulPHP/2020.phpkonf.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·48 lines (46 loc) · 1.52 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
const API_URL = 'https://cms.kommunity.com/api/events/phpkonf-2020?with[]=speakers&with[]=sessions&with[]=days&with[]=tracks&with[]=sponsorships&with[]=photos'
var App = new Vue({
el: '#app',
data: {
days: [],
speakers: [],
sessions: [],
},
mounted() {
this.getData()
},
methods: {
getData: function () {
axios.get(API_URL).then(response => {
const { days, speakers } = response.data.data;
this.days = days
this.days[0].isSelected = true;
this.days[0].tracks[0].isSelected = true;
this.speakers = speakers;
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);
}
}
});