Commit 66539563 authored by Phil Hughes's avatar Phil Hughes

Added eventHub events to change the showForm value

[ci skip]
parent 5d19bda4
import Vue from 'vue'; import Vue from 'vue';
import eventHub from './event_hub';
import issuableApp from './components/app.vue'; import issuableApp from './components/app.vue';
import '../vue_shared/vue_resource_interceptor'; import '../vue_shared/vue_resource_interceptor';
document.addEventListener('DOMContentLoaded', () => new Vue({ document.addEventListener('DOMContentLoaded', () => {
el: document.getElementById('js-issuable-app'), $('.issuable-edit').on('click', (e) => {
components: { e.preventDefault();
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,
endpoint,
issuableRef,
} = issuableElement.dataset;
return { eventHub.$emit('open.form');
canUpdate: gl.utils.convertPermissionToBoolean(canUpdate), });
endpoint,
issuableRef, return new Vue({
initialTitle: issuableTitleElement.innerHTML, el: document.getElementById('js-issuable-app'),
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '', components: {
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '', issuableApp,
}; },
}, data() {
render(createElement) { const issuableElement = this.$options.el;
return createElement('issuable-app', { const issuableTitleElement = issuableElement.querySelector('.title');
props: { const issuableDescriptionElement = issuableElement.querySelector('.wiki');
canUpdate: this.canUpdate, const issuableDescriptionTextarea = issuableElement.querySelector('.js-task-list-field');
endpoint: this.endpoint, const {
issuableRef: this.issuableRef, canUpdate,
initialTitle: this.initialTitle, endpoint,
initialDescriptionHtml: this.initialDescriptionHtml, issuableRef,
initialDescriptionText: this.initialDescriptionText, } = issuableElement.dataset;
return {
canUpdate: gl.utils.convertPermissionToBoolean(canUpdate),
endpoint,
issuableRef,
initialTitle: issuableTitleElement.innerHTML,
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
showForm: false,
};
},
methods: {
openForm() {
this.showForm = true;
console.log(this.showForm);
}, },
}); },
}, created() {
})); eventHub.$on('open.form', this.openForm);
},
beforeDestroy() {
eventHub.$off('open.form', this.openForm);
},
render(createElement) {
return createElement('issuable-app', {
props: {
canUpdate: this.canUpdate,
endpoint: this.endpoint,
issuableRef: this.issuableRef,
initialTitle: this.initialTitle,
initialDescriptionHtml: this.initialDescriptionHtml,
initialDescriptionText: this.initialDescriptionText,
},
});
},
});
});
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
%li %li
= link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, format: 'json'), data: {no_turbolink: true}, class: "btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue' = link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, format: 'json'), data: {no_turbolink: true}, class: "btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue'
%li %li
= link_to 'Edit', edit_namespace_project_issue_path(@project.namespace, @project, @issue) = link_to 'Edit', edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: 'issuable-edit'
- if @issue.submittable_as_spam_by?(current_user) - if @issue.submittable_as_spam_by?(current_user)
%li %li
= link_to 'Submit as spam', mark_as_spam_namespace_project_issue_path(@project.namespace, @project, @issue), method: :post, class: 'btn-spam', title: 'Submit as spam' = link_to 'Submit as spam', mark_as_spam_namespace_project_issue_path(@project.namespace, @project, @issue), method: :post, class: 'btn-spam', title: 'Submit as spam'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment