Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<div class="mt-sm-3">
<div>
<p>Search results:</p>
<b-list-group v-for="item in model.genericSearchResults.items" v-bind:key="item.id">
<b-list-group-item href="#" v-on:click="openSearchResult(item)">
<span class="float-left">
<font-awesome-icon icon="folder" v-if="item.type === 'GROUP'"></font-awesome-icon>
<font-awesome-icon icon="user" v-if="item.type === 'USER'"></font-awesome-icon>
{{item.label}}
</span>
</b-list-group-item>
</b-list-group>
<Paginator :paginatedPanel="model.genericSearchResults" :onUpdate="updateSearchResults" />
</div>
</div>
</template>
<script>
import client from 'api-client';
import Paginator from './Paginator.vue';
import {
mapState
} from 'vuex';
export default {
name: 'GenericSearchResults',
components: {
Paginator
},
computed: mapState({
model: state => state.model,
input: state => state.input
}),
methods: {
openSearchResult: function(result) {
switch (result.type) {
case 'GROUP':
this.$store.commit('openGroup', result.id);
break;
case 'USER':
client.openUserSearchResult(result.id)
.then(model => {
this.$store.commit('displayUserSearchResults', [result.label, model]);
});
break;
}
},
updateSearchResults: function() {
}
}
}
</script>