Commit 881e2d16 authored by Simon Knox's avatar Simon Knox

add Projects dropdown to New issue form

parent 28ee4ef7
......@@ -9,6 +9,10 @@ const Store = gl.issueBoards.BoardsStore;
export default {
name: 'BoardList',
props: {
groupId: {
type: Number,
required: false,
},
disabled: {
type: Boolean,
required: true,
......@@ -167,6 +171,7 @@ export default {
</div>
<transition name="slide-down">
<board-new-issue
:groupId="groupId"
:list="list"
v-if="list.type !== 'closed' && showIssueForm"/>
</transition>
......
/* global ListIssue */
import eventHub from '../eventhub';
import Api from '../../api';
const Store = gl.issueBoards.BoardsStore;
export default {
name: 'BoardNewIssue',
props: {
list: Object,
groupId: {
type: Number,
required: false,
},
list: {
type: Object,
required: true,
},
},
data() {
return {
title: '',
loading: true,
selectedProject: {},
projects: [],
error: false,
};
},
methods: {
loadProjects() {
this.loading = true;
Api.groupProjects(this.groupId, {}, (projects) => {
this.projects = projects;
this.loading = false;
});
},
submit(e) {
e.preventDefault();
if (this.title.trim() === '') return Promise.resolve();
......@@ -27,6 +45,7 @@ export default {
labels,
subscribed: true,
assignees: [],
project_id: this.selectedProject.id,
});
if (Store.state.currentBoard) {
......@@ -62,6 +81,18 @@ export default {
},
mounted() {
this.$refs.input.focus();
$(this.$refs.projectsDropdown).glDropdown({
filterable: true,
filterRemote: true,
search: {
fields: ['name_with_namespace'],
},
data(term, callback) {
console.log(term);
return Api.groupProjects(this.groupId, term, callback);
},
text: project => project.name,
});
},
template: `
<div class="card board-new-issue-form">
......@@ -82,6 +113,31 @@ export default {
ref="input"
autocomplete="off"
:id="list.id + '-title'" />
<div class="dropdown prepend-top-10">
<button
@click="loadProjects"
class="dropdown-menu-toggle"
type="button"
data-toggle="dropdown"
aria-expanded="false">
{{ selectedProject.name || 'Select a project' }}
<i class="fa fa-chevron-down"></i>
</button>
<div class="dropdown-menu dropdown-menu-selectable">
<ul>
<li v-for="project in projects">
<a
href="#"
role="button"
:class="{ 'is-active': project.id == selectedProject.id }"
@click.prevent="selectedProject = project">
{{ project.name }}
</a>
</li>
</ul>
</div>
</div>
<div class="clearfix prepend-top-10">
<button class="btn btn-success pull-left"
type="submit"
......
......@@ -19,8 +19,8 @@ class ListIssue {
this.position = obj.relative_position || Infinity;
this.milestone_id = obj.milestone_id;
this.updateUrl = obj.update_url;
this.canEdit = obj.can_edit;
this.projectId = obj.project_id;
this.canEdit = true; //obj.can_edit;
this.project_id = obj.project_id;
if (obj.milestone) {
this.milestone = new ListMilestone(obj.milestone);
......
......@@ -209,6 +209,12 @@
padding: $gl-padding;
font-size: 1em;
border-bottom: 1px solid $border-color;
display: flex;
align-items: center;
}
.board-title-text {
margin-right: auto;
}
.board-delete {
......
......@@ -6,10 +6,16 @@
%i.fa.fa-fw.board-title-expandable-toggle{ "v-if": "list.isExpandable",
":class": "{ \"fa-caret-down\": list.isExpanded, \"fa-caret-right\": !list.isExpanded && list.position === -1, \"fa-caret-left\": !list.isExpanded && list.position !== -1 }",
"aria-hidden": "true" }
%span.has-tooltip{ ":title" => '(list.label ? list.label.description : "")',
%span.board-title-text.has-tooltip{ ":title" => '(list.label ? list.label.description : "")',
data: { container: "body", placement: "bottom" } }
{{ list.title }}
.issue-count-badge.pull-right.clearfix{ "v-if" => 'list.type !== "blank"' }
- if can?(current_user, :admin_list, current_board_parent)
%board-delete{ "inline-template" => true,
":list" => "list",
"v-if" => "!list.preset && list.id" }
%button.board-delete.has-tooltip.btn.btn-transparent.link-highlight{ type: "button", title: "Delete list", "aria-label" => "Delete list", data: { placement: "bottom" }, "@click.stop" => "deleteBoard" }
= icon("trash")
.issue-count-badge.clearfix{ "v-if" => 'list.type !== "blank"' }
%span.issue-count-badge-count.pull-left{ ":class" => '{ "has-btn": list.type !== "closed" && !disabled }' }
{{ list.issuesSize }}
- if can?(current_user, :admin_list, current_board_parent)
......@@ -20,12 +26,6 @@
"title" => "New issue",
data: { placement: "top", container: "body" } }
= icon("plus", class: "js-no-trigger-collapse")
- if can?(current_user, :admin_list, current_board_parent)
%board-delete{ "inline-template" => true,
":list" => "list",
"v-if" => "!list.preset && list.id" }
%button.board-delete.has-tooltip.pull-right{ type: "button", title: "Delete list", "aria-label" => "Delete list", data: { placement: "bottom" }, "@click.stop" => "deleteBoard" }
= icon("trash")
%board-list{ "v-if" => 'list.type !== "blank"',
":list" => "list",
":issues" => "list.issues",
......@@ -33,6 +33,7 @@
":disabled" => "disabled",
":issue-link-base" => "issueLinkBase",
":root-path" => "rootPath",
":groupId" => (current_board_parent.id if @group),
"ref" => "board-list" }
- if can?(current_user, :admin_list, current_board_parent)
%board-blank-state{ "v-if" => 'list.id == "blank"' }
......@@ -33,5 +33,5 @@
= icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
= render partial: "shared/issuable/label_page_default"
- if can? current_user, :admin_label, @project and @project
- if can?(current_user, :admin_label, current_board_parent)
= render partial: "shared/issuable/label_page_create"
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