Merge pull request #1865 from nextcloud/enh/addStackOnEmptyBoard

This commit is contained in:
Julius Härtl
2020-07-31 22:47:57 +02:00
committed by GitHub

View File

@@ -23,13 +23,33 @@
<template> <template>
<div class="board-wrapper"> <div class="board-wrapper">
<Controls :board="board" /> <Controls :board="board" />
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div v-if="loading" key="loading" class="emptycontent"> <div v-if="loading" key="loading" class="emptycontent">
<div class="icon icon-loading" /> <div class="icon icon-loading" />
<h2>{{ t('deck', 'Loading board') }}</h2> <h2>{{ t('deck', 'Loading board') }}</h2>
<p /> <p />
</div> </div>
<div v-else-if="board && !loading" key="board" class="board"> <EmptyContent v-else-if="isEmpty" key="empty" icon="icon-deck">
{{ t('deck', 'No lists available') }}
<template #desc>
{{ t('deck', 'Create a new list to add cards to this board') }}
<form @submit.prevent="addNewStack()">
<input id="new-stack-input-main"
v-model="newStackTitle"
v-focus
type="text"
class="no-close"
:placeholder="t('deck', 'List name')"
required>
<input v-tooltip="t('deck', 'Add new list')"
class="icon-confirm"
type="submit"
value="">
</form>
</template>
</EmptyContent>
<div v-else-if="!isEmpty && !loading" key="board" class="board">
<Container lock-axix="y" <Container lock-axix="y"
orientation="horizontal" orientation="horizontal"
:drag-handle-selector="dragHandleSelector" :drag-handle-selector="dragHandleSelector"
@@ -54,6 +74,7 @@ import { Container, Draggable } from 'vue-smooth-dnd'
import { mapState, mapGetters } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Controls from '../Controls' import Controls from '../Controls'
import Stack from './Stack' import Stack from './Stack'
import { EmptyContent } from '@nextcloud/vue'
export default { export default {
name: 'Board', name: 'Board',
@@ -62,6 +83,7 @@ export default {
Container, Container,
Draggable, Draggable,
Stack, Stack,
EmptyContent,
}, },
inject: [ inject: [
'boardApi', 'boardApi',
@@ -75,6 +97,7 @@ export default {
data() { data() {
return { return {
loading: true, loading: true,
newStackTitle: '',
} }
}, },
computed: { computed: {
@@ -91,6 +114,9 @@ export default {
dragHandleSelector() { dragHandleSelector() {
return this.canEdit ? null : '.no-drag' return this.canEdit ? null : '.no-drag'
}, },
isEmpty() {
return this.stacksByBoard.length === 0
},
}, },
watch: { watch: {
id: 'fetchData', id: 'fetchData',
@@ -117,13 +143,13 @@ export default {
this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex }) this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex })
}, },
createStack() { addNewStack() {
const newStack = { const newStack = {
title: 'FooBar', title: this.newStackTitle,
boardId: this.id, boardId: this.id,
order: this.stacksByBoard().length,
} }
this.$store.dispatch('createStack', newStack) this.$store.dispatch('createStack', newStack)
this.newStackTitle = ''
}, },
}, },
} }
@@ -137,6 +163,19 @@ export default {
$stack-spacing: 10px; $stack-spacing: 10px;
$stack-width: 300px; $stack-width: 300px;
form {
text-align: center;
display: flex;
width: 100%;
max-width: 200px;
margin: auto;
margin-top: 20px;
input[type=text] {
flex-grow: 1;
}
}
.board-wrapper { .board-wrapper {
position: relative; position: relative;
width: 100%; width: 100%;