summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/boards')
-rw-r--r--app/assets/javascripts/boards/components/board.js15
-rw-r--r--app/assets/javascripts/boards/components/new_list_dropdown.js25
-rw-r--r--app/assets/javascripts/boards/models/issue.js25
-rw-r--r--app/assets/javascripts/boards/models/list.js14
-rw-r--r--app/assets/javascripts/boards/services/board_service.js6
-rw-r--r--app/assets/javascripts/boards/stores/boards_store.js5
-rw-r--r--app/assets/javascripts/boards/stores/boards_store_ee.js2
7 files changed, 57 insertions, 35 deletions
diff --git a/app/assets/javascripts/boards/components/board.js b/app/assets/javascripts/boards/components/board.js
index c6122fbc686..58759fd1efe 100644
--- a/app/assets/javascripts/boards/components/board.js
+++ b/app/assets/javascripts/boards/components/board.js
@@ -50,6 +50,9 @@ export default Vue.extend({
};
},
computed: {
+ isLoggedIn() {
+ return Boolean(gon.current_user_id);
+ },
counterTooltip() {
const { issuesSize } = this.list;
return `${n__('%d issue', '%d issues', issuesSize)}`;
@@ -106,7 +109,11 @@ export default Vue.extend({
Sortable.create(this.$el.parentNode, sortableOptions);
},
created() {
- if (this.list.isExpandable && AccessorUtilities.isLocalStorageAccessSafe()) {
+ if (
+ this.list.isExpandable &&
+ AccessorUtilities.isLocalStorageAccessSafe() &&
+ !this.isLoggedIn
+ ) {
const isCollapsed = localStorage.getItem(`${this.uniqueKey}.expanded`) === 'false';
this.list.isExpanded = !isCollapsed;
@@ -120,10 +127,14 @@ export default Vue.extend({
if (this.list.isExpandable) {
this.list.isExpanded = !this.list.isExpanded;
- if (AccessorUtilities.isLocalStorageAccessSafe()) {
+ if (AccessorUtilities.isLocalStorageAccessSafe() && !this.isLoggedIn) {
localStorage.setItem(`${this.uniqueKey}.expanded`, this.list.isExpanded);
}
+ if (this.isLoggedIn) {
+ this.list.update();
+ }
+
// When expanding/collapsing, the tooltip on the caret button sometimes stays open.
// Close all tooltips manually to prevent dangling tooltips.
$('.tooltip').tooltip('hide');
diff --git a/app/assets/javascripts/boards/components/new_list_dropdown.js b/app/assets/javascripts/boards/components/new_list_dropdown.js
index c8a9cb1c296..229bb82152b 100644
--- a/app/assets/javascripts/boards/components/new_list_dropdown.js
+++ b/app/assets/javascripts/boards/components/new_list_dropdown.js
@@ -1,7 +1,9 @@
-/* eslint-disable func-names, no-new, promise/catch-or-return */
+/* eslint-disable func-names, no-new */
import $ from 'jquery';
+import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils';
+import flash from '~/flash';
import CreateLabelDropdown from '../../create_label';
import boardsStore from '../stores/boards_store';
@@ -26,18 +28,23 @@ $(document)
export default function initNewListDropdown() {
$('.js-new-board-list').each(function() {
- const $this = $(this);
+ const $dropdownToggle = $(this);
+ const $dropdown = $dropdownToggle.closest('.dropdown');
new CreateLabelDropdown(
- $this.closest('.dropdown').find('.dropdown-new-label'),
- $this.data('namespacePath'),
- $this.data('projectPath'),
+ $dropdown.find('.dropdown-new-label'),
+ $dropdownToggle.data('namespacePath'),
+ $dropdownToggle.data('projectPath'),
);
- $this.glDropdown({
+ $dropdownToggle.glDropdown({
data(term, callback) {
- axios.get($this.attr('data-list-labels-path')).then(({ data }) => {
- callback(data);
- });
+ axios
+ .get($dropdownToggle.attr('data-list-labels-path'))
+ .then(({ data }) => callback(data))
+ .catch(() => {
+ $dropdownToggle.data('bs.dropdown').hide();
+ flash(__('Error fetching labels.'));
+ });
},
renderRow(label) {
const active = boardsStore.findListByLabelId(label.id);
diff --git a/app/assets/javascripts/boards/models/issue.js b/app/assets/javascripts/boards/models/issue.js
index 086340105b7..1cee9e5725a 100644
--- a/app/assets/javascripts/boards/models/issue.js
+++ b/app/assets/javascripts/boards/models/issue.js
@@ -11,11 +11,6 @@ import boardsStore from '../stores/boards_store';
class ListIssue {
constructor(obj, defaultAvatar) {
- this.id = obj.id;
- this.iid = obj.iid;
- this.title = obj.title;
- this.confidential = obj.confidential;
- this.dueDate = obj.due_date;
this.subscribed = obj.subscribed;
this.labels = [];
this.assignees = [];
@@ -25,6 +20,16 @@ class ListIssue {
subscriptions: true,
};
this.isLoading = {};
+
+ this.refreshData(obj, defaultAvatar);
+ }
+
+ refreshData(obj, defaultAvatar) {
+ this.id = obj.id;
+ this.iid = obj.iid;
+ this.title = obj.title;
+ this.confidential = obj.confidential;
+ this.dueDate = obj.due_date;
this.sidebarInfoEndpoint = obj.issue_sidebar_endpoint;
this.referencePath = obj.reference_path;
this.path = obj.real_path;
@@ -42,11 +47,13 @@ class ListIssue {
this.milestone_id = obj.milestone.id;
}
- obj.labels.forEach(label => {
- this.labels.push(new ListLabel(label));
- });
+ if (obj.labels) {
+ this.labels = obj.labels.map(label => new ListLabel(label));
+ }
- this.assignees = obj.assignees.map(a => new ListAssignee(a, defaultAvatar));
+ if (obj.assignees) {
+ this.assignees = obj.assignees.map(a => new ListAssignee(a, defaultAvatar));
+ }
}
addLabel(label) {
diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js
index 1edaf971afd..b3e56a34c28 100644
--- a/app/assets/javascripts/boards/models/list.js
+++ b/app/assets/javascripts/boards/models/list.js
@@ -1,4 +1,4 @@
-/* eslint-disable no-underscore-dangle, class-methods-use-this, consistent-return, no-shadow, no-param-reassign */
+/* eslint-disable no-underscore-dangle, class-methods-use-this, consistent-return, no-shadow */
import { __ } from '~/locale';
import ListLabel from './label';
@@ -45,7 +45,7 @@ class List {
const typeInfo = this.getTypeInfo(this.type);
this.preset = Boolean(typeInfo.isPreset);
this.isExpandable = Boolean(typeInfo.isExpandable);
- this.isExpanded = true;
+ this.isExpanded = !obj.collapsed;
this.page = 1;
this.loading = true;
this.loadingMore = false;
@@ -113,7 +113,8 @@ class List {
}
update() {
- gl.boardService.updateList(this.id, this.position).catch(() => {
+ const collapsed = !this.isExpanded;
+ return gl.boardService.updateList(this.id, this.position, collapsed).catch(() => {
// TODO: handle request error
});
}
@@ -259,12 +260,7 @@ class List {
}
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;
- issue.assignableLabelsEndpoint = data.assignable_labels_endpoint;
+ issue.refreshData(data);
if (this.issuesSize > 1) {
const moveBeforeId = this.issues[1].id;
diff --git a/app/assets/javascripts/boards/services/board_service.js b/app/assets/javascripts/boards/services/board_service.js
index 56a6cab6c73..0d11db89511 100644
--- a/app/assets/javascripts/boards/services/board_service.js
+++ b/app/assets/javascripts/boards/services/board_service.js
@@ -2,7 +2,7 @@
/**
* This file is intended to be deleted.
* The existing functions will removed one by one in favor of using the board store directly.
- * see https://gitlab.com/gitlab-org/gitlab-ce/issues/61621
+ * see https://gitlab.com/gitlab-org/gitlab-foss/issues/61621
*/
import boardsStore from '~/boards/stores/boards_store';
@@ -32,8 +32,8 @@ export default class BoardService {
return boardsStore.createList(entityId, entityType);
}
- updateList(id, position) {
- return boardsStore.updateList(id, position);
+ updateList(id, position, collapsed) {
+ return boardsStore.updateList(id, position, collapsed);
}
destroyList(id) {
diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js
index f57c684691c..6da1cca9628 100644
--- a/app/assets/javascripts/boards/stores/boards_store.js
+++ b/app/assets/javascripts/boards/stores/boards_store.js
@@ -82,7 +82,7 @@ const boardsStore = {
this.state.lists = _.sortBy(this.state.lists, 'position');
})
.catch(() => {
- // https://gitlab.com/gitlab-org/gitlab-ce/issues/30821
+ // https://gitlab.com/gitlab-org/gitlab-foss/issues/30821
});
this.removeBlankState();
},
@@ -278,10 +278,11 @@ const boardsStore = {
});
},
- updateList(id, position) {
+ updateList(id, position, collapsed) {
return axios.put(`${this.state.endpoints.listsEndpoint}/${id}`, {
list: {
position,
+ collapsed,
},
});
},
diff --git a/app/assets/javascripts/boards/stores/boards_store_ee.js b/app/assets/javascripts/boards/stores/boards_store_ee.js
index 09e3a938fbe..2a289ce5d0a 100644
--- a/app/assets/javascripts/boards/stores/boards_store_ee.js
+++ b/app/assets/javascripts/boards/stores/boards_store_ee.js
@@ -1,4 +1,4 @@
-// this is just to make ee_else_ce happy and will be cleaned up in https://gitlab.com/gitlab-org/gitlab-ce/issues/59807
+// this is just to make ee_else_ce happy and will be cleaned up in https://gitlab.com/gitlab-org/gitlab-foss/issues/59807
export default {
initEESpecific() {},