2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
2019-07-31 22:56:46 +05:30
|
|
|
import initNoteStats from 'ee_else_ce/event_tracking/notes';
|
2018-03-17 18:26:18 +05:30
|
|
|
import notesApp from './components/notes_app.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
import initDiscussionFilters from './discussion_filters';
|
2018-11-08 19:23:39 +05:30
|
|
|
import createStore from './stores';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const store = createStore();
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2018-11-08 19:23:39 +05:30
|
|
|
el: '#js-vue-notes',
|
|
|
|
components: {
|
|
|
|
notesApp,
|
|
|
|
},
|
|
|
|
store,
|
|
|
|
data() {
|
|
|
|
const notesDataset = document.getElementById('js-vue-notes').dataset;
|
|
|
|
const parsedUserData = JSON.parse(notesDataset.currentUserData);
|
|
|
|
const noteableData = JSON.parse(notesDataset.noteableData);
|
|
|
|
let currentUserData = {};
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
noteableData.noteableType = notesDataset.noteableType;
|
|
|
|
noteableData.targetType = notesDataset.targetType;
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
if (parsedUserData) {
|
|
|
|
currentUserData = {
|
|
|
|
id: parsedUserData.id,
|
|
|
|
name: parsedUserData.name,
|
|
|
|
username: parsedUserData.username,
|
|
|
|
avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
|
|
|
|
path: parsedUserData.path,
|
2018-05-09 12:01:36 +05:30
|
|
|
};
|
2018-11-08 19:23:39 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
noteableData,
|
|
|
|
currentUserData,
|
|
|
|
notesData: JSON.parse(notesDataset.notesData),
|
|
|
|
};
|
|
|
|
},
|
2019-07-31 22:56:46 +05:30
|
|
|
mounted() {
|
2019-09-30 21:07:59 +05:30
|
|
|
initNoteStats();
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement('notes-app', {
|
|
|
|
props: {
|
|
|
|
noteableData: this.noteableData,
|
|
|
|
notesData: this.notesData,
|
|
|
|
userData: this.currentUserData,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
initDiscussionFilters(store);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|