Commit 4d9f76c1 authored by Phil Hughes's avatar Phil Hughes

Added ability to save the new issue

parent 4241c290
......@@ -76,7 +76,7 @@
group: 'issues',
sort: false,
disabled: this.disabled,
filter: '.board-list-count',
filter: '.board-list-count, .board-new-issue-form',
onStart: (e) => {
const card = this.$refs.issue[e.oldIndex];
......
......@@ -3,6 +3,7 @@
gl.issueBoards.BoardNewIssue = Vue.extend({
props: {
list: Object,
showIssueForm: Boolean
},
data() {
......@@ -10,14 +11,26 @@
title: ''
};
},
watch: {
showIssueForm () {
this.$els.input.focus();
}
},
methods: {
submit(e) {
e.preventDefault();
const issue = new ListIssue({
title: this.title,
labels: [this.list.label]
});
this.title = '';
this.list.newIssue(issue);
this.cancel();
},
cancel() {
this.showIssueForm = false;
this.title = '';
}
}
});
......
......@@ -21,7 +21,7 @@
fallbackClass: 'is-dragging',
fallbackOnBody: true,
ghostClass: 'is-ghost',
filter: '.has-tooltip',
filter: '.has-tooltip, .btn',
delay: gl.issueBoards.touchEnabled ? 100 : 0,
scrollSensitivity: gl.issueBoards.touchEnabled ? 60 : 100,
scrollSpeed: 20,
......
......@@ -87,6 +87,17 @@ class List {
});
}
newIssue (issue) {
this.addIssue(issue);
this.issuesSize++;
gl.boardService.newIssue(this.id, issue)
.then((resp) => {
const data = resp.json();
issue.id = data.iid;
});
}
createIssues (data) {
data.forEach((issueObj) => {
this.addIssue(new ListIssue(issueObj));
......
......@@ -58,4 +58,12 @@ class BoardService {
to_list_id
});
}
newIssue (id, issue) {
return this.issues.save({ id }, {
issue: {
title: issue.title
}
});
}
};
......@@ -19,6 +19,15 @@ module Projects
}
end
def create
list = project.board.lists.find(params[:list_id])
issue = Issues::CreateService.new(project, current_user, issue_params.merge(request: request)).execute
issue.labels << list.label
render json: issue.to_json
end
def update
service = ::Boards::Issues::MoveService.new(project, current_user, move_params)
......@@ -54,6 +63,10 @@ module Projects
def move_params
params.permit(:id, :from_list_id, :to_list_id)
end
def issue_params
params.require(:issue).permit(:title)
end
end
end
end
......@@ -42,14 +42,16 @@
":data-board" => "list.id" }
- if can? current_user, :create_issue, @project
%board-new-issue{ "inline-template" => true,
":list" => "list",
":show-issue-form.sync" => "showIssueForm",
"v-if" => "list.type !== 'done' && showIssueForm" }
%li.card
"v-show" => "list.type !== 'done' && showIssueForm" }
%li.card.board-new-issue-form
%form{ "@submit" => "submit($event)" }
%label.label-light
Title
%input.form-control{ type: "text",
"v-model" => "title" }
"v-model" => "title",
"v-el:input" => true }
.clearfix.prepend-top-10
%button.btn.btn-success.pull-left{ type: "submit",
":disabled" => "title === ''" }
......
......@@ -424,7 +424,7 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only:
post :generate
end
resources :issues, only: [:index]
resources :issues, only: [:index, :create]
end
end
end
......
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