debian-mirror-gitlab/app/assets/javascripts/notes/index.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import notesApp from './components/notes_app.vue';
2018-12-13 13:39:08 +05:30
import initDiscussionFilters from './discussion_filters';
2020-04-22 19:07:51 +05:30
import initSortDiscussions from './sort_discussions';
2020-05-24 23:13:21 +05:30
import { store } from './stores';
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
document.addEventListener('DOMContentLoaded', () => {
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),
};
},
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);
2020-04-22 19:07:51 +05:30
initSortDiscussions(store);
2018-11-08 19:23:39 +05:30
});