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
|
import Vue from 'vue';
import { mapActions, mapState } from 'vuex';
import { parseBoolean } from '~/lib/utils/common_utils';
import AwardsList from '~/vue_shared/components/awards_list.vue';
import createstore from './store';
export default (el) => {
const {
dataset: { path },
} = el;
const canAwardEmoji = parseBoolean(el.dataset.canAwardEmoji);
return new Vue({
el,
name: 'AwardsListRoot',
store: createstore(),
computed: {
...mapState(['currentUserId', 'canAwardEmoji', 'awards']),
},
created() {
this.setInitialData({ path, currentUserId: window.gon.current_user_id, canAwardEmoji });
},
mounted() {
this.fetchAwards();
},
methods: {
...mapActions(['setInitialData', 'fetchAwards', 'toggleAward']),
},
render(createElement) {
return createElement(AwardsList, {
props: {
awards: this.awards,
canAwardEmoji: this.canAwardEmoji,
currentUserId: this.currentUserId,
defaultAwards: ['thumbsup', 'thumbsdown'],
selectedClass: 'selected',
},
on: {
award: this.toggleAward,
},
});
},
});
};
|