summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-10-19 22:26:51 +0100
committerPhil Hughes <me@iamphill.com>2016-10-19 22:26:51 +0100
commitcd5e83b6d6da3bddbc44334a1bcdbac287b35fb4 (patch)
tree8a35049f45fa6d6f1274eaa39c49fb5bacaba546
parenta0f6526f02ac855027d7dfe763aab4b2a9978dca (diff)
downloadgitlab-ce-cd5e83b6d6da3bddbc44334a1bcdbac287b35fb4.tar.gz
Scroll board into view when clicking issue
Changed return statement instead of if Delete objects after issue is closed
-rw-r--r--app/assets/javascripts/boards/boards_bundle.js.es68
-rw-r--r--app/assets/javascripts/boards/components/board.js.es621
-rw-r--r--app/assets/javascripts/boards/components/board_card.js.es66
-rw-r--r--app/assets/javascripts/boards/components/board_sidebar.js.es619
-rw-r--r--app/assets/stylesheets/pages/boards.scss4
-rw-r--r--app/views/projects/boards/components/_sidebar.html.haml2
-rw-r--r--app/views/projects/boards/index.html.haml2
-rw-r--r--app/views/projects/boards/show.html.haml2
8 files changed, 49 insertions, 15 deletions
diff --git a/app/assets/javascripts/boards/boards_bundle.js.es6 b/app/assets/javascripts/boards/boards_bundle.js.es6
index 0cecdc4f50a..56f91503017 100644
--- a/app/assets/javascripts/boards/boards_bundle.js.es6
+++ b/app/assets/javascripts/boards/boards_bundle.js.es6
@@ -33,9 +33,15 @@ $(() => {
endpoint: $boardApp.dataset.endpoint,
boardId: $boardApp.dataset.boardId,
disabled: $boardApp.dataset.disabled === 'true',
- issueLinkBase: $boardApp.dataset.issueLinkBase
+ issueLinkBase: $boardApp.dataset.issueLinkBase,
+ detailIssue: Store.detail
},
init: Store.create.bind(Store),
+ computed: {
+ detailIssueVisible () {
+ return Object.keys(this.detailIssue.issue).length;
+ }
+ },
created () {
gl.boardService = new BoardService(this.endpoint, this.boardId);
},
diff --git a/app/assets/javascripts/boards/components/board.js.es6 b/app/assets/javascripts/boards/components/board.js.es6
index cacb36a897f..500213a3a43 100644
--- a/app/assets/javascripts/boards/components/board.js.es6
+++ b/app/assets/javascripts/boards/components/board.js.es6
@@ -21,6 +21,7 @@
},
data () {
return {
+ detailIssue: Store.detail,
filters: Store.state.filters,
showIssueForm: false
};
@@ -32,6 +33,26 @@
this.list.getIssues(true);
},
deep: true
+ },
+ detailIssue: {
+ handler () {
+ if (!Object.keys(this.detailIssue.issue).length) return;
+
+ const issue = this.list.findIssue(this.detailIssue.issue.id);
+
+ if (issue) {
+ const boardsList = document.querySelectorAll('.boards-list')[0];
+ const right = (this.$el.offsetLeft + this.$el.offsetWidth) - boardsList.offsetWidth;
+ const left = boardsList.scrollLeft - this.$el.offsetLeft;
+
+ if (right - boardsList.scrollLeft > 0) {
+ boardsList.scrollLeft = right;
+ } else if (left > 0) {
+ boardsList.scrollLeft = this.$el.offsetLeft;
+ }
+ }
+ },
+ deep: true
}
},
methods: {
diff --git a/app/assets/javascripts/boards/components/board_card.js.es6 b/app/assets/javascripts/boards/components/board_card.js.es6
index bcb1b60b978..f743d72f936 100644
--- a/app/assets/javascripts/boards/components/board_card.js.es6
+++ b/app/assets/javascripts/boards/components/board_card.js.es6
@@ -20,11 +20,7 @@
},
computed: {
issueDetailVisible () {
- if (this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id) {
- return true;
- } else {
- return false;
- }
+ return this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id;
}
},
methods: {
diff --git a/app/assets/javascripts/boards/components/board_sidebar.js.es6 b/app/assets/javascripts/boards/components/board_sidebar.js.es6
index 1c002a54bed..35d97531439 100644
--- a/app/assets/javascripts/boards/components/board_sidebar.js.es6
+++ b/app/assets/javascripts/boards/components/board_sidebar.js.es6
@@ -29,15 +29,22 @@
issue () {
if (this.showSidebar) {
this.$nextTick(() => {
- new IssuableContext(this.currentUser);
- new MilestoneSelect();
- new gl.DueDateSelectors();
- new LabelsSelect();
- new Sidebar();
- new Subscription('.subscription');
+ this.issuableContext = new IssuableContext(this.currentUser);
+ this.milestoneSelect = new MilestoneSelect();
+ this.dueDateSelect = new gl.DueDateSelectors();
+ this.labelsSelect = new LabelsSelect();
+ this.sidebar = new Sidebar();
+ this.subscription = new Subscription('.subscription');
});
} else {
$('.right-sidebar').getNiceScroll().remove();
+
+ delete this.issuableContext;
+ delete this.milestoneSelect;
+ delete this.dueDateSelect;
+ delete this.labelsSelect;
+ delete this.sidebar;
+ delete this.subscription;
}
}
},
diff --git a/app/assets/stylesheets/pages/boards.scss b/app/assets/stylesheets/pages/boards.scss
index 0807d583207..8e972020234 100644
--- a/app/assets/stylesheets/pages/boards.scss
+++ b/app/assets/stylesheets/pages/boards.scss
@@ -76,6 +76,10 @@ lex
height: 475px; // Needed for PhantomJS
height: calc(100vh - 220px);
min-height: 475px;
+
+ &.is-compact {
+ width: calc(100% - 290px);
+ }
}
}
diff --git a/app/views/projects/boards/components/_sidebar.html.haml b/app/views/projects/boards/components/_sidebar.html.haml
index cf70ad4927a..7907fdfa810 100644
--- a/app/views/projects/boards/components/_sidebar.html.haml
+++ b/app/views/projects/boards/components/_sidebar.html.haml
@@ -12,7 +12,7 @@
{{ issue.id }}
%a.gutter-toggle.pull-right{ role: "button",
href: "#",
- "@click" => "closeSidebar",
+ "@click.prevent" => "closeSidebar",
"aria-label" => "Toggle sidebar" }
= icon("times")
.js-issuable-update
diff --git a/app/views/projects/boards/index.html.haml b/app/views/projects/boards/index.html.haml
index 45c2e0ee2da..29c9a43a0c1 100644
--- a/app/views/projects/boards/index.html.haml
+++ b/app/views/projects/boards/index.html.haml
@@ -11,7 +11,7 @@
= render 'shared/issuable/filter', type: :boards
#board-app.boards-app{ "v-cloak" => true, data: board_data }
- .boards-list
+ .boards-list{ ":class" => "{ 'is-compact': detailIssueVisible }" }
.boards-app-loading.text-center{ "v-if" => "loading" }
= icon("spinner spin")
= render "projects/boards/components/board"
diff --git a/app/views/projects/boards/show.html.haml b/app/views/projects/boards/show.html.haml
index 45c2e0ee2da..29c9a43a0c1 100644
--- a/app/views/projects/boards/show.html.haml
+++ b/app/views/projects/boards/show.html.haml
@@ -11,7 +11,7 @@
= render 'shared/issuable/filter', type: :boards
#board-app.boards-app{ "v-cloak" => true, data: board_data }
- .boards-list
+ .boards-list{ ":class" => "{ 'is-compact': detailIssueVisible }" }
.boards-app-loading.text-center{ "v-if" => "loading" }
= icon("spinner spin")
= render "projects/boards/components/board"