Commit 0e4e2d96 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'ee-move-board-list-vue-component' into 'master'

Move BoardList vue component to vue file

See merge request gitlab-org/gitlab-ee!4406
parents b6fed0ba 27aa4094
...@@ -3,7 +3,7 @@ import Sortable from 'vendor/Sortable'; ...@@ -3,7 +3,7 @@ import Sortable from 'vendor/Sortable';
import Vue from 'vue'; import Vue from 'vue';
import boardPromotionState from 'ee/boards/components/board_promotion_state'; import boardPromotionState from 'ee/boards/components/board_promotion_state';
import AccessorUtilities from '../../lib/utils/accessor'; import AccessorUtilities from '../../lib/utils/accessor';
import boardList from './board_list'; import boardList from './board_list.vue';
import boardBlankState from './board_blank_state'; import boardBlankState from './board_blank_state';
import './board_delete'; import './board_delete';
......
<script>
import Sortable from 'vendor/Sortable'; import Sortable from 'vendor/Sortable';
import boardNewIssue from './board_new_issue'; import boardNewIssue from './board_new_issue';
import boardCard from './board_card.vue'; import boardCard from './board_card.vue';
...@@ -8,6 +9,11 @@ const Store = gl.issueBoards.BoardsStore; ...@@ -8,6 +9,11 @@ const Store = gl.issueBoards.BoardsStore;
export default { export default {
name: 'BoardList', name: 'BoardList',
components: {
boardCard,
boardNewIssue,
loadingIcon,
},
props: { props: {
groupId: { groupId: {
type: Number, type: Number,
...@@ -47,46 +53,6 @@ export default { ...@@ -47,46 +53,6 @@ export default {
showIssueForm: false, showIssueForm: false,
}; };
}, },
components: {
boardCard,
boardNewIssue,
loadingIcon,
},
methods: {
listHeight() {
return this.$refs.list.getBoundingClientRect().height;
},
scrollHeight() {
return this.$refs.list.scrollHeight;
},
scrollTop() {
return this.$refs.list.scrollTop + this.listHeight();
},
scrollToTop() {
this.$refs.list.scrollTop = 0;
},
loadNextPage() {
const getIssues = this.list.nextPage();
const loadingDone = () => {
this.list.loadingMore = false;
};
if (getIssues) {
this.list.loadingMore = true;
getIssues
.then(loadingDone)
.catch(loadingDone);
}
},
toggleForm() {
this.showIssueForm = !this.showIssueForm;
},
onScroll() {
if (!this.list.loadingMore && (this.scrollTop() > this.scrollHeight() - this.scrollOffset)) {
this.loadNextPage();
}
},
},
watch: { watch: {
filters: { filters: {
handler() { handler() {
...@@ -143,7 +109,8 @@ export default { ...@@ -143,7 +109,8 @@ export default {
}); });
}, },
onUpdate: (e) => { onUpdate: (e) => {
const sortedArray = this.sortable.toArray().filter(id => id !== '-1'); const sortedArray = this.sortable.toArray()
.filter(id => id !== '-1');
gl.issueBoards.BoardsStore gl.issueBoards.BoardsStore
.moveIssueInList(this.list, Store.moving.issue, e.oldIndex, e.newIndex, sortedArray); .moveIssueInList(this.list, Store.moving.issue, e.oldIndex, e.newIndex, sortedArray);
}, },
...@@ -162,22 +129,56 @@ export default { ...@@ -162,22 +129,56 @@ export default {
eventHub.$off(`scroll-board-list-${this.list.id}`, this.scrollToTop); eventHub.$off(`scroll-board-list-${this.list.id}`, this.scrollToTop);
this.$refs.list.removeEventListener('scroll', this.onScroll); this.$refs.list.removeEventListener('scroll', this.onScroll);
}, },
template: ` methods: {
listHeight() {
return this.$refs.list.getBoundingClientRect().height;
},
scrollHeight() {
return this.$refs.list.scrollHeight;
},
scrollTop() {
return this.$refs.list.scrollTop + this.listHeight();
},
scrollToTop() {
this.$refs.list.scrollTop = 0;
},
loadNextPage() {
const getIssues = this.list.nextPage();
const loadingDone = () => {
this.list.loadingMore = false;
};
if (getIssues) {
this.list.loadingMore = true;
getIssues
.then(loadingDone)
.catch(loadingDone);
}
},
toggleForm() {
this.showIssueForm = !this.showIssueForm;
},
onScroll() {
if (!this.list.loadingMore && (this.scrollTop() > this.scrollHeight() - this.scrollOffset)) {
this.loadNextPage();
}
},
},
};
</script>
<template>
<div class="board-list-component"> <div class="board-list-component">
<div <div
key="loading"
class="board-list-loading text-center" class="board-list-loading text-center"
aria-label="Loading issues" aria-label="Loading issues"
v-if="loading"> v-if="loading">
<loading-icon /> <loading-icon />
</div> </div>
<board-new-issue <board-new-issue
key="newIssue"
:group-id="groupId"
:list="list" :list="list"
v-if="list.type !== 'closed' && showIssueForm"/> v-if="list.type !== 'closed' && showIssueForm"/>
<ul <ul
key="list"
class="board-list" class="board-list"
v-show="!loading" v-show="!loading"
ref="list" ref="list"
...@@ -190,7 +191,6 @@ export default { ...@@ -190,7 +191,6 @@ export default {
:list="list" :list="list"
:issue="issue" :issue="issue"
:issue-link-base="issueLinkBase" :issue-link-base="issueLinkBase"
:group-id="groupId"
:root-path="rootPath" :root-path="rootPath"
:disabled="disabled" :disabled="disabled"
:key="issue.id" /> :key="issue.id" />
...@@ -198,20 +198,21 @@ export default { ...@@ -198,20 +198,21 @@ export default {
class="board-list-count text-center" class="board-list-count text-center"
v-if="showCount" v-if="showCount"
data-issue-id="-1"> data-issue-id="-1">
<loading-icon <loading-icon
v-show="list.loadingMore" v-show="list.loadingMore"
label="Loading more issues" label="Loading more issues"
/> />
<span
<span v-if="list.issues.length === list.issuesSize"> v-if="list.issues.length === list.issuesSize"
>
Showing all issues Showing all issues
</span> </span>
<span v-else> <span
v-else
>
Showing {{ list.issues.length }} of {{ list.issuesSize }} issues Showing {{ list.issues.length }} of {{ list.issuesSize }} issues
</span> </span>
</li> </li>
</ul> </ul>
</div> </div>
`, </template>
};
---
title: Move BoardList vue component to vue file
merge_request: 16888
author: George Tsiolis
type: performance
...@@ -5,7 +5,7 @@ import Vue from 'vue'; ...@@ -5,7 +5,7 @@ import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Sortable from 'vendor/Sortable'; import Sortable from 'vendor/Sortable';
import BoardList from '~/boards/components/board_list'; import BoardList from '~/boards/components/board_list.vue';
import eventHub from '~/boards/eventhub'; import eventHub from '~/boards/eventhub';
import '~/boards/mixins/sortable_default_options'; import '~/boards/mixins/sortable_default_options';
import '~/boards/models/issue'; import '~/boards/models/issue';
......
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