2017-04-06 01:13:06 +00:00
|
|
|
import Vue from 'vue';
|
2017-05-12 09:11:15 +00:00
|
|
|
import eventHub from './event_hub';
|
2017-05-10 11:29:33 +00:00
|
|
|
import issuableApp from './components/app.vue';
|
2017-04-06 01:13:06 +00:00
|
|
|
import '../vue_shared/vue_resource_interceptor';
|
|
|
|
|
2017-05-12 09:11:15 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
$('.issuable-edit').on('click', (e) => {
|
|
|
|
e.preventDefault();
|
2017-04-06 01:13:06 +00:00
|
|
|
|
2017-05-12 09:11:15 +00:00
|
|
|
eventHub.$emit('open.form');
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el: document.getElementById('js-issuable-app'),
|
|
|
|
components: {
|
|
|
|
issuableApp,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
const issuableElement = this.$options.el;
|
|
|
|
const issuableTitleElement = issuableElement.querySelector('.title');
|
|
|
|
const issuableDescriptionElement = issuableElement.querySelector('.wiki');
|
|
|
|
const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field');
|
|
|
|
const {
|
|
|
|
canUpdate,
|
2017-05-12 10:58:48 +00:00
|
|
|
canDestroy,
|
2017-05-12 09:11:15 +00:00
|
|
|
endpoint,
|
|
|
|
issuableRef,
|
|
|
|
} = issuableElement.dataset;
|
|
|
|
|
|
|
|
return {
|
|
|
|
canUpdate: gl.utils.convertPermissionToBoolean(canUpdate),
|
2017-05-12 10:58:48 +00:00
|
|
|
canDestroy: gl.utils.convertPermissionToBoolean(canDestroy),
|
2017-05-12 09:11:15 +00:00
|
|
|
endpoint,
|
|
|
|
issuableRef,
|
|
|
|
initialTitle: issuableTitleElement.innerHTML,
|
|
|
|
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
|
|
|
|
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('issuable-app', {
|
|
|
|
props: {
|
|
|
|
canUpdate: this.canUpdate,
|
2017-05-12 10:58:48 +00:00
|
|
|
canDestroy: this.canDestroy,
|
2017-05-12 09:11:15 +00:00
|
|
|
endpoint: this.endpoint,
|
|
|
|
issuableRef: this.issuableRef,
|
|
|
|
initialTitle: this.initialTitle,
|
|
|
|
initialDescriptionHtml: this.initialDescriptionHtml,
|
|
|
|
initialDescriptionText: this.initialDescriptionText,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|