2017-06-08 18:50:11 -04:00
|
|
|
import Vue from 'vue';
|
2017-12-08 15:24:52 -05:00
|
|
|
import notesApp from './components/notes_app.vue';
|
2018-10-23 05:49:45 -04:00
|
|
|
import initDiscussionFilters from './discussion_filters';
|
2020-03-26 05:07:52 -04:00
|
|
|
import initSortDiscussions from './sort_discussions';
|
2020-10-05 11:08:56 -04:00
|
|
|
import initTimelineToggle from './timeline';
|
2020-05-08 11:09:28 -04:00
|
|
|
import { store } from './stores';
|
2017-06-08 18:50:11 -04:00
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2020-09-22 11:09:37 -04:00
|
|
|
const el = document.getElementById('js-vue-notes');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
2019-03-13 06:00:29 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2020-09-22 11:09:37 -04:00
|
|
|
el,
|
2018-06-21 08:22:40 -04:00
|
|
|
components: {
|
|
|
|
notesApp,
|
|
|
|
},
|
|
|
|
store,
|
2020-05-07 17:09:26 -04:00
|
|
|
data() {
|
2020-09-22 11:09:37 -04:00
|
|
|
const notesDataset = el.dataset;
|
2020-05-07 17:09:26 -04:00
|
|
|
const parsedUserData = JSON.parse(notesDataset.currentUserData);
|
|
|
|
const noteableData = JSON.parse(notesDataset.noteableData);
|
|
|
|
let currentUserData = {};
|
2018-04-03 12:03:00 -04:00
|
|
|
|
2020-05-07 17:09:26 -04:00
|
|
|
noteableData.noteableType = notesDataset.noteableType;
|
|
|
|
noteableData.targetType = notesDataset.targetType;
|
2020-07-29 11:09:39 -04:00
|
|
|
if (noteableData.discussion_locked === null) {
|
|
|
|
// discussion_locked has never been set for this issuable.
|
|
|
|
// set to `false` for safety.
|
|
|
|
noteableData.discussion_locked = false;
|
|
|
|
}
|
2017-07-27 16:24:05 -04:00
|
|
|
|
2020-05-07 17:09:26 -04:00
|
|
|
if (parsedUserData) {
|
|
|
|
currentUserData = {
|
|
|
|
id: parsedUserData.id,
|
|
|
|
name: parsedUserData.name,
|
|
|
|
username: parsedUserData.username,
|
|
|
|
avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
|
|
|
|
path: parsedUserData.path,
|
2020-05-06 11:09:42 -04:00
|
|
|
};
|
2020-05-07 17:09:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
noteableData,
|
|
|
|
currentUserData,
|
|
|
|
notesData: JSON.parse(notesDataset.notesData),
|
|
|
|
};
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('notes-app', {
|
2020-05-07 17:09:26 -04:00
|
|
|
props: {
|
|
|
|
noteableData: this.noteableData,
|
|
|
|
notesData: this.notesData,
|
|
|
|
userData: this.currentUserData,
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2019-03-13 06:00:29 -04:00
|
|
|
|
|
|
|
initDiscussionFilters(store);
|
2020-03-26 05:07:52 -04:00
|
|
|
initSortDiscussions(store);
|
2020-10-05 11:08:56 -04:00
|
|
|
initTimelineToggle(store);
|
2018-06-21 08:22:40 -04:00
|
|
|
});
|