Add working example of vue-multiselect

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-04-25 15:09:03 +02:00
parent 49e1d8e8ec
commit 907bf57460
2 changed files with 42 additions and 20 deletions

View File

@@ -1,6 +1,10 @@
<template> <template>
<div> <div>
<multiselect :options="board.sharees" /> <multiselect :options="sharees" @search-change="asyncFind" label="label">
<template #option="scope">
{{ scope.option.label }}
</template>
</multiselect>
<ul <ul
id="shareWithList" id="shareWithList"
@@ -24,6 +28,7 @@
<script> <script>
import { Avatar, Multiselect } from 'nextcloud-vue' import { Avatar, Multiselect } from 'nextcloud-vue'
import { mapGetters } from 'vuex'
export default { export default {
name: 'SharingTabSidebard', name: 'SharingTabSidebard',
@@ -31,17 +36,29 @@ export default {
Avatar, Avatar,
Multiselect, Multiselect,
}, },
props: {
},
data() { data() {
return { return {
isLoading: false
} }
}, },
computed: {
...mapGetters({
sharees: 'sharees'
})
},
props: { props: {
board: { board: {
type: Object, type: Object,
default: undefined default: undefined
} }
},
methods: {
asyncFind (query) {
this.isLoading = true
this.$store.dispatch('loadSharees').then(response => {
this.isLoading = false
})
},
} }

View File

@@ -51,12 +51,16 @@ export default new Vuex.Store({
sidebarShown: false, sidebarShown: false,
currentBoard: null, currentBoard: null,
boards: [], boards: [],
sharees: [],
boardFilter: BOARD_FILTERS.ALL boardFilter: BOARD_FILTERS.ALL
}, },
getters: { getters: {
boards: state => { boards: state => {
return state.boards return state.boards
}, },
sharees: state => {
return state.sharees
},
noneArchivedBoards: state => { noneArchivedBoards: state => {
return state.boards.filter(board => { return state.boards.filter(board => {
return board.archived === false && !board.deletedAt return board.archived === false && !board.deletedAt
@@ -212,14 +216,15 @@ export default new Vuex.Store({
const boards = await apiClient.loadBoards() const boards = await apiClient.loadBoards()
commit('setBoards', boards) commit('setBoards', boards)
}, },
async loadSharees({ commit }) { loadSharees({ commit }) {
const params = { const params = new URLSearchParams()
format: 'json', params.append('format', 'json')
perPage: 4, params.append('perPage', 4)
itemType: [0, 1] params.append('itemType', 0)
} params.append('itemType', 1)
const { data } = await axios.get(OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { params }) axios.get(OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { params }).then((response) => {
commit('setSharees', data.users) commit('setSharees', response.data.ocs.data.users)
})
}, },
setBoardFilter({ commmit }, filter) { setBoardFilter({ commmit }, filter) {
commmit('setBoardFilter', filter) commmit('setBoardFilter', filter)