Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move card to another board #1242

Merged
merged 6 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 68 additions & 4 deletions src/components/cards/CardItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,25 @@
<ActionButton v-if="showArchived === false" icon="icon-user" @click="assignCardToMe()">{{ t('deck', 'Assign to me') }}</ActionButton>
<ActionButton icon="icon-archive" @click="archiveUnarchiveCard()">{{ t('deck', (showArchived ? 'Unarchive card' : 'Archive card')) }}</ActionButton>
<ActionButton v-if="showArchived === false" icon="icon-delete" @click="deleteCard()">{{ t('deck', 'Delete card') }}</ActionButton>
<ActionButton icon="icon-external" @click.stop="modalShow=true">{{ t('deck', 'Move card') }}</ActionButton>
<ActionButton icon="icon-settings-dark" @click="openCard">{{ t('deck', 'Card details') }}</ActionButton>
</Actions>

</transition>
<modal v-if="modalShow" title="Move card to another board" @close="modalShow=false">
<div class="modal__content">
<Multiselect :placeholder="t('deck', 'Select a board')" v-model="selectedBoard" :options="boards"
label="title"
@select="loadStacksFromBoard" />
<Multiselect :placeholder="t('deck', 'Select a stack')" v-model="selectedStack" :options="stacksFromBoard"
label="title" />

<button :disabled="!isBoardAndStackChoosen" class="primary" @click="moveCard">{{ t('deck', 'Move card') }}</button>
<button @click="modalShow=false">{{ t('deck', 'Cancel') }}</button>

</div>
</modal>

</div>
<ul class="labels" @click="openCard">
<li v-for="label in card.labels" :key="label.id" :style="labelStyle(label)"><span>{{ label.title }}</span></li>
Expand All @@ -51,19 +66,21 @@
</template>

<script>
import { PopoverMenu } from 'nextcloud-vue'
import { Modal } from 'nextcloud-vue/dist/Components/Modal'
import { Actions } from 'nextcloud-vue/dist/Components/Actions'
import { ActionButton } from 'nextcloud-vue/dist/Components/ActionButton'
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
import ClickOutside from 'vue-click-outside'
import { mapState } from 'vuex'
import axios from 'nextcloud-axios'

import CardBadges from './CardBadges'
import LabelTag from './LabelTag'
import Color from '../../mixins/color'

export default {
name: 'CardItem',
components: { PopoverMenu, CardBadges, LabelTag, Actions, ActionButton },
components: { Modal, CardBadges, LabelTag, Actions, ActionButton, Multiselect },
directives: {
ClickOutside
},
Expand All @@ -78,17 +95,27 @@ export default {
return {
menuOpened: false,
editing: false,
copiedCard: ''
copiedCard: '',
modalShow: false,
selectedBoard: '',
selectedStack: '',
stacksFromBoard: []
}
},
computed: {
...mapState({
compactMode: state => state.compactMode,
showArchived: state => state.showArchived
showArchived: state => state.showArchived,
currentBoard: state => state.currentBoard
}),
card() {
return this.$store.getters.cardById(this.id)
},
boards() {
return this.$store.getters.boards.filter(board => {
return board.id !== this.currentBoard.id
})
},
menu() {
return []
},
Expand All @@ -102,6 +129,12 @@ export default {
},
currentCard() {
return this.$route.params.cardId === this.id
},
isBoardAndStackChoosen() {
if (this.selectedBoard === '' || this.selectedStack === '') {
return false
}
return true
}
},
methods: {
Expand Down Expand Up @@ -136,6 +169,21 @@ export default {
this.copiedCard = Object.assign({}, this.card)
this.copiedCard.newUserUid = this.card.owner.uid
this.$store.dispatch('assignCardToUser', this.copiedCard)
},
async loadStacksFromBoard(board) {
try {
let url = OC.generateUrl('/apps/deck/stacks/' + board.id)
let response = await axios.get(url)
this.stacksFromBoard = response.data
} catch (err) {
return err
}
},
moveCard() {
this.copiedCard = Object.assign({}, this.card)
this.copiedCard.stackId = this.selectedStack.id
this.$store.dispatch('moveCard', this.copiedCard)
this.modalShow = false
}
}
}
Expand Down Expand Up @@ -248,4 +296,20 @@ export default {
color: transparent;
}
}

.modal__content {
width: 25vw;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A proper max-width/max-height would be good for small screen sizes

min-width: 250px;
height: 120px;
text-align: center;
margin: 20px 20px 60px 20px;

.multiselect {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.multiselect is not inside the button ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

margin-bottom: 10px;
}
}

.modal__content button {
float: right;
}
</style>
6 changes: 6 additions & 0 deletions src/store/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export default {
commit('updateTitle', updatedCard)
})
},
moveCard({ commit }, card) {
apiClient.updateCard(card)
.then((updatedCard) => {
commit('deleteCard', updatedCard)
})
},
reorderCard({ commit }, card) {
commit('updateCard', card)
// TODO iterate over cards in stacks and increase order state from cards >= card.order
Expand Down