Commit 0c196e76 authored by Simon Knox's avatar Simon Knox

move board crud to a modal

parent c472e8f6
...@@ -48,14 +48,18 @@ import extraMilestones from '../mixins/extra_milestones'; ...@@ -48,14 +48,18 @@ import extraMilestones from '../mixins/extra_milestones';
return 'Save'; return 'Save';
}, },
title() {
if (this.currentPage === 'new') {
return 'Create new board';
}
// TODO check for readonly
return 'Edit board';
},
milestoneToggleText() { milestoneToggleText() {
return this.board.milestone.title || 'Milestone'; return this.board.milestone ? this.board.milestone.title : 'Milestone';
}, },
submitDisabled() { submitDisabled() {
if (this.currentPage !== 'milestone') {
return this.board.name === '';
}
return false; return false;
}, },
}, },
...@@ -83,10 +87,10 @@ import extraMilestones from '../mixins/extra_milestones'; ...@@ -83,10 +87,10 @@ import extraMilestones from '../mixins/extra_milestones';
if (this.currentBoard && this.currentPage !== 'new') { if (this.currentBoard && this.currentPage !== 'new') {
this.currentBoard.name = this.board.name; this.currentBoard.name = this.board.name;
if (this.currentPage === 'milestone') {
// We reload the page to make sure the store & state of the app are correct // We reload the page to make sure the store & state of the app are correct
this.refreshPage(); this.refreshPage();
}
$('#edit-board-modal').modal('hide');
// Enable the button thanks to our jQuery disabling it // Enable the button thanks to our jQuery disabling it
$(this.$refs.submitBtn).enable(); $(this.$refs.submitBtn).enable();
......
...@@ -55,19 +55,6 @@ import './board_new_form'; ...@@ -55,19 +55,6 @@ import './board_new_form';
showDelete() { showDelete() {
return this.boards.length > 1; return this.boards.length > 1;
}, },
title() {
if (this.currentPage === 'edit') {
return 'Edit board name';
} else if (this.currentPage === 'milestone') {
return 'Edit board milestone';
} else if (this.currentPage === 'new') {
return 'Create new board';
} else if (this.currentPage === 'delete') {
return 'Delete board';
}
return 'Go to a board';
},
}, },
methods: { methods: {
showPage(page) { showPage(page) {
......
...@@ -5,23 +5,14 @@ ...@@ -5,23 +5,14 @@
%boards-selector{ "inline-template" => true, %boards-selector{ "inline-template" => true,
":current-board" => current_board_json, ":current-board" => current_board_json,
"milestone-path" => milestones_filter_path(milestone_filter_opts) } "milestone-path" => milestones_filter_path(milestone_filter_opts) }
%span.boards-selector-wrapper
.dropdown .dropdown
%button.dropdown-menu-toggle{ "@click" => "loadBoards", %button.dropdown-menu-toggle{ "@click" => "loadBoards",
data: { toggle: "dropdown" } } data: { toggle: "dropdown" } }
{{ board.name }} {{ board.name }}
= icon("chevron-down") = icon("chevron-down")
.dropdown-menu{ ":class" => "{ 'is-loading': loading }" } .dropdown-menu{ ":class" => "{ 'is-loading': loading }" }
.dropdown-title .dropdown-content
%button.dropdown-title-button.dropdown-menu-back{ type: "button",
aria: { label: "Go back" },
"@click.stop.prevent" => "showPage('')",
"v-if" => "currentPage !== ''" }
= icon("arrow-left")
{{ title }}
%button.dropdown-title-button.dropdown-menu-close{ type: "button",
aria: { label: "Close" } }
= icon("times", class: "dropdown-menu-close-icon")
.dropdown-content{ "v-if" => "currentPage === ''" }
%ul{ "v-if" => "!loading" } %ul{ "v-if" => "!loading" }
%li{ "v-for" => "board in boards" } %li{ "v-for" => "board in boards" }
%a{ ":href" => "'#{board_base_url}/' + board.id" } %a{ ":href" => "'#{board_base_url}/' + board.id" }
...@@ -31,37 +22,24 @@ ...@@ -31,37 +22,24 @@
Some of your boards are hidden, activate a license to see them again. Some of your boards are hidden, activate a license to see them again.
.dropdown-loading{ "v-if" => "loading" } .dropdown-loading{ "v-if" => "loading" }
= icon("spin spinner") = icon("spin spinner")
- if can?(current_user, :admin_board, parent) - if can?(current_user, :admin_board, parent)
%board-selector-form{ "inline-template" => true, .dropdown-footer
":milestone-path" => "milestonePath",
"v-if" => "currentPage === 'new' || currentPage === 'edit' || currentPage === 'milestone'" }
= render "shared/boards/components/form"
.dropdown-content.board-selector-page-two{ "v-if" => "currentPage === 'delete'" }
%p
Are you sure you want to delete this board?
.board-delete-btns.clearfix
= link_to current_board_path(board),
class: "btn btn-danger pull-left",
method: :delete do
Delete
%button.btn.btn-default.pull-right{ type: "button",
"@click.stop.prevent" => "showPage('')" }
Cancel
- if can?(current_user, :admin_board, parent)
.dropdown-footer{ "v-if" => "currentPage === ''" }
%ul.dropdown-footer-list %ul.dropdown-footer-list
- if parent.feature_available?(:multiple_issue_boards) - if parent.feature_available?(:multiple_issue_boards)
%li %li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('new')" } %a{ "href" => "#", "@click.prevent" => "showPage('new')", data: { toggle: 'modal', target: '#edit-board-modal' } }
Create new board Create new board
%li %li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('edit')" } %a{ "href" => "#", "@click.prevent" => "showPage('edit')", data: { toggle: 'modal', target: '#edit-board-modal' } }
Edit board name Edit board
- if parent.issue_board_milestone_available?(current_user)
%li
%a{ "href" => "#", "@click.stop.prevent" => "showPage('milestone')" }
Edit board milestone
%li{ "v-if" => "showDelete" } %li{ "v-if" => "showDelete" }
%a{ "href" => "#", "@click.stop.prevent" => "showPage('delete')" } %a{ "href" => "#", "@click.prevent" => "showPage('delete')", data: { toggle: 'modal', target: '#edit-board-modal' } }
%span.text-danger %span.text-danger
Delete board Delete board
- if can?(current_user, :admin_board, parent)
%board-selector-form{ "inline-template" => true,
":milestone-path" => "milestonePath",
"v-if" => "currentPage" }
= render "shared/boards/components/form"
.board-selector-page-two #edit-board-modal.modal.fade{ tabindex: -1 }
%form{ "@submit.prevent" => "submit" } .modal-dialog.modal-md
.dropdown-content .modal-content
.modal-header
%a.close{ href: "#", "data-dismiss" => "modal" } ×
%h4
{{ title }}
%div{ "v-if" => "currentPage === 'delete'" }
.modal-body
%p
Are you sure you want to delete this board?
.modal-footer
= link_to current_board_path(board),
class: "btn btn-danger pull-left",
method: :delete do
Delete
%button.btn.btn-default.pull-right{ type: "button",
"@click" => "cancel",
data: { dismiss: "modal" } }
Cancel
%form{ "v-else" => true,
"@submit.prevent" => "submit" }
.modal-body
%input{ type: "hidden", %input{ type: "hidden",
id: "board-milestone", id: "board-milestone",
"v-model.number" => "board.milestone_id" } "v-model.number" => "board.milestone_id" }
%div{ "v-if" => "currentPage !== 'milestone'" } %div
%label.label-light{ for: "board-new-name" } %label.label-light{ for: "board-new-name" }
Board name Board name
%input.form-control{ type: "text", %input.form-control{ type: "text",
id: "board-new-name", id: "board-new-name",
"v-model" => "board.name" } "v-model" => "board.name" }
- if current_board_parent.issue_board_milestone_available?(current_user) - if current_board_parent.issue_board_milestone_available?(current_user)
.dropdown.board-inner-milestone-dropdown{ ":class" => "{ open: milestoneDropdownOpen }", .dropdown.board-inner-milestone-dropdown{ ":class" => "{ open: milestoneDropdownOpen }" }
"v-if" => "currentPage === 'new'" }
%label.label-light{ for: "board-milestone" } %label.label-light{ for: "board-milestone" }
Board milestone Board milestone
%button.dropdown-menu-toggle.wide{ type: "button", %button.dropdown-menu-toggle.wide{ type: "button",
...@@ -35,17 +54,12 @@ ...@@ -35,17 +54,12 @@
"@click.stop.prevent" => "selectMilestone(milestone)" } "@click.stop.prevent" => "selectMilestone(milestone)" }
{{ milestone.title }} {{ milestone.title }}
= dropdown_loading = dropdown_loading
%span .modal-footer
Only show issues scheduled for the selected milestone
%board-milestone-select{ "v-if" => "currentPage == 'milestone'",
":milestone-path" => "milestonePath",
":select-milestone" => "selectMilestone",
":board" => "board" }
.dropdown-footer
%button.btn.btn-primary.pull-left{ type: "submit", %button.btn.btn-primary.pull-left{ type: "submit",
":disabled" => "submitDisabled", ":disabled" => "submitDisabled",
"ref" => "'submit-btn'" } "ref" => "'submit-btn'" }
{{ buttonText }} {{ buttonText }}
%button.btn.btn-default.pull-right{ type: "button", %button.btn.btn-default.pull-right{ type: "button",
"@click.stop.prevent" => "cancel" } "@click.prevent" => "cancel",
data: { dismiss: "modal" } }
Cancel Cancel
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