2018-03-27 19:54:05 +05:30
|
|
|
<script>
|
2018-11-08 19:23:39 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
import _ from 'underscore';
|
2018-12-13 13:39:08 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import { GlLoadingIcon } from '@gitlab-org/gitlab-ui';
|
2018-11-08 19:23:39 +05:30
|
|
|
import eventHub from '../eventhub';
|
|
|
|
import Api from '../../api';
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
export default {
|
|
|
|
name: 'BoardProjectSelect',
|
2018-12-13 13:39:08 +05:30
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
GlLoadingIcon,
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
props: {
|
|
|
|
groupId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
default: 0,
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
selectedProject: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
selectedProjectName() {
|
|
|
|
return this.selectedProject.name || 'Select a project';
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
$(this.$refs.projectsDropdown).glDropdown({
|
|
|
|
filterable: true,
|
|
|
|
filterRemote: true,
|
|
|
|
search: {
|
|
|
|
fields: ['name_with_namespace'],
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
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-12-13 13:39:08 +05:30
|
|
|
return Api.groupProjects(this.groupId, term, { with_issues_enabled: true }, projects => {
|
2018-11-08 19:23:39 +05:30
|
|
|
this.loading = false;
|
|
|
|
callback(projects);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
renderRow(project) {
|
|
|
|
return `
|
2018-03-27 19:54:05 +05:30
|
|
|
<li>
|
2018-12-13 13:39:08 +05:30
|
|
|
<a href='#' class='dropdown-menu-link' data-project-id="${
|
|
|
|
project.id
|
|
|
|
}" data-project-name="${project.name}">
|
2018-03-27 19:54:05 +05:30
|
|
|
${_.escape(project.name)}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
`;
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
text: project => project.name,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
2018-03-27 19:54:05 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2018-11-18 11:00:15 +05:30
|
|
|
<label class="label-bold prepend-top-10">
|
2018-03-27 19:54:05 +05:30
|
|
|
Project
|
|
|
|
</label>
|
|
|
|
<div
|
|
|
|
ref="projectsDropdown"
|
|
|
|
class="dropdown"
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
class="dropdown-menu-toggle wide"
|
|
|
|
type="button"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
aria-expanded="false"
|
|
|
|
>
|
|
|
|
{{ selectedProjectName }}
|
2018-12-13 13:39:08 +05:30
|
|
|
<icon
|
|
|
|
name="chevron-down"
|
|
|
|
/>
|
2018-03-27 19:54:05 +05:30
|
|
|
</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"
|
|
|
|
>
|
2018-12-13 13:39:08 +05:30
|
|
|
<icon
|
|
|
|
name="merge-request-close-m"
|
2018-03-27 19:54:05 +05:30
|
|
|
data-hidden="true"
|
2018-12-13 13:39:08 +05:30
|
|
|
class="dropdown-menu-close-icon"
|
|
|
|
/>
|
2018-03-27 19:54:05 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="dropdown-input">
|
|
|
|
<input
|
|
|
|
class="dropdown-input-field"
|
|
|
|
type="search"
|
|
|
|
placeholder="Search projects"
|
|
|
|
/>
|
2018-12-13 13:39:08 +05:30
|
|
|
<icon
|
|
|
|
name="search"
|
|
|
|
class="dropdown-input-search"
|
2018-03-27 19:54:05 +05:30
|
|
|
data-hidden="true"
|
2018-12-13 13:39:08 +05:30
|
|
|
/>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
|
|
|
<div class="dropdown-content"></div>
|
|
|
|
<div class="dropdown-loading">
|
2018-12-05 23:21:45 +05:30
|
|
|
<gl-loading-icon />
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|