new functions

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-07-16 14:17:51 +02:00
committed by Julius Härtl
parent 70d3fba187
commit 38dc7945dd
8 changed files with 141 additions and 29 deletions

View File

@@ -12,7 +12,6 @@
</ul> </ul>
<h3>{{ t('deck', 'Deleted cards') }}</h3> <h3>{{ t('deck', 'Deleted cards') }}</h3>
<ul> <ul>
<!-- <li ng-repeat="deletedCard in cardservice.deleted"> <!-- <li ng-repeat="deletedCard in cardservice.deleted">
<span class="icon icon-deck"></span> <span class="icon icon-deck"></span>
@@ -48,12 +47,7 @@ export default {
...mapState({ ...mapState({
deletedStacks: state => state.deletedStacks deletedStacks: state => state.deletedStacks
// deletedCards: state => state.deletedCards // deletedCards: state => state.deletedCards
}), })
deletedCards() {
console.log(store.state.deletedCards)
return store.state.deletedCards
}
}, },
created() { created() {

View File

@@ -120,7 +120,7 @@ export default {
boardId: this.stack.boardId boardId: this.stack.boardId
} }
this.$store.dispatch('addCard', newCard) this.$store.dispatch('addCard', newCard)
}, }
} }
} }
</script> </script>

View File

@@ -22,13 +22,37 @@
<template> <template>
<app-sidebar v-if="currentCard != null" <app-sidebar v-if="currentCard != null"
:actions="[]" :actions="toolbarActions"
:title="currentCard.title" :title="currentCard.title"
:subtitle="subtitle" :subtitle="subtitle"
@close="closeSidebar"> @close="closeSidebar">
<template #action /> <template #action />
<AppSidebarTab name="Details" icon="icon-home">
<p>Tags</p>
<multiselect v-model="addedLabelToCard" :options="currentBoard.labels" label="label"
@input="clickaddLabelToCard">
<template #option="scope">
{{ scope.option.title }}
</template>
</multiselect>
<p>Assign to user</p>
<multiselect v-model="addAclToCard" :options="unallocatedSharees" label="label"
@input="clickAddAclToCard" @search-change="asyncFind">
<template #option="scope">
{{ scope.option.label }}
</template>
</multiselect>
<p>Due to</p>
<DatetimePicker />
</AppSidebarTab>
<AppSidebarTab name="Description" icon="icon-description"> <AppSidebarTab name="Description" icon="icon-description">
{{ currentCard.description }} <textarea v-model="copiedCard.description" type="text" autofocus />
<input type="button" class="icon-confirm" @click="saveDesc()">
</AppSidebarTab> </AppSidebarTab>
<AppSidebarTab name="Attachments" icon="icon-files-dark"> <AppSidebarTab name="Attachments" icon="icon-files-dark">
{{ currentCard.attachments }} {{ currentCard.attachments }}
@@ -40,33 +64,101 @@
</template> </template>
<script> <script>
import { AppSidebar, AppSidebarTab } from 'nextcloud-vue' import { AppSidebar, AppSidebarTab, Multiselect, DatetimePicker } from 'nextcloud-vue'
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'CardSidebar', name: 'CardSidebar',
components: { components: {
AppSidebar, AppSidebar,
AppSidebarTab AppSidebarTab,
Multiselect,
DatetimePicker
}, },
data() { data() {
return { return {
addAclToCard: null,
addedLabelToCard: null,
isLoading: false,
copiedCard: null
} }
}, },
computed: { computed: {
...mapState({ ...mapState({
currentCard: state => state.currentCard currentCard: state => state.currentCard,
currentBoard: state => state.currentBoard,
sharees: 'sharees'
}), }),
subtitle() { subtitle() {
let lastModified = this.currentCard.lastModified let lastModified = this.currentCard.lastModified
let createdAt = this.currentCard.createdAt let createdAt = this.currentCard.createdAt
return t('deck', 'Modified') + ': ' + lastModified + ' ' + t('deck', 'Created') + ': ' + createdAt return t('deck', 'Modified') + ': ' + lastModified + ' ' + t('deck', 'Created') + ': ' + createdAt
},
unallocatedSharees() {
return this.sharees
/* return this.sharees.filter((sharee) => {
return Object.values(this.board.acl).findIndex((acl) => {
return acl.participant.uid === sharee.value.shareWith
})
}) */
},
toolbarActions() {
return [
{
action: () => {
},
icon: 'icon-archive-dark',
text: t('deck', 'Assign to me')
},
{
action: () => {
},
icon: 'icon-archive',
text: t('deck', (this.showArchived ? 'Unarchive card' : 'Archive card'))
}
]
}
},
watch: {
currentCard() {
this.copiedCard = JSON.parse(JSON.stringify(this.currentCard))
} }
}, },
methods: { methods: {
saveDesc() {
this.$store.dispatch('updateCard', this.copiedCard)
},
asyncFind(query) {
this.isLoading = true
this.$store.dispatch('loadSharees').then(response => {
this.isLoading = false
})
},
closeSidebar() { closeSidebar() {
this.$router.push({ name: 'board' }) this.$router.push({ name: 'board' })
},
clickAddAclToCard() {
/* this.addAclForAPI = {
type: 0,
participant: this.addAcl.value.shareWith,
permissionEdit: false,
permissionShare: false,
permissionManage: false
}
this.$store.dispatch('addAclToCurrentBoard', this.addAclForAPI) */
},
clickaddLabelToCard() {
this.copiedCard.labels.push(this.addedLabelToCard)
let data = {
cardId: this.copiedCard.id,
labelId: this.addedLabelToCard.id
}
this.$store.dispatch('assignLabel', data)
} }
} }
} }

View File

@@ -22,9 +22,9 @@
<template> <template>
<div class="badges"> <div class="badges">
<div v-if="true" class="card-files icon icon-files-dark" /> <div v-if="card.attechments" class="card-files icon icon-files-dark" />
<div v-if="true" class="card-comments icon icon-comment" /> <div v-if="card.description" class="card-comments icon icon-comment" />
<div v-if="true" :class="{'icon-calendar': true, 'icon-calendar-dark': false}" class="due icon now"> <div v-if="card.duedate" :class="{'icon-calendar': true, 'icon-calendar-dark': false}" class="due icon now">
<span>Now</span> <span>Now</span>
</div> </div>
<div v-if="true" class="card-tasks icon icon-checkmark"> <div v-if="true" class="card-tasks icon icon-checkmark">
@@ -50,6 +50,9 @@ export default {
computed: { computed: {
compactMode() { compactMode() {
return false return false
},
card() {
return this.$store.getters.cardById(this.id)
} }
} }
} }

View File

@@ -34,10 +34,10 @@
</transition> </transition>
</div> </div>
<ul class="labels"> <ul class="labels">
<li v-for="label in labels" :key="label.id" :style="labelStyle(label)"><span>{{ label.title }}</span></li> <li v-for="label in card.labels" :key="label.id" :style="labelStyle(label)"><span>{{ label.title }}</span></li>
</ul> </ul>
<div v-show="!compactMode" class="card-controls compact-item"> <div v-show="!compactMode" class="card-controls compact-item">
<card-badges /> <card-badges :id="id" />
</div> </div>
</div> </div>
</template> </template>
@@ -82,12 +82,6 @@ export default {
menu() { menu() {
return [] return []
}, },
labels() {
return [
{ id: 1, title: 'ToDo', color: 'aa0000' },
{ id: 2, title: 'Done', color: '33ff33' }
]
},
labelStyle() { labelStyle() {
return (label) => { return (label) => {
return { return {

View File

@@ -75,7 +75,7 @@ export class CardApi {
} }
assignUser(card) { assignUser(card) {
return axios.post(this.url(`/cards/${card.id}/assignUser`), card.newUserUid) return axios.post(this.url(`/cards/${card.id}/assign`), card.newUserUid)
.then( .then(
(response) => { (response) => {
return Promise.resolve(response.data) return Promise.resolve(response.data)
@@ -119,4 +119,19 @@ export class CardApi {
}) })
} }
assignLabelToCard(data) {
return axios.post(this.url(`/cards/${data.cardId}/label/${data.labelId}`))
.then(
(response) => {
return Promise.resolve(response.data)
},
(err) => {
return Promise.reject(err)
}
)
.catch((err) => {
return Promise.reject(err)
})
}
} }

View File

@@ -64,10 +64,18 @@ export default {
}, },
assignCardToMe(state, card) { assignCardToMe(state, card) {
console.log(card) console.log(card)
let existingIndex = state.cards.findIndex(_card => _card.id === card.id) // let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) { /* if (existingIndex !== -1) {
} } */
},
updateCard(state, card) {
// console.log(card)
// new card is not returned!
// let existingIndex = state.cards.findIndex(_card => _card.id === card.id)
/* if (existingIndex !== -1) {
state.cards[existingIndex] = card
} */
} }
}, },
actions: { actions: {
@@ -105,6 +113,12 @@ export default {
.then((card) => { .then((card) => {
commit('assignCardToMe', card) commit('assignCardToMe', card)
}) })
},
assignLabel({ commit }, data) {
apiClient.assignLabelToCard(data)
.then((card) => {
commit('updateCard', card)
})
} }
} }
} }

View File

@@ -262,7 +262,7 @@ export default new Vuex.Store({
params.append('itemType', 0) params.append('itemType', 0)
params.append('itemType', 1) params.append('itemType', 1)
axios.get(OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { params }).then((response) => { axios.get(OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { params }).then((response) => {
//commit('setSharees', response.data.ocs.data.users) // commit('setSharees', response.data.ocs.data.users)
commit('setSharees', response.data.ocs.data) commit('setSharees', response.data.ocs.data)
}) })
}, },