Commit 8f693d3c authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'issue-boards-js-fix' into 'master'

Fixed JS error in issue boards

See merge request gitlab-org/gitlab-ee!6660
parents bcc6eef4 80a06bc5
/* eslint-disable quote-props, comma-dangle */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
import Vue from 'vue'; import Vue from 'vue';
...@@ -56,7 +54,7 @@ export default () => { ...@@ -56,7 +54,7 @@ export default () => {
gl.IssueBoardsApp = new Vue({ gl.IssueBoardsApp = new Vue({
el: $boardApp, el: $boardApp,
components: { components: {
'board': gl.issueBoards.Board, board: gl.issueBoards.Board,
'board-sidebar': gl.issueBoards.BoardSidebar, 'board-sidebar': gl.issueBoards.BoardSidebar,
BoardAddIssuesModal, BoardAddIssuesModal,
}, },
...@@ -74,11 +72,11 @@ export default () => { ...@@ -74,11 +72,11 @@ export default () => {
defaultAvatar: $boardApp.dataset.defaultAvatar, defaultAvatar: $boardApp.dataset.defaultAvatar,
}, },
computed: { computed: {
detailIssueVisible () { detailIssueVisible() {
return Object.keys(this.detailIssue.issue).length; return Object.keys(this.detailIssue.issue).length;
}, },
}, },
created () { created() {
gl.boardService = new BoardService({ gl.boardService = new BoardService({
boardsEndpoint: this.boardsEndpoint, boardsEndpoint: this.boardsEndpoint,
listsEndpoint: this.listsEndpoint, listsEndpoint: this.listsEndpoint,
...@@ -100,15 +98,16 @@ export default () => { ...@@ -100,15 +98,16 @@ export default () => {
sidebarEventHub.$off('toggleSubscription', this.toggleSubscription); sidebarEventHub.$off('toggleSubscription', this.toggleSubscription);
sidebarEventHub.$off('updateWeight', this.updateWeight); sidebarEventHub.$off('updateWeight', this.updateWeight);
}, },
mounted () { mounted() {
this.filterManager = new FilteredSearchBoards(Store.filter, true, Store.cantEdit); this.filterManager = new FilteredSearchBoards(Store.filter, true, Store.cantEdit);
this.filterManager.setup(); this.filterManager.setup();
Store.disabled = this.disabled; Store.disabled = this.disabled;
gl.boardService.all() gl.boardService
.all()
.then(res => res.data) .then(res => res.data)
.then((data) => { .then(data => {
data.forEach((board) => { data.forEach(board => {
const list = Store.addList(board, this.defaultAvatar); const list = Store.addList(board, this.defaultAvatar);
if (list.type === 'closed') { if (list.type === 'closed') {
...@@ -140,7 +139,7 @@ export default () => { ...@@ -140,7 +139,7 @@ export default () => {
newIssue.setFetchingState('epic', true); newIssue.setFetchingState('epic', true);
BoardService.getIssueInfo(sidebarInfoEndpoint) BoardService.getIssueInfo(sidebarInfoEndpoint)
.then(res => res.data) .then(res => res.data)
.then((data) => { .then(data => {
newIssue.setFetchingState('subscriptions', false); newIssue.setFetchingState('subscriptions', false);
newIssue.setFetchingState('weight', false); newIssue.setFetchingState('weight', false);
newIssue.setFetchingState('epic', false); newIssue.setFetchingState('epic', false);
...@@ -185,7 +184,7 @@ export default () => { ...@@ -185,7 +184,7 @@ export default () => {
issue.setLoadingState('weight', true); issue.setLoadingState('weight', true);
BoardService.updateWeight(issue.sidebarInfoEndpoint, newWeight) BoardService.updateWeight(issue.sidebarInfoEndpoint, newWeight)
.then(res => res.data) .then(res => res.data)
.then((data) => { .then(data => {
issue.setLoadingState('weight', false); issue.setLoadingState('weight', false);
issue.updateData({ issue.updateData({
weight: data.weight, weight: data.weight,
...@@ -196,7 +195,7 @@ export default () => { ...@@ -196,7 +195,7 @@ export default () => {
Flash(__('An error occurred when updating the issue weight')); Flash(__('An error occurred when updating the issue weight'));
}); });
} }
} },
}, },
}); });
...@@ -206,7 +205,7 @@ export default () => { ...@@ -206,7 +205,7 @@ export default () => {
filters: Store.state.filters, filters: Store.state.filters,
milestoneTitle: $boardApp.dataset.boardMilestoneTitle, milestoneTitle: $boardApp.dataset.boardMilestoneTitle,
}, },
mounted () { mounted() {
gl.issueBoards.newListDropdownInit(); gl.issueBoards.newListDropdownInit();
}, },
}); });
...@@ -231,8 +230,8 @@ export default () => { ...@@ -231,8 +230,8 @@ export default () => {
return this.canAdminList ? 'Edit board' : 'View scope'; return this.canAdminList ? 'Edit board' : 'View scope';
}, },
tooltipTitle() { tooltipTitle() {
return this.hasScope ? __('This board\'s scope is reduced') : ''; return this.hasScope ? __("This board's scope is reduced") : '';
} },
}, },
methods: { methods: {
showPage: page => gl.issueBoards.BoardsStore.showPage(page), showPage: page => gl.issueBoards.BoardsStore.showPage(page),
...@@ -254,76 +253,80 @@ export default () => { ...@@ -254,76 +253,80 @@ export default () => {
}); });
} }
gl.IssueBoardsModalAddBtn = new Vue({ const issueBoardsModal = document.getElementById('js-add-issues-btn');
el: document.getElementById('js-add-issues-btn'),
mixins: [modalMixin], if (issueBoardsModal) {
data() { gl.IssueBoardsModalAddBtn = new Vue({
return { el: issueBoardsModal,
modal: ModalStore.store, mixins: [modalMixin],
store: Store.state, data() {
isFullscreen: false, return {
focusModeAvailable: $boardApp.hasAttribute('data-focus-mode-available'), modal: ModalStore.store,
canAdminList: this.$options.el.hasAttribute('data-can-admin-list'), store: Store.state,
}; isFullscreen: false,
}, focusModeAvailable: $boardApp.hasAttribute('data-focus-mode-available'),
computed: { canAdminList: this.$options.el.hasAttribute('data-can-admin-list'),
disabled() { };
if (!this.store) {
return true;
}
return !this.store.lists.filter(list => !list.preset).length;
}, },
tooltipTitle() { computed: {
if (this.disabled) { disabled() {
return 'Please add a list to your board first'; if (!this.store) {
} return true;
}
return !this.store.lists.filter(list => !list.preset).length;
},
tooltipTitle() {
if (this.disabled) {
return 'Please add a list to your board first';
}
return ''; return '';
},
}, },
}, watch: {
watch: { disabled() {
disabled() { this.updateTooltip();
},
},
mounted() {
this.updateTooltip(); this.updateTooltip();
}, },
}, methods: {
mounted() { updateTooltip() {
this.updateTooltip(); const $tooltip = $(this.$refs.addIssuesButton);
},
methods: {
updateTooltip() {
const $tooltip = $(this.$refs.addIssuesButton);
this.$nextTick(() => { this.$nextTick(() => {
if (this.disabled) { if (this.disabled) {
$tooltip.tooltip(); $tooltip.tooltip();
} else { } else {
$tooltip.tooltip('dispose'); $tooltip.tooltip('dispose');
}
});
},
openModal() {
if (!this.disabled) {
this.toggleModal(true);
} }
}); },
},
openModal() {
if (!this.disabled) {
this.toggleModal(true);
}
}, },
}, template: `
template: ` <div class="board-extra-actions">
<div class="board-extra-actions"> <button
<button class="btn btn-create prepend-left-10"
class="btn btn-create prepend-left-10" type="button"
type="button" data-placement="bottom"
data-placement="bottom" ref="addIssuesButton"
ref="addIssuesButton" :class="{ 'disabled': disabled }"
:class="{ 'disabled': disabled }" :title="tooltipTitle"
:title="tooltipTitle" :aria-disabled="disabled"
:aria-disabled="disabled" v-if="canAdminList"
v-if="canAdminList" @click="openModal">
@click="openModal"> Add issues
Add issues </button>
</button> </div>
</div> `,
`, });
}); }
gl.IssueBoardsToggleFocusBtn = new Vue({ gl.IssueBoardsToggleFocusBtn = new Vue({
el: document.getElementById('js-toggle-focus-btn'), el: document.getElementById('js-toggle-focus-btn'),
...@@ -335,7 +338,9 @@ export default () => { ...@@ -335,7 +338,9 @@ export default () => {
}, },
methods: { methods: {
toggleFocusMode() { toggleFocusMode() {
if (!this.focusModeAvailable) { return; } if (!this.focusModeAvailable) {
return;
}
$(this.$refs.toggleFocusModeButton).tooltip('hide'); $(this.$refs.toggleFocusModeButton).tooltip('hide');
issueBoardsContent.classList.toggle('is-focused'); issueBoardsContent.classList.toggle('is-focused');
...@@ -369,6 +374,6 @@ export default () => { ...@@ -369,6 +374,6 @@ export default () => {
el: '#js-multiple-boards-switcher', el: '#js-multiple-boards-switcher',
components: { components: {
'boards-selector': gl.issueBoards.BoardsSelector, 'boards-selector': gl.issueBoards.BoardsSelector,
} },
}); });
}; };
...@@ -6227,7 +6227,7 @@ msgstr "" ...@@ -6227,7 +6227,7 @@ msgstr ""
msgid "This application will be able to:" msgid "This application will be able to:"
msgstr "" msgstr ""
msgid "This board\\'s scope is reduced" msgid "This board's scope is reduced"
msgstr "" msgstr ""
msgid "This diff is collapsed." msgid "This diff is collapsed."
......
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