summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-10-03 14:29:21 +0100
committerPhil Hughes <me@iamphill.com>2016-10-06 11:00:01 +0100
commit4d9f76c15115d3fd48d61e998edca86917fb1ccf (patch)
tree1bd8bce6f935c1b5785d8dab310ef900c028a0e8
parent4241c2906c9531ab7ddb43740b222a102f5508fa (diff)
downloadgitlab-ce-4d9f76c15115d3fd48d61e998edca86917fb1ccf.tar.gz
Added ability to save the new issue
-rw-r--r--app/assets/javascripts/boards/components/board_list.js.es62
-rw-r--r--app/assets/javascripts/boards/components/board_new_issue.js.es615
-rw-r--r--app/assets/javascripts/boards/mixins/sortable_default_options.js.es62
-rw-r--r--app/assets/javascripts/boards/models/list.js.es611
-rw-r--r--app/assets/javascripts/boards/services/board_service.js.es68
-rw-r--r--app/controllers/projects/boards/issues_controller.rb13
-rw-r--r--app/views/projects/boards/components/_board.html.haml8
-rw-r--r--config/routes/project.rb2
8 files changed, 54 insertions, 7 deletions
diff --git a/app/assets/javascripts/boards/components/board_list.js.es6 b/app/assets/javascripts/boards/components/board_list.js.es6
index d2e905ae062..208aac504fd 100644
--- a/app/assets/javascripts/boards/components/board_list.js.es6
+++ b/app/assets/javascripts/boards/components/board_list.js.es6
@@ -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];
diff --git a/app/assets/javascripts/boards/components/board_new_issue.js.es6 b/app/assets/javascripts/boards/components/board_new_issue.js.es6
index 057844f3ebb..60c13afefeb 100644
--- a/app/assets/javascripts/boards/components/board_new_issue.js.es6
+++ b/app/assets/javascripts/boards/components/board_new_issue.js.es6
@@ -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 = '';
}
}
});
diff --git a/app/assets/javascripts/boards/mixins/sortable_default_options.js.es6 b/app/assets/javascripts/boards/mixins/sortable_default_options.js.es6
index 44addb3ea98..f629d45c587 100644
--- a/app/assets/javascripts/boards/mixins/sortable_default_options.js.es6
+++ b/app/assets/javascripts/boards/mixins/sortable_default_options.js.es6
@@ -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,
diff --git a/app/assets/javascripts/boards/models/list.js.es6 b/app/assets/javascripts/boards/models/list.js.es6
index 91fd620fdb3..14e42db4cd2 100644
--- a/app/assets/javascripts/boards/models/list.js.es6
+++ b/app/assets/javascripts/boards/models/list.js.es6
@@ -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));
diff --git a/app/assets/javascripts/boards/services/board_service.js.es6 b/app/assets/javascripts/boards/services/board_service.js.es6
index 9b80fb2e99f..c8b1d4f2b5a 100644
--- a/app/assets/javascripts/boards/services/board_service.js.es6
+++ b/app/assets/javascripts/boards/services/board_service.js.es6
@@ -58,4 +58,12 @@ class BoardService {
to_list_id
});
}
+
+ newIssue (id, issue) {
+ return this.issues.save({ id }, {
+ issue: {
+ title: issue.title
+ }
+ });
+ }
};
diff --git a/app/controllers/projects/boards/issues_controller.rb b/app/controllers/projects/boards/issues_controller.rb
index 4aa7982eab4..41794193784 100644
--- a/app/controllers/projects/boards/issues_controller.rb
+++ b/app/controllers/projects/boards/issues_controller.rb
@@ -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
diff --git a/app/views/projects/boards/components/_board.html.haml b/app/views/projects/boards/components/_board.html.haml
index 6c95812aebd..bd60e56a340 100644
--- a/app/views/projects/boards/components/_board.html.haml
+++ b/app/views/projects/boards/components/_board.html.haml
@@ -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 === ''" }
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 224ec7e8324..14d986c9475 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -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