Commit 84cf1644 authored by Simon Knox's avatar Simon Knox

fix board delete button

parent 3efbe1d4
......@@ -3,8 +3,9 @@
<popup-dialog
v-show="currentPage"
:title="title"
:primaryButtonLabel="buttonText"
:primary-button-label="buttonText"
:kind="buttonKind"
:submit-disabled="submitDisabled"
@toggle="cancel"
@submit="submit"
>
......@@ -140,16 +141,20 @@ const Store = gl.issueBoards.BoardsStore;
export default Vue.extend({
props: {
milestonePath: {
boardPath: {
type: String,
required: true,
},
labelsPath: {
canAdminBoard: {
type: Boolean,
required: true,
},
milestonePath: {
type: String,
required: true,
},
canAdminBoard: {
type: Boolean,
labelsPath: {
type: String,
required: true,
},
scopedIssueBoardFeatureEnabled: {
......@@ -181,6 +186,7 @@ export default Vue.extend({
currentPage: Store.state.currentPage,
milestones: [],
milestoneDropdownOpen: false,
submitDisabled: false,
};
},
components: {
......@@ -227,9 +233,6 @@ export default Vue.extend({
milestoneToggleText() {
return this.board.milestone ? this.board.milestone.title : 'Milestone';
},
submitDisabled() {
return false;
},
expandButtonText() {
return this.expanded ? 'Collapse' : 'Expand';
},
......@@ -248,28 +251,40 @@ export default Vue.extend({
location.href = location.pathname;
},
submit() {
gl.boardService.createBoard(this.board)
.then(resp => resp.json())
.then((data) => {
if (this.currentBoard && this.currentPage !== 'new') {
this.currentBoard.name = this.board.name;
if (this.currentPage === 'delete') {
this.submitDisabled = true;
this.$http.delete(this.boardPath)
.then(({redirect_to}) => {
gl.utils.visitUrl(Store.rootPath);
})
.catch(() => {
Flash('Failed to delete board. Please try again.')
this.submitDisabled = false;
});
} else {
gl.boardService.createBoard(this.board)
.then(resp => resp.json())
.then((data) => {
if (this.currentBoard && this.currentPage !== 'new') {
this.currentBoard.name = this.board.name;
// We reload the page to make sure the store & state of the app are correct
this.refreshPage();
// We reload the page to make sure the store & state of the app are correct
this.refreshPage();
// Enable the button thanks to our jQuery disabling it
$(this.$refs.submitBtn).enable();
// Enable the button thanks to our jQuery disabling it
$(this.$refs.submitBtn).enable();
// Reset the selectors current page
Store.state.currentPage = '';
Store.state.reload = true;
} else if (this.currentPage === 'new') {
gl.utils.visitUrl(`${Store.rootPath}/${data.id}`);
}
})
.catch(() => {
Flash('Unable to save your changes. Please try again.')
});
// Reset the selectors current page
Store.state.currentPage = '';
Store.state.reload = true;
} else if (this.currentPage === 'new') {
gl.utils.visitUrl(`${Store.rootPath}/${data.id}`);
}
})
.catch(() => {
Flash('Unable to save your changes. Please try again.')
});
}
},
cancel() {
Store.state.currentPage = '';
......
......@@ -20,6 +20,11 @@ export default {
type: String,
required: false,
},
submitDisabled: {
type: Boolean,
required: false,
default: false,
}
},
computed: {
......@@ -73,8 +78,10 @@ export default {
</div>
<slot name="footer">
<div class="modal-footer">
<button type="button"
<button
type="button"
class="btn pull-left"
:disabled="submitDisabled"
:class="btnKindClass"
@click="emitSubmit(true)">
{{primaryButtonLabel}}
......
......@@ -36,6 +36,7 @@
Delete board
%board-form{ ":milestone-path" => "milestonePath",
"board-path" => current_board_path(board),
"labels-path" => labels_filter_path(true),
"project-id" => @project&.id,
"group-id" => @group&.id,
......
......@@ -44,6 +44,7 @@ module EE
service.execute(@board)
respond_to do |format|
format.json { head :ok }
format.html { redirect_to boards_path, status: 302 }
end
end
......
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