Commit e52ab81f authored by Simon Knox's avatar Simon Knox

add search to new issue project dropdown

parent 6f438650
...@@ -42,13 +42,6 @@ export default { ...@@ -42,13 +42,6 @@ export default {
}, },
}, },
methods: { methods: {
loadProjects() {
this.loading = true;
Api.groupProjects(this.groupId, {}, (projects) => {
this.projects = projects;
this.loading = false;
});
},
submit(e) { submit(e) {
e.preventDefault(); e.preventDefault();
if (this.title.trim() === '') return Promise.resolve(); if (this.title.trim() === '') return Promise.resolve();
...@@ -104,8 +97,29 @@ export default { ...@@ -104,8 +97,29 @@ export default {
search: { search: {
fields: ['name_with_namespace'], fields: ['name_with_namespace'],
}, },
data(term, callback) { clicked: ({ $el, e }) => {
return Api.groupProjects(this.groupId, term, callback); e.preventDefault();
this.selectedProject = {
id: $el.data('project-id'),
name: $el.data('project-name'),
};
},
selectable: true,
data: (term, callback) => {
this.loading = true;
return Api.groupProjects(this.groupId, term, (projects) => {
this.loading = false;
callback(projects);
});
},
renderRow(project) {
return `
<li>
<a href='#' class='dropdown-menu-link' data-project-id="${project.id}" data-project-name="${project.name}">
${_.escape(project.name)}
</a>
</li>
`;
}, },
text: project => project.name, text: project => project.name,
}); });
...@@ -135,9 +149,8 @@ export default { ...@@ -135,9 +149,8 @@ export default {
:for="list.id + '-project'"> :for="list.id + '-project'">
Project Project
</label> </label>
<div class="dropdown"> <div ref="projectsDropdown" class="dropdown">
<button <button
@click="loadProjects"
class="dropdown-menu-toggle wide" class="dropdown-menu-toggle wide"
type="button" type="button"
data-toggle="dropdown" data-toggle="dropdown"
...@@ -146,18 +159,17 @@ export default { ...@@ -146,18 +159,17 @@ export default {
<i class="fa fa-chevron-down" aria-hidden="true"></i> <i class="fa fa-chevron-down" aria-hidden="true"></i>
</button> </button>
<div class="dropdown-menu dropdown-menu-selectable dropdown-menu-full-width"> <div class="dropdown-menu dropdown-menu-selectable dropdown-menu-full-width">
<loading-icon v-if="loading" /> <div class="dropdown-title">
<ul> <span>Projects</span>
<li v-for="project in projects"> <button aria-label="Close" type="button" class="dropdown-title-button dropdown-menu-close">
<a <i aria-hidden="true" data-hidden="true" class="fa fa-times dropdown-menu-close-icon"></i>
href="#" </button>
role="button" </div>
:class="{ 'is-active': project.id == selectedProject.id }" <div class="dropdown-input">
@click.prevent="selectedProject = project"> <input class="dropdown-input-field">
{{ project.name }} </div>
</a> <div class="dropdown-content"></div>
</li> <div class="dropdown-loading"></div>
</ul>
</div> </div>
</div> </div>
</template> </template>
......
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