summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2018-07-03 16:19:29 -0500
committerPaul Slaughter <pslaughter@gitlab.com>2018-07-03 16:19:29 -0500
commit21843c2c12f8a5410addbd60014fb73283a3cc55 (patch)
treea2c8a16b378c70fe28a3edeef3e086181bbd028d /app/assets/javascripts/boards
parent26998c68c936f183ead1a84e404a61160fc646f7 (diff)
downloadgitlab-ce-21843c2c12f8a5410addbd60014fb73283a3cc55.tar.gz
Port of EE refactoring to extract EE lines from boards
Diffstat (limited to 'app/assets/javascripts/boards')
-rw-r--r--app/assets/javascripts/boards/components/modal/footer.vue22
-rw-r--r--app/assets/javascripts/boards/components/modal/list.vue3
-rw-r--r--app/assets/javascripts/boards/components/sidebar/remove_issue.vue41
-rw-r--r--app/assets/javascripts/boards/models/issue.js1
-rw-r--r--app/assets/javascripts/boards/models/list.js60
5 files changed, 90 insertions, 37 deletions
diff --git a/app/assets/javascripts/boards/components/modal/footer.vue b/app/assets/javascripts/boards/components/modal/footer.vue
index e0dac6003f1..d4affc8c3de 100644
--- a/app/assets/javascripts/boards/components/modal/footer.vue
+++ b/app/assets/javascripts/boards/components/modal/footer.vue
@@ -28,23 +28,29 @@ export default {
},
},
methods: {
+ buildUpdateRequest(list) {
+ return {
+ add_label_ids: [list.label.id],
+ };
+ },
addIssues() {
const firstListIndex = 1;
const list = this.modal.selectedList || this.state.lists[firstListIndex];
const selectedIssues = ModalStore.getSelectedIssues();
const issueIds = selectedIssues.map(issue => issue.id);
+ const req = this.buildUpdateRequest(list);
// Post the data to the backend
- gl.boardService.bulkUpdate(issueIds, {
- add_label_ids: [list.label.id],
- }).catch(() => {
- Flash(__('Failed to update issues, please try again.'));
+ gl.boardService
+ .bulkUpdate(issueIds, req)
+ .catch(() => {
+ Flash(__('Failed to update issues, please try again.'));
- selectedIssues.forEach((issue) => {
- list.removeIssue(issue);
- list.issuesSize -= 1;
+ selectedIssues.forEach((issue) => {
+ list.removeIssue(issue);
+ list.issuesSize -= 1;
+ });
});
- });
// Add the issues on the frontend
selectedIssues.forEach((issue) => {
diff --git a/app/assets/javascripts/boards/components/modal/list.vue b/app/assets/javascripts/boards/components/modal/list.vue
index 02ac36d7367..a58b5afe970 100644
--- a/app/assets/javascripts/boards/components/modal/list.vue
+++ b/app/assets/javascripts/boards/components/modal/list.vue
@@ -121,8 +121,7 @@
<div
v-if="issuesCount > 0 && issues.length === 0"
class="empty-state add-issues-empty-state-filter text-center">
- <div
- class="svg-content">
+ <div class="svg-content">
<img :src="emptyStateSvg" />
</div>
<div class="text-content">
diff --git a/app/assets/javascripts/boards/components/sidebar/remove_issue.vue b/app/assets/javascripts/boards/components/sidebar/remove_issue.vue
index 55278626ffc..90d4c710daf 100644
--- a/app/assets/javascripts/boards/components/sidebar/remove_issue.vue
+++ b/app/assets/javascripts/boards/components/sidebar/remove_issue.vue
@@ -5,7 +5,7 @@
const Store = gl.issueBoards.BoardsStore;
- export default {
+ export default Vue.extend({
props: {
issue: {
type: Object,
@@ -25,19 +25,16 @@
removeIssue() {
const { issue } = this;
const lists = issue.getLists();
- const listLabelIds = lists.map(list => list.label.id);
-
- let labelIds = issue.labels.map(label => label.id).filter(id => !listLabelIds.includes(id));
- if (labelIds.length === 0) {
- labelIds = [''];
- }
+ const req = this.buildPatchRequest(issue, lists);
const data = {
- issue: {
- label_ids: labelIds,
- },
+ issue: this.seedPatchRequest(issue, req),
};
+ if (data.issue.label_ids.length === 0) {
+ data.issue.label_ids = [''];
+ }
+
// Post the remove data
Vue.http.patch(this.updateUrl, data).catch(() => {
Flash(__('Failed to remove issue from board, please try again.'));
@@ -54,8 +51,30 @@
Store.detail.issue = {};
},
+ /**
+ * Build the default patch request.
+ */
+ buildPatchRequest(issue, lists) {
+ const listLabelIds = lists.map(list => list.label.id);
+
+ const labelIds = issue.labels
+ .map(label => label.id)
+ .filter(id => !listLabelIds.includes(id));
+
+ return {
+ label_ids: labelIds,
+ };
+ },
+ /**
+ * Seed the given patch request.
+ *
+ * (This is overridden in EE)
+ */
+ seedPatchRequest(issue, req) {
+ return req;
+ },
},
- };
+ });
</script>
<template>
<div
diff --git a/app/assets/javascripts/boards/models/issue.js b/app/assets/javascripts/boards/models/issue.js
index b85266b6bc3..c7cfb72067c 100644
--- a/app/assets/javascripts/boards/models/issue.js
+++ b/app/assets/javascripts/boards/models/issue.js
@@ -4,6 +4,7 @@
/* global ListAssignee */
import Vue from 'vue';
+import '~/vue_shared/models/label';
import IssueProject from './project';
class ListIssue {
diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js
index e35f277a865..4f05a0e4282 100644
--- a/app/assets/javascripts/boards/models/list.js
+++ b/app/assets/javascripts/boards/models/list.js
@@ -7,6 +7,24 @@ import queryData from '../utils/query_data';
const PER_PAGE = 20;
+const TYPES = {
+ backlog: {
+ isPreset: true,
+ isExpandable: true,
+ isBlank: false,
+ },
+ closed: {
+ isPreset: true,
+ isExpandable: true,
+ isBlank: false,
+ },
+ blank: {
+ isPreset: true,
+ isExpandable: false,
+ isBlank: true,
+ },
+};
+
class List {
constructor(obj, defaultAvatar) {
this.id = obj.id;
@@ -14,8 +32,10 @@ class List {
this.position = obj.position;
this.title = obj.title;
this.type = obj.list_type;
- this.preset = ['backlog', 'closed', 'blank'].indexOf(this.type) > -1;
- this.isExpandable = ['backlog', 'closed'].indexOf(this.type) > -1;
+
+ const typeInfo = this.getTypeInfo(this.type);
+ this.preset = !!typeInfo.isPreset;
+ this.isExpandable = !!typeInfo.isExpandable;
this.isExpanded = true;
this.page = 1;
this.loading = true;
@@ -31,7 +51,7 @@ class List {
this.title = this.assignee.name;
}
- if (this.type !== 'blank' && this.id) {
+ if (!typeInfo.isBlank && this.id) {
this.getIssues().catch(() => {
// TODO: handle request error
});
@@ -107,7 +127,7 @@ class List {
return gl.boardService
.getIssuesForList(this.id, data)
.then(res => res.data)
- .then((data) => {
+ .then(data => {
this.loading = false;
this.issuesSize = data.size;
@@ -126,18 +146,7 @@ class List {
return gl.boardService
.newIssue(this.id, issue)
.then(res => res.data)
- .then((data) => {
- issue.id = data.id;
- issue.iid = data.iid;
- issue.project = data.project;
- issue.path = data.real_path;
- issue.referencePath = data.reference_path;
-
- if (this.issuesSize > 1) {
- const moveBeforeId = this.issues[1].id;
- gl.boardService.moveIssue(issue.id, null, null, null, moveBeforeId);
- }
- });
+ .then(data => this.onNewIssueResponse(issue, data));
}
createIssues(data) {
@@ -217,6 +226,25 @@ class List {
return !matchesRemove;
});
}
+
+ getTypeInfo (type) {
+ return TYPES[type] || {};
+ }
+
+ onNewIssueResponse (issue, data) {
+ issue.id = data.id;
+ issue.iid = data.iid;
+ issue.project = data.project;
+ issue.path = data.real_path;
+ issue.referencePath = data.reference_path;
+
+ if (this.issuesSize > 1) {
+ const moveBeforeId = this.issues[1].id;
+ gl.boardService.moveIssue(issue.id, null, null, null, moveBeforeId);
+ }
+ }
}
window.List = List;
+
+export default List;