Commit efc9408f authored by Phil Hughes's avatar Phil Hughes

Added description template selector

[ci skip]
parent 14387b49
...@@ -41,6 +41,11 @@ export default { ...@@ -41,6 +41,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
issuableTemplates: {
type: Array,
required: false,
default: () => [],
},
}, },
data() { data() {
const store = new Store({ const store = new Store({
...@@ -146,7 +151,8 @@ export default { ...@@ -146,7 +151,8 @@ export default {
:show-form="showForm" :show-form="showForm"
:issuable-ref="issuableRef" :issuable-ref="issuableRef"
:title-html="state.titleHtml" :title-html="state.titleHtml"
:title-text="state.titleText" /> :title-text="state.titleText"
:issuable-templates="issuableTemplates" />
<description-component <description-component
v-if="state.descriptionHtml" v-if="state.descriptionHtml"
:can-update="canUpdate" :can-update="canUpdate"
......
<script>
export default {
props: {
issuableTemplates: {
type: Array,
required: false,
default: () => [],
},
},
mounted() {
return new gl.IssuableTemplateSelectors();
},
};
</script>
<template>
<div
class="dropdown js-issuable-selector-wrap"
data-issuable-type="issue">
<button
class="dropdown-menu-toggle js-issuable-selector"
type="button"
:data-data="JSON.stringify(issuableTemplates)"
data-field-name="issuable_template"
data-selected="null"
data-project-path="gitlab-ce"
data-namespace-path="gitlab-org"
data-toggle="dropdown">
<span class="dropdown-toggle-text ">
Choose a template
</span>
<i
aria-hidden="true"
class="fa fa-chevron-down">
</i>
</button>
<div class="dropdown-menu dropdown-select">
<div class="dropdown-title">
Choose a template
<button
class="dropdown-title-button dropdown-menu-close"
aria-label="Close"
type="button">
<i
aria-hidden="true"
class="fa fa-times dropdown-menu-close-icon">
</i>
</button>
</div>
<div class="dropdown-input">
<input
type="search"
class="dropdown-input-field"
placeholder="Filter"
autocomplete="off" />
<i
aria-hidden="true"
class="fa fa-search dropdown-input-search">
</i>
<i
role="button"
aria-hidden="true"
class="fa fa-times dropdown-input-clear js-dropdown-input-clear">
</i>
</div>
<div class="dropdown-content ">
</div>
<div class="dropdown-footer">
<ul class="dropdown-footer-list">
<li>
<a class="no-template">
No template
</a>
</li>
<li>
<a class="reset-template">
Reset template
</a>
</li>
</ul>
</div>
</div>
</div>
</template>
<script> <script>
import descriptionTemplate from './template.vue';
export default { export default {
props: { props: {
store: { store: {
type: Object, type: Object,
required: true, required: true,
}, },
issuableTemplates: {
type: Array,
required: false,
default: () => [],
},
}, },
data() { data() {
return { return {
state: this.store.formState, state: this.store.formState,
}; };
}, },
components: {
descriptionTemplate,
},
}; };
</script> </script>
<template> <template>
<fieldset> <fieldset class="row">
<div class="col-sm-4 col-lg-3">
<description-template
:issuable-templates="issuableTemplates" />
</div>
<div class="col-sm-8 col-lg-9">
<label <label
class="sr-only" class="sr-only"
for="issue-title"> for="issue-title">
...@@ -28,5 +43,6 @@ ...@@ -28,5 +43,6 @@
placeholder="Issue title" placeholder="Issue title"
aria-label="Issue title" aria-label="Issue title"
v-model="state.title" /> v-model="state.title" />
</div>
</fieldset> </fieldset>
</template> </template>
...@@ -35,6 +35,11 @@ ...@@ -35,6 +35,11 @@
type: Boolean, type: Boolean,
required: true, required: true,
}, },
issuableTemplates: {
type: Array,
required: true,
default: () => [],
},
}, },
watch: { watch: {
titleHtml() { titleHtml() {
...@@ -56,7 +61,8 @@ ...@@ -56,7 +61,8 @@
<div> <div>
<title-field <title-field
v-if="showForm" v-if="showForm"
:store="store" /> :store="store"
:issuable-templates="issuableTemplates" />
<h2 <h2
v-else v-else
class="title" class="title"
......
...@@ -4,6 +4,8 @@ import issuableApp from './components/app.vue'; ...@@ -4,6 +4,8 @@ import issuableApp from './components/app.vue';
import '../vue_shared/vue_resource_interceptor'; import '../vue_shared/vue_resource_interceptor';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const initialDataEl = document.getElementById('js-issuable-app-initial-data');
const initialData = JSON.parse(initialDataEl.innerHTML.replace(/&quot;/g, '"'));
$('.issuable-edit').on('click', (e) => { $('.issuable-edit').on('click', (e) => {
e.preventDefault(); e.preventDefault();
...@@ -35,6 +37,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -35,6 +37,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle: issuableTitleElement.innerHTML, initialTitle: issuableTitleElement.innerHTML,
initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '', initialDescriptionHtml: issuableDescriptionElement ? issuableDescriptionElement.innerHTML : '',
initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '', initialDescriptionText: issuableDescriptionTextarea ? issuableDescriptionTextarea.textContent : '',
issuableTemplates: initialData.templates,
}; };
}, },
render(createElement) { render(createElement) {
...@@ -47,6 +50,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -47,6 +50,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle: this.initialTitle, initialTitle: this.initialTitle,
initialDescriptionHtml: this.initialDescriptionHtml, initialDescriptionHtml: this.initialDescriptionHtml,
initialDescriptionText: this.initialDescriptionText, initialDescriptionText: this.initialDescriptionText,
issuableTemplates: this.issuableTemplates,
}, },
}); });
}, },
......
...@@ -199,6 +199,12 @@ module IssuablesHelper ...@@ -199,6 +199,12 @@ module IssuablesHelper
issuable_filter_params.any? { |k| params.key?(k) } issuable_filter_params.any? { |k| params.key?(k) }
end end
def issuable_initial_data(issuable)
{
templates: issuable_templates(issuable)
}.to_json
end
private private
def sidebar_gutter_collapsed? def sidebar_gutter_collapsed?
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
.issue-details.issuable-details .issue-details.issuable-details
.detail-page-description.content-block .detail-page-description.content-block
%script#js-issuable-app-initial-data{ type: "application/json" }= issuable_initial_data(@issue)
#js-issuable-app{ "data" => { "endpoint" => namespace_project_issue_path(@project.namespace, @project, @issue), #js-issuable-app{ "data" => { "endpoint" => namespace_project_issue_path(@project.namespace, @project, @issue),
"can-update" => can?(current_user, :update_issue, @issue).to_s, "can-update" => can?(current_user, :update_issue, @issue).to_s,
"can-destroy" => can?(current_user, :destroy_issue, @issue).to_s, "can-destroy" => can?(current_user, :destroy_issue, @issue).to_s,
......
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