@webitel/ui-sdk 24.10.42 → 24.10.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,215 @@
1
+ <template>
2
+ <section
3
+ v-if="access.read"
4
+ class="permissions-tab"
5
+ >
6
+ <header class="content-header">
7
+ <h3 class="content-title">
8
+ {{ $t('access.operations') }}
9
+ </h3>
10
+ <div class="content-header__actions-wrap">
11
+ <!-- TODO replace wt-table-actions -->
12
+ <!-- <wt-table-actions-->
13
+ <!-- :icons="['refresh']"-->
14
+ <!-- @input="(event) => event === 'refresh' && loadData()"-->
15
+ <!-- >-->
16
+ <!-- </wt-table-actions>-->
17
+ <role-popup
18
+ v-if="props.access.add"
19
+ :namespace="tableNamespace"
20
+ />
21
+ </div>
22
+ </header>
23
+
24
+ <wt-loader v-show="isLoading" />
25
+
26
+ <!-- TODO -->
27
+ <!-- <wt-dummy-->
28
+ <!-- v-if="dummy && !isLoading"-->
29
+ <!-- :dark-mode="darkMode"-->
30
+ <!-- :src="dummy.src"-->
31
+ <!-- :text="dummy.text && t(dummy.text)"-->
32
+ <!-- class="dummy-wrapper"-->
33
+ <!-- />-->
34
+
35
+ <div class="table-wrapper">
36
+ <div
37
+ v-if="dataList.length && !isLoading"
38
+ style="display:contents;"
39
+ >
40
+ <!-- TODO -->
41
+ <!-- <transition-slide-->
42
+ <!-- :offset="{-->
43
+ <!-- enter: ['-5%', 0],-->
44
+ <!-- leave: [0, 0]-->
45
+ <!-- }"-->
46
+ <!-- duration="200"-->
47
+ <!-- mode="out-in"-->
48
+ <!-- appear-->
49
+ <!-- >-->
50
+ <wt-table
51
+ :data="localizedDataList"
52
+ :grid-actions="access.edit"
53
+ :headers="headers"
54
+ :selectable="false"
55
+ sortable
56
+ @sort="sort"
57
+ >
58
+ <template #grantee="{ item }">
59
+ <role-column
60
+ :role="item.grantee"
61
+ />
62
+ </template>
63
+
64
+ <template #read="{ item }">
65
+ <wt-select
66
+ :clearable="false"
67
+ :disabled="!access.edit"
68
+ :options="accessOptions"
69
+ :value="item.access.r"
70
+ @input="changeAccessMode({ item, ruleName: 'r', mode: $event })"
71
+ />
72
+ </template>
73
+
74
+ <template #edit="{ item }">
75
+ <wt-select
76
+ :clearable="false"
77
+ :disabled="!access.edit"
78
+ :options="accessOptions"
79
+ :value="item.access.w"
80
+ @input="changeAccessMode({ item, ruleName: 'w', mode: $event })"
81
+ />
82
+ </template>
83
+
84
+ <template #delete="{ item }">
85
+ <wt-select
86
+ :clearable="false"
87
+ :disabled="!access.edit"
88
+ :options="accessOptions"
89
+ :value="item.access.d"
90
+ @input="changeAccessMode({ item, ruleName: 'd', mode: $event })"
91
+ />
92
+ </template>
93
+ <template #actions="{ item }">
94
+ <wt-icon-action
95
+ action="delete"
96
+ @click="changeAccessMode({ item, ruleName: 'r', mode: { id: AccessMode.FORBIDDEN }})"
97
+ />
98
+ </template>
99
+ </wt-table>
100
+ <!-- </transition-slide>-->
101
+ </div>
102
+ <filter-pagination
103
+ :namespace="filtersNamespace"
104
+ :next="isNext"
105
+ />
106
+ </div>
107
+ </section>
108
+ </template>
109
+
110
+ <script setup>
111
+ // TODO: класи, даммі, транзішен таблички. WTEL-3392
112
+
113
+ import { computed, onUnmounted } from 'vue';
114
+ import { useI18n } from 'vue-i18n';
115
+ import { useStore } from 'vuex';
116
+ import { useTableStore } from '../../../store/new/index.js';
117
+ import FilterPagination from '../../Filters/components/filter-pagination.vue';
118
+ import { useTableFilters } from '../../Filters/composables/useTableFilters.js';
119
+ import RoleColumn from '../_internals/components/permissions-role-row.vue';
120
+ import RolePopup from '../_internals/components/permissions-tab-role-popup.vue';
121
+ import { AccessMode } from '../_internals/enums/AccessMode.enum.js';
122
+
123
+ const props = defineProps({
124
+ namespace: {
125
+ type: String,
126
+ required: true,
127
+ },
128
+ access: {
129
+ type: Object,
130
+ default: () => ({
131
+ read: true,
132
+ add: true,
133
+ edit: true,
134
+ delete: true,
135
+ }),
136
+ },
137
+ });
138
+
139
+ const { t } = useI18n();
140
+ const store = useStore();
141
+
142
+ const {
143
+ namespace: tableNamespace,
144
+
145
+ dataList,
146
+ isLoading,
147
+ headers,
148
+ isNext,
149
+ error,
150
+
151
+ loadData, // TODO: use for refresh button
152
+ sort,
153
+ onFilterEvent,
154
+ } = useTableStore(`${props.namespace}/permissions`);
155
+
156
+ const localizedDataList = computed(() => {
157
+ return dataList.value.map((item) => {
158
+
159
+ const access = Object.keys(item.access).reduce((access, rule) => {
160
+ return {
161
+ ...access,
162
+ [rule]: {
163
+ ...item.access[rule],
164
+ name: t(`access.accessMode.${item.access[rule].id}`),
165
+ },
166
+ };
167
+ }, {});
168
+
169
+ return {
170
+ ...item,
171
+ access,
172
+ };
173
+ });
174
+ });
175
+
176
+ const {
177
+ namespace: filtersNamespace,
178
+ restoreFilters,
179
+
180
+ subscribe,
181
+ flushSubscribers,
182
+ } = useTableFilters(tableNamespace);
183
+
184
+ subscribe({
185
+ event: '*',
186
+ callback: onFilterEvent,
187
+ });
188
+
189
+ restoreFilters();
190
+
191
+ onUnmounted(() => {
192
+ flushSubscribers();
193
+ });
194
+
195
+ // TODO
196
+ // const { dummy } = useDummy({
197
+ // namespace,
198
+ // hiddenText: true,
199
+ // });
200
+
201
+ const accessOptions = computed(() => {
202
+ return Object.values(AccessMode).map((mode) => ({
203
+ id: mode,
204
+ name: t(`access.accessMode.${mode}`),
205
+ }));
206
+ });
207
+
208
+ const changeAccessMode = (payload) => (
209
+ store.dispatch(`${tableNamespace}/CHANGE_ACCESS_MODE`, payload)
210
+ );
211
+
212
+ </script>
213
+
214
+ <style lang="scss" scoped>
215
+ </style>
@@ -0,0 +1,7 @@
1
+ import {
2
+ createObjectPermissionsStoreModule,
3
+ } from '../_internals/store/helpers/createObjectPermissionsStoreModule.js';
4
+
5
+ export {
6
+ createObjectPermissionsStoreModule,
7
+ };