-
Notifications
You must be signed in to change notification settings - Fork 327
/
List.vue
150 lines (136 loc) · 3.44 KB
/
List.vue
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
<b-container
fluid="xl"
>
<c-content-header
:title="$t('title')"
>
<span
class="text-nowrap"
>
<b-button
v-if="canCreate"
variant="primary"
class="mr-2"
:to="{ name: 'system.sensitivityLevel.new' }"
>
{{ $t('new') }}
</b-button>
</span>
</c-content-header>
<c-resource-list
:primary-key="primaryKey"
:filter="filter"
:sorting="sorting"
:pagination="pagination"
:fields="fields"
:items="items"
:row-class="genericRowClass"
:translations="{
notFound: $t('admin:general.notFound'),
noItems: $t('admin:general.resource-list.no-items'),
loading: $t('loading'),
showingPagination: 'admin:general.pagination.showing',
singlePluralPagination: 'admin:general.pagination.single',
prevPagination: $t('admin:general.pagination.prev'),
nextPagination: $t('admin:general.pagination.next'),
resourceSingle: $t('general:label.sensitivity_level.single'),
resourcePlural: $t('general:label.sensitivity_level.plural'),
}"
sticky-header
hide-search
class="custom-resource-list-height"
>
<template #header>
<c-resource-list-status-filter
v-model="filter.deleted"
:label="$t('filterForm.deleted.label')"
:excluded-label="$t('filterForm.excluded.label')"
:inclusive-label="$t('filterForm.inclusive.label')"
:exclusive-label="$t('filterForm.exclusive.label')"
@change="filterList"
/>
</template>
<template #actions="{ item }">
<b-button
size="sm"
variant="link"
:to="{ name: editRoute, params: { [primaryKey]: item[primaryKey] } }"
>
<font-awesome-icon
:icon="['fas', 'pen']"
/>
</b-button>
</template>
</c-resource-list>
</b-container>
</template>
<script>
import * as moment from 'moment'
import listHelpers from 'corteza-webapp-admin/src/mixins/listHelpers'
import { mapGetters } from 'vuex'
import { components } from '@cortezaproject/corteza-vue'
const { CResourceList } = components
export default {
components: {
CResourceList,
},
mixins: [
listHelpers,
],
i18nOptions: {
namespaces: 'system.sensitivityLevel',
keyPrefix: 'list',
},
data () {
return {
id: 'sensitivityLevel',
primaryKey: 'sensitivityLevelID',
editRoute: 'system.sensitivityLevel.edit',
filter: {
query: '',
deleted: 0,
},
sorting: {
sortBy: 'level',
sortDesc: true,
},
fields: [
{
key: 'meta.name',
},
{
key: 'level',
sortable: true,
},
{
key: 'createdAt',
sortable: true,
formatter: (v) => moment(v).fromNow(),
},
{
key: 'actions',
tdClass: 'text-right',
},
].map(c => ({
...c,
// Generate column label translation key
label: this.$t(`columns.${c.key}`),
})),
}
},
computed: {
...mapGetters({
can: 'rbac/can',
}),
canCreate () {
return this.can('system/', 'dal-sensitivity-level.manage')
},
},
methods: {
items () {
return this.procListResults(this.$SystemAPI.dalSensitivityLevelList(this.encodeListParams()))
},
},
}
</script>