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

Fixed Vue2 errors with multiple issue boards

parent 1d98630e
...@@ -2,29 +2,27 @@ ...@@ -2,29 +2,27 @@
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.issueBoards = window.gl.issueBoards || {}; window.gl.issueBoards = window.gl.issueBoards || {};
const Store = gl.issueBoards.BoardsStore;
gl.issueBoards.BoardSelectorForm = Vue.extend({ gl.issueBoards.BoardSelectorForm = Vue.extend({
props: {
type: String,
currentBoard: Object,
currentPage: String,
reload: Boolean,
},
data() { data() {
return { return {
board: { board: {
id: false, id: false,
name: '', name: '',
}, },
currentBoard: Store.state.currentBoard,
currentPage: Store.state.currentPage,
}; };
}, },
ready() { mounted() {
if (this.currentBoard && Object.keys(this.currentBoard).length) { if (this.currentBoard && Object.keys(this.currentBoard).length && this.currentPage === 'edit') {
this.board = Vue.util.extend({}, this.currentBoard); this.board = Vue.util.extend({}, this.currentBoard);
} }
}, },
computed: { computed: {
buttonText() { buttonText() {
if (this.type === 'new') { if (this.currentPage === 'new') {
return 'Create'; return 'Create';
} }
...@@ -35,16 +33,16 @@ ...@@ -35,16 +33,16 @@
submit() { submit() {
gl.boardService.createBoard(this.board) gl.boardService.createBoard(this.board)
.then(() => { .then(() => {
if (this.currentBoard) { if (this.currentBoard && this.currentPage === 'edit') {
this.currentBoard.name = this.board.name; this.currentBoard.name = this.board.name;
} }
// Enable the button thanks to our jQuery disabling it // Enable the button thanks to our jQuery disabling it
$(this.$els.submitBtn).enable(); $(this.$refs.submitBtn).enable();
// Reset the selectors current page // Reset the selectors current page
this.currentPage = ''; Store.state.currentPage = '';
this.reload = true; Store.state.reload = true;
}); });
}, },
}, },
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.issueBoards = window.gl.issueBoards || {}; window.gl.issueBoards = window.gl.issueBoards || {};
const Store = gl.issueBoards.BoardsStore;
Store.createNewListDropdownData();
gl.issueBoards.BoardsSelector = Vue.extend({ gl.issueBoards.BoardsSelector = Vue.extend({
components: { components: {
'board-selector-form': gl.issueBoards.BoardSelectorForm, 'board-selector-form': gl.issueBoards.BoardSelectorForm,
...@@ -17,8 +21,7 @@ ...@@ -17,8 +21,7 @@
open: false, open: false,
loading: true, loading: true,
boards: [], boards: [],
currentPage: '', state: Store.state,
reload: false,
}; };
}, },
watch: { watch: {
...@@ -33,6 +36,15 @@ ...@@ -33,6 +36,15 @@
}, },
}, },
computed: { computed: {
currentPage() {
return this.state.currentPage;
},
reload() {
return this.state.reload;
},
board() {
return this.state.currentBoard;
},
showDelete() { showDelete() {
return this.boards.length > 1; return this.boards.length > 1;
}, },
...@@ -50,7 +62,7 @@ ...@@ -50,7 +62,7 @@
}, },
methods: { methods: {
showPage(page) { showPage(page) {
this.currentPage = page; this.state.currentPage = page;
}, },
toggleDropdown() { toggleDropdown() {
this.open = !this.open; this.open = !this.open;
...@@ -68,5 +80,8 @@ ...@@ -68,5 +80,8 @@
} }
}, },
}, },
created() {
this.state.currentBoard = this.currentBoard;
},
}); });
})(); })();
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
search: '' search: ''
}; };
}, },
createNewListDropdownData() {
this.state.currentBoard = {};
this.state.currentPage = '';
this.state.reload = false;
},
addList (listObj) { addList (listObj) {
const list = new List(listObj); const list = new List(listObj);
this.state.lists.push(list); this.state.lists.push(list);
......
...@@ -280,7 +280,7 @@ class Issue < ActiveRecord::Base ...@@ -280,7 +280,7 @@ class Issue < ActiveRecord::Base
def as_json(options = {}) def as_json(options = {})
super(options).tap do |json| super(options).tap do |json|
json[:subscribed] = subscribed?(options[:user]) if options.has_key?(:user) json[:subscribed] = subscribed?(options[:user]) if options.has_key?(:user) && options[:user]
if options.has_key?(:labels) if options.has_key?(:labels)
json[:labels] = labels.as_json( json[:labels] = labels.as_json(
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
.boards-title-holder.dropdown .boards-title-holder.dropdown
%button.boards-switcher{ "@click" => "loadBoards", %button.boards-switcher{ "@click" => "loadBoards",
data: { toggle: "dropdown" } } data: { toggle: "dropdown" } }
{{ currentBoard.name }} {{ board.name }}
= icon("caret-down") = icon("caret-down")
.dropdown-menu{ ":class" => "{ 'is-loading': loading }" } .dropdown-menu{ ":class" => "{ 'is-loading': loading }" }
.dropdown-title .dropdown-title
...@@ -25,17 +25,7 @@ ...@@ -25,17 +25,7 @@
= icon("spin spinner") = icon("spin spinner")
- if can?(current_user, :admin_board, @project) - if can?(current_user, :admin_board, @project)
%board-selector-form{ "inline-template" => true, %board-selector-form{ "inline-template" => true,
"v-if" => "currentPage === 'edit'", "v-if" => "currentPage === 'new' || currentPage === 'edit'" }
"type" => "edit",
":current-board.sync" => "currentBoard",
":current-page.sync" => "currentPage",
":reload.sync" => "reload" }
= render "projects/boards/components/form"
%board-selector-form{ "inline-template" => true,
"v-if" => "currentPage === 'new'",
"type" => "new",
":current-page.sync" => "currentPage",
":reload.sync" => "reload" }
= render "projects/boards/components/form" = render "projects/boards/components/form"
.dropdown-content.board-selector-page-two{ "v-if" => "currentPage === 'delete'" } .dropdown-content.board-selector-page-two{ "v-if" => "currentPage === 'delete'" }
%p %p
...@@ -44,7 +34,7 @@ ...@@ -44,7 +34,7 @@
= link_to "", = link_to "",
class: "btn btn-danger pull-left", class: "btn btn-danger pull-left",
method: :delete, method: :delete,
":href" => "'#{namespace_project_boards_path(@project.namespace, @project)}/' + currentBoard.id" do ":href" => "'#{namespace_project_boards_path(@project.namespace, @project)}/' + board.id" do
Delete Delete
%button.btn.btn-default.pull-right{ type: "button", %button.btn.btn-default.pull-right{ type: "button",
"@click.stop.prevent" => "currentPage = ''" } "@click.stop.prevent" => "currentPage = ''" }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.clearfix.prepend-top-10 .clearfix.prepend-top-10
%button.btn.btn-primary.pull-left{ type: "submit", %button.btn.btn-primary.pull-left{ type: "submit",
":disabled" => "board.name === ''", ":disabled" => "board.name === ''",
"v-el:submit-btn" => true } "ref" => "'submit-btn'" }
{{ buttonText }} {{ buttonText }}
%button.btn.btn-default.pull-right{ type: "button", %button.btn.btn-default.pull-right{ type: "button",
"@click.stop.prevent" => "currentPage = ''" } "@click.stop.prevent" => "currentPage = ''" }
......
%board-sidebar{ "inline-template" => true, %board-sidebar{ "inline-template" => true,
":current-user" => "#{current_user.to_json(only: [:username, :id, :name], methods: [:avatar_url]) if current_user}" } ":current-user" => "#{current_user ? current_user.to_json(only: [:username, :id, :name], methods: [:avatar_url]) : {}}" }
%aside.right-sidebar.right-sidebar-expanded.issue-boards-sidebar{ "v-show" => "showSidebar" } %aside.right-sidebar.right-sidebar-expanded.issue-boards-sidebar{ "v-show" => "showSidebar" }
.issuable-sidebar .issuable-sidebar
.block.issuable-sidebar-header .block.issuable-sidebar-header
......
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