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

Added ability to save the new issue

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