2018-02-19 14:06:16 -05:00
|
|
|
<script>
|
2018-05-28 05:47:59 -04:00
|
|
|
import $ from 'jquery';
|
|
|
|
import _ from 'underscore';
|
|
|
|
import eventHub from '../eventhub';
|
|
|
|
import loadingIcon from '../../vue_shared/components/loading_icon.vue';
|
|
|
|
import Api from '../../api';
|
2018-03-09 15:18:59 -05:00
|
|
|
|
2018-05-28 05:47:59 -04:00
|
|
|
export default {
|
|
|
|
name: 'BoardProjectSelect',
|
|
|
|
components: {
|
|
|
|
loadingIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
groupId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
default: 0,
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2018-05-28 05:47:59 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
selectedProject: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
selectedProjectName() {
|
|
|
|
return this.selectedProject.name || 'Select a project';
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2018-05-28 05:47:59 -04:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
$(this.$refs.projectsDropdown).glDropdown({
|
|
|
|
filterable: true,
|
|
|
|
filterRemote: true,
|
|
|
|
search: {
|
|
|
|
fields: ['name_with_namespace'],
|
2018-02-19 14:06:16 -05:00
|
|
|
},
|
2018-05-28 05:47:59 -04:00
|
|
|
clicked: ({ $el, e }) => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.selectedProject = {
|
|
|
|
id: $el.data('project-id'),
|
|
|
|
name: $el.data('project-name'),
|
|
|
|
};
|
|
|
|
eventHub.$emit('setSelectedProject', this.selectedProject);
|
|
|
|
},
|
|
|
|
selectable: true,
|
|
|
|
data: (term, callback) => {
|
|
|
|
this.loading = true;
|
2018-08-01 12:17:56 -04:00
|
|
|
return Api.groupProjects(this.groupId, term, {}, projects => {
|
2018-05-28 05:47:59 -04:00
|
|
|
this.loading = false;
|
|
|
|
callback(projects);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
renderRow(project) {
|
|
|
|
return `
|
2018-02-19 14:06:16 -05:00
|
|
|
<li>
|
|
|
|
<a href='#' class='dropdown-menu-link' data-project-id="${project.id}" data-project-name="${project.name}">
|
|
|
|
${_.escape(project.name)}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
`;
|
2018-05-28 05:47:59 -04:00
|
|
|
},
|
|
|
|
text: project => project.name,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
2018-02-19 14:06:16 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2018-07-19 18:11:31 -04:00
|
|
|
<label class="label-bold prepend-top-10">
|
2018-02-19 14:06:16 -05:00
|
|
|
Project
|
|
|
|
</label>
|
|
|
|
<div
|
|
|
|
ref="projectsDropdown"
|
|
|
|
class="dropdown"
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
class="dropdown-menu-toggle wide"
|
|
|
|
type="button"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
aria-expanded="false"
|
|
|
|
>
|
|
|
|
{{ selectedProjectName }}
|
|
|
|
<i
|
|
|
|
class="fa fa-chevron-down"
|
|
|
|
aria-hidden="true"
|
|
|
|
>
|
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
<div class="dropdown-menu dropdown-menu-selectable dropdown-menu-full-width">
|
|
|
|
<div class="dropdown-title">
|
|
|
|
<span>Projects</span>
|
|
|
|
<button
|
|
|
|
aria-label="Close"
|
|
|
|
type="button"
|
|
|
|
class="dropdown-title-button dropdown-menu-close"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
aria-hidden="true"
|
|
|
|
data-hidden="true"
|
|
|
|
class="fa fa-times dropdown-menu-close-icon"
|
|
|
|
>
|
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="dropdown-input">
|
|
|
|
<input
|
|
|
|
class="dropdown-input-field"
|
|
|
|
type="search"
|
|
|
|
placeholder="Search projects"
|
|
|
|
/>
|
|
|
|
<i
|
|
|
|
aria-hidden="true"
|
|
|
|
data-hidden="true"
|
|
|
|
class="fa fa-search dropdown-input-search"
|
|
|
|
>
|
|
|
|
</i>
|
|
|
|
</div>
|
|
|
|
<div class="dropdown-content"></div>
|
|
|
|
<div class="dropdown-loading">
|
|
|
|
<loading-icon />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|