bfg-common 1.4.792 → 1.4.794

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.
@@ -1,326 +1,308 @@
1
- <template>
2
- <ui-data-table
3
- test-id="task-table"
4
- :data="data"
5
- :options="options"
6
- :loading="props.loading || true"
7
- :total-pages="props.totalPages"
8
- :total-items="props.totalItems"
9
- :texts="texts"
10
- size="sm"
11
- class="task-table"
12
- :texts="tableTexts"
13
- @sort="onSorting"
14
- @pagination="onPagination"
15
- @column-filter="onColumnFilter"
16
- >
17
- <template #icon="{ item }">
18
- <span class="flex-align-center">
19
- <span :class="['icon', item.data.icon]" />
20
-
21
- <span
22
- :data-id="`rtask-${item.data.testId}`"
23
- :class="item.data.isLink && 'target-link'"
24
- @click.stop="onSelectNodeOfTree(item.data)"
25
- >
26
- {{ item.text }}
27
- </span>
28
- </span>
29
- </template>
30
-
31
- <template #status="{ item }">
32
- <ui-chip :test-id="item.data.testId" :color="item.data.chipColor" rounded>
33
- <ui-icon
34
- :name="item.data.icon"
35
- width="14px"
36
- height="14px"
37
- class="chip-icon"
38
- ></ui-icon>
39
- {{ item.text }}
40
- </ui-chip>
41
-
42
- <common-pages-tasks-table-error-info
43
- v-if="item.data.error"
44
- :id="item.data.testId"
45
- :error="item.data.error"
46
- :opened-error="openedError"
47
- @toggle-error="onToggleError"
48
- />
49
- </template>
50
-
51
- <template #default-actions="{ item }">
52
- <div class="actions">
53
- <ui-button
54
- variant="text"
55
- :test-id="`data-table-task-action-${item.data.id}`"
56
- is-without-height
57
- is-without-sizes
58
- @click.stop="onToggleActions(item.data.id)"
59
- >
60
- <span
61
- :class="['action-icon', { active: actionsShowId === item.data.id }]"
62
- >
63
- <ui-icon name="vertical-dotes" width="20" height="20" />
64
- </span>
65
- </ui-button>
66
- <ui-dropdown
67
- :show="actionsShowId === item.data.id"
68
- :test-id="`data-table-task-dropdown-${item.data.id}`"
69
- :items="actions"
70
- :elem-id="`data-table-task-action-${item.data.id}`"
71
- left
72
- width="max-content"
73
- @select="onSelectAction(item.data.target, $event)"
74
- @hide="onHideActionsDropdown"
75
- >
76
- <template #row="{ item: dropMenu }">
77
- <ui-icon
78
- v-if="dropMenu.iconName === 'hide'"
79
- name="password-hide"
80
- width="16"
81
- height="16"
82
- />
83
- <span class="action-text">
84
- {{ dropMenu.text }}
85
- </span>
86
- </template>
87
- </ui-dropdown>
88
- </div>
89
- </template>
90
-
91
- <template #expand="{ item }">
92
- <common-pages-tasks-table-expand-details :data="item.data" />
93
- </template>
94
- </ui-data-table>
95
- </template>
96
-
97
- <script setup lang="ts">
98
- import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
99
- import type {
100
- UI_I_DataTable,
101
- UI_I_DataTableHeader,
102
- UI_I_DataTableBody,
103
- UI_I_Pagination,
104
- UI_I_TableTexts,
105
- } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
106
- import type { UI_T_ArbitraryObject } from '~/node_modules/bfg-uikit/models/types'
107
- import type { UI_T_Project, UI_T_ProcuratorTypeNodes } from '~/lib/models/types'
108
- import type { UI_I_Localization } from '~/lib/models/interfaces'
109
- import type { UI_I_TaskItem } from '~/lib/models/store/tasks/interfaces'
110
- import type { UI_I_TableTarget } from '~/lib/models/table/interfaces'
111
- import type { UI_I_TableTexts } from 'bfg-uikit/components/ui/dataTable/models/interfaces'
112
- import {
113
- options,
114
- getTargetActionsFunc,
115
- getHeaderDataFunc,
116
- getBodyDataFunc,
117
- } from '~/components/common/pages/tasks/table/lib/config/config'
118
- import { useDebounceFn } from '@vueuse/core'
119
-
120
- const props = defineProps<{
121
- project: UI_T_Project
122
- tableData: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]
123
- totalPages: number
124
- totalItems: number
125
- loading: boolean
126
- }>()
127
- const emits = defineEmits<{
128
- (event: 'sort', value: string): void
129
- (event: 'pagination', value: UI_I_Pagination): void
130
- (event: 'col-search', value: string): void
131
- }>()
132
-
133
- const localization = computed<UI_I_Localization>(() => useLocal())
134
- const { $store }: any = useNuxtApp()
135
-
136
- const texts = computed<UI_I_TableTexts>(() => ({
137
- searchHere: localization.value.common.searchHere,
138
- rowsPerPage: localization.value.common.rowsPerPage,
139
- of: localization.value.common.of,
140
- selected: localization.value.common.selected,
141
- columns: localization.value.common.columns,
142
- previous: localization.value.common.previous,
143
- next: localization.value.common.next,
144
- noItemsFound: localization.value.common.noItemsFound,
145
- exportAll: localization.value.common.exportAll,
146
- exportSelected: localization.value.common.exportSelected,
147
- all: localization.value.common.all,
148
- }))
149
-
150
- const actionsShowId = ref<number>(-1)
151
-
152
- const data = computed<UI_I_DataTable>(() => ({
153
- id: 'tasks-table',
154
- header: taskHeadItems.value,
155
- body: taskBodyItems.value,
156
- }))
157
-
158
- const taskHeadItems = computed<UI_I_DataTableHeader[]>(() =>
159
- getHeaderDataFunc(localization.value)
160
- )
161
-
162
- const taskBodyItems = ref<UI_I_DataTableBody[]>([])
163
- watch(
164
- () => props.tableData,
165
- (newValue: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]) => {
166
- if (!newValue?.length) {
167
- taskBodyItems.value = []
168
- return
169
- }
170
-
171
- taskBodyItems.value = getBodyDataFunc(newValue, localization.value)
172
- },
173
- { deep: true, immediate: true }
174
- )
175
-
176
- const openedError = ref<string>('')
177
-
178
- const onToggleError = (value: string): void => {
179
- if (!value || value === openedError.value) {
180
- openedError.value = ''
181
- } else {
182
- openedError.value = value
183
- }
184
- }
185
-
186
- const onSorting = (value: string): void => {
187
- emits('sort', value)
188
- }
189
- const onPagination = (value: UI_I_Pagination): void => {
190
- emits('pagination', value)
191
- }
192
- const sendFilter = useDebounceFn((searchText: string) => {
193
- emits('col-search', searchText)
194
- }, 1000)
195
- const onColumnFilter = (obj: UI_T_ArbitraryObject<string>): void => {
196
- let searchText = ''
197
-
198
- for (const [key, value] of Object.entries(obj)) {
199
- const currentFilter = searchText
200
- ? ',' + key + '.' + value
201
- : key + '.' + value
202
-
203
- searchText = searchText + (value ? currentFilter : '')
204
- }
205
- sendFilter(searchText)
206
- }
207
-
208
- const actions = computed<UI_I_Dropdown[]>(() =>
209
- getTargetActionsFunc(localization.value, props.project)
210
- )
211
- const onToggleActions = (id: number): void => {
212
- if (actionsShowId.value === id) {
213
- actionsShowId.value = -1
214
- } else {
215
- actionsShowId.value = id
216
- }
217
- }
218
- const onSelectAction = (
219
- data: UI_I_TableTarget<typeof props.project>,
220
- action: 'view-target' | 'view-zone'
221
- ): void => {
222
- switch (action) {
223
- case 'view-target':
224
- onSelectNodeOfTree(data)
225
- break
226
- case 'view-zone':
227
- onSelectNodeOfTree({ ...data, type: 'zone', nav: 'h' })
228
- break
229
- }
230
- onHideActionsDropdown()
231
- }
232
- const onHideActionsDropdown = (): void => {
233
- actionsShowId.value = -1
234
- }
235
-
236
- const onSelectNodeOfTree = (
237
- data: UI_I_TableTarget<typeof props.project>
238
- ): void => {
239
- if (!data.isLink) return
240
-
241
- const { type, id, nav } = data
242
-
243
- const node = {
244
- id,
245
- type,
246
- }
247
-
248
- const path = `/inventory/type=${type};nav=${nav};id=${id}/summary`
249
- navigateTo(path)
250
-
251
- $store.dispatch('inventory/A_SELECT_NODE', { node, type })
252
- }
253
-
254
- const tableTexts = computed<UI_I_TableTexts>(() => {
255
- return {
256
- rowsPerPage: localization.value.common.rowsPerPage,
257
- of: localization.value.common.of,
258
- searchHere: localization.value.common.searchHere,
259
- selected: localization.value.common.selected,
260
- columns: localization.value.common.columns,
261
- previous: localization.value.common.previous,
262
- next: localization.value.common.next,
263
- noItemsFound: localization.value.common.noItemsFound,
264
- exportSelected: localization.value.common.exportSelected,
265
- exportAll: localization.value.common.exportAll,
266
- }
267
- })
268
- </script>
269
-
270
- <style>
271
- /*TODO move up*/
272
- :root {
273
- --actions-icon-color: #4d5d69;
274
- --actions-icon-hover-color: #213444;
275
- --actions-icon-icative-color: #008fd6;
276
- }
277
- :root.dark-theme {
278
- --actions-icon-color: #e9eaec;
279
- --actions-icon-hover-color: #ffffff;
280
- --actions-icon-icative-color: #2ba2de;
281
- }
282
- </style>
283
- <style scoped lang="scss">
284
- .task-table {
285
- height: inherit;
286
-
287
- .target-link {
288
- font-family: Inter, serif;
289
- font-size: 13px;
290
- color: var(--bottom-pannel-rtask-link-text);
291
- font-weight: 400;
292
- line-height: 15.73px;
293
- cursor: pointer;
294
- &:hover {
295
- color: var(--bottom-pannel-rtask-link-hover-text);
296
- }
297
- }
298
- .chip-icon {
299
- min-width: 14px;
300
- }
301
- .icon {
302
- margin-right: 4px;
303
- }
304
-
305
- .actions {
306
- width: 100%;
307
-
308
- .action-icon {
309
- width: 16px;
310
- height: 16px;
311
- color: var(--actions-icon-color);
312
-
313
- &:hover {
314
- color: var(--actions-icon-hover-color);
315
- }
316
- &.active {
317
- color: var(--actions-icon-icative-color);
318
- }
319
- }
320
-
321
- .action-text {
322
- margin-left: 8px;
323
- }
324
- }
325
- }
326
- </style>
1
+ <template>
2
+ <ui-data-table
3
+ test-id="task-table"
4
+ :data="data"
5
+ :options="options"
6
+ :loading="props.loading"
7
+ :total-pages="props.totalPages"
8
+ :total-items="props.totalItems"
9
+ :texts="texts"
10
+ class="task-table"
11
+ @sort="onSorting"
12
+ @pagination="onPagination"
13
+ @column-filter="onColumnFilter"
14
+ >
15
+ <template #icon="{ item }">
16
+ <span class="flex-align-center">
17
+ <span :class="['icon', item.data.icon]" />
18
+
19
+ <span
20
+ :data-id="`rtask-${item.data.testId}`"
21
+ :class="item.data.isLink && 'target-link'"
22
+ @click.stop="onSelectNodeOfTree(item.data)"
23
+ >
24
+ {{ item.text }}
25
+ </span>
26
+ </span>
27
+ </template>
28
+
29
+ <template #status="{ item }">
30
+ <ui-chip :test-id="item.data.testId" :color="item.data.chipColor" rounded>
31
+ <ui-icon
32
+ :name="item.data.icon"
33
+ width="14px"
34
+ height="14px"
35
+ class="chip-icon"
36
+ ></ui-icon>
37
+ {{ item.text }}
38
+ </ui-chip>
39
+
40
+ <common-pages-tasks-table-error-info
41
+ v-if="item.data.error"
42
+ :id="item.data.testId"
43
+ :error="item.data.error"
44
+ :opened-error="openedError"
45
+ @toggle-error="onToggleError"
46
+ />
47
+ </template>
48
+
49
+ <template #default-actions="{ item }">
50
+ <div class="actions">
51
+ <ui-button
52
+ variant="text"
53
+ :test-id="`data-table-task-action-${item.data.id}`"
54
+ is-without-height
55
+ is-without-sizes
56
+ @click.stop="onToggleActions(item.data.id)"
57
+ >
58
+ <span
59
+ :class="['action-icon', { active: actionsShowId === item.data.id }]"
60
+ >
61
+ <ui-icon name="vertical-dotes" width="20" height="20" />
62
+ </span>
63
+ </ui-button>
64
+ <ui-dropdown
65
+ :show="actionsShowId === item.data.id"
66
+ :test-id="`data-table-task-dropdown-${item.data.id}`"
67
+ :items="actions"
68
+ :elem-id="`data-table-task-action-${item.data.id}`"
69
+ left
70
+ width="max-content"
71
+ @select="onSelectAction(item.data.target, $event)"
72
+ @hide="onHideActionsDropdown"
73
+ >
74
+ <template #row="{ item: dropMenu }">
75
+ <ui-icon
76
+ v-if="dropMenu.iconName === 'hide'"
77
+ name="password-hide"
78
+ width="16"
79
+ height="16"
80
+ />
81
+ <span class="action-text">
82
+ {{ dropMenu.text }}
83
+ </span>
84
+ </template>
85
+ </ui-dropdown>
86
+ </div>
87
+ </template>
88
+
89
+ <template #expand="{ item }">
90
+ <common-pages-tasks-table-expand-details :data="item.data" />
91
+ </template>
92
+ </ui-data-table>
93
+ </template>
94
+
95
+ <script setup lang="ts">
96
+ import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
97
+ import type {
98
+ UI_I_DataTable,
99
+ UI_I_DataTableHeader,
100
+ UI_I_DataTableBody,
101
+ UI_I_Pagination,
102
+ UI_I_TableTexts,
103
+ } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
104
+ import type { UI_T_ArbitraryObject } from '~/node_modules/bfg-uikit/models/types'
105
+ import type { UI_T_Project, UI_T_ProcuratorTypeNodes } from '~/lib/models/types'
106
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
107
+ import type { UI_I_TaskItem } from '~/lib/models/store/tasks/interfaces'
108
+ import type { UI_I_TableTarget } from '~/lib/models/table/interfaces'
109
+ import {
110
+ options,
111
+ getTargetActionsFunc,
112
+ getHeaderDataFunc,
113
+ getBodyDataFunc,
114
+ } from '~/components/common/pages/tasks/table/lib/config/config'
115
+ import { useDebounceFn } from '@vueuse/core'
116
+
117
+ const props = defineProps<{
118
+ project: UI_T_Project
119
+ tableData: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]
120
+ totalPages: number
121
+ totalItems: number
122
+ loading: boolean
123
+ }>()
124
+ const emits = defineEmits<{
125
+ (event: 'sort', value: string): void
126
+ (event: 'pagination', value: UI_I_Pagination): void
127
+ (event: 'col-search', value: string): void
128
+ }>()
129
+
130
+ const localization = computed<UI_I_Localization>(() => useLocal())
131
+ const { $store }: any = useNuxtApp()
132
+
133
+ const texts = computed<UI_I_TableTexts>(() => ({
134
+ searchHere: localization.value.common.searchHere,
135
+ rowsPerPage: localization.value.common.rowsPerPage,
136
+ of: localization.value.common.of,
137
+ selected: localization.value.common.selected,
138
+ columns: localization.value.common.columns,
139
+ previous: localization.value.common.previous,
140
+ next: localization.value.common.next,
141
+ noItemsFound: localization.value.common.noItemsFound,
142
+ exportAll: localization.value.common.exportAll,
143
+ exportSelected: localization.value.common.exportSelected,
144
+ all: localization.value.common.all,
145
+ }))
146
+
147
+ const actionsShowId = ref<number>(-1)
148
+
149
+ const data = computed<UI_I_DataTable>(() => ({
150
+ id: 'tasks-table',
151
+ header: taskHeadItems.value,
152
+ body: taskBodyItems.value,
153
+ }))
154
+
155
+ const taskHeadItems = computed<UI_I_DataTableHeader[]>(() =>
156
+ getHeaderDataFunc(localization.value)
157
+ )
158
+
159
+ const taskBodyItems = ref<UI_I_DataTableBody[]>([])
160
+ watch(
161
+ () => props.tableData,
162
+ (newValue: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]) => {
163
+ if (!newValue?.length) {
164
+ taskBodyItems.value = []
165
+ return
166
+ }
167
+
168
+ taskBodyItems.value = getBodyDataFunc(newValue, localization.value)
169
+ },
170
+ { deep: true, immediate: true }
171
+ )
172
+
173
+ const openedError = ref<string>('')
174
+
175
+ const onToggleError = (value: string): void => {
176
+ if (!value || value === openedError.value) {
177
+ openedError.value = ''
178
+ } else {
179
+ openedError.value = value
180
+ }
181
+ }
182
+
183
+ const onSorting = (value: string): void => {
184
+ emits('sort', value)
185
+ }
186
+ const onPagination = (value: UI_I_Pagination): void => {
187
+ emits('pagination', value)
188
+ }
189
+ const sendFilter = useDebounceFn((searchText: string) => {
190
+ emits('col-search', searchText)
191
+ }, 1000)
192
+ const onColumnFilter = (obj: UI_T_ArbitraryObject<string>): void => {
193
+ let searchText = ''
194
+
195
+ for (const [key, value] of Object.entries(obj)) {
196
+ const currentFilter = searchText
197
+ ? ',' + key + '.' + value
198
+ : key + '.' + value
199
+
200
+ searchText = searchText + (value ? currentFilter : '')
201
+ }
202
+ sendFilter(searchText)
203
+ }
204
+
205
+ const actions = computed<UI_I_Dropdown[]>(() =>
206
+ getTargetActionsFunc(localization.value, props.project)
207
+ )
208
+ const onToggleActions = (id: number): void => {
209
+ if (actionsShowId.value === id) {
210
+ actionsShowId.value = -1
211
+ } else {
212
+ actionsShowId.value = id
213
+ }
214
+ }
215
+ const onSelectAction = (
216
+ data: UI_I_TableTarget<typeof props.project>,
217
+ action: 'view-target' | 'view-zone'
218
+ ): void => {
219
+ switch (action) {
220
+ case 'view-target':
221
+ onSelectNodeOfTree(data)
222
+ break
223
+ case 'view-zone':
224
+ onSelectNodeOfTree({ ...data, type: 'zone', nav: 'h' })
225
+ break
226
+ }
227
+ onHideActionsDropdown()
228
+ }
229
+ const onHideActionsDropdown = (): void => {
230
+ actionsShowId.value = -1
231
+ }
232
+
233
+ const onSelectNodeOfTree = (
234
+ data: UI_I_TableTarget<typeof props.project>
235
+ ): void => {
236
+ if (!data.isLink) return
237
+
238
+ const { type, id, nav } = data
239
+
240
+ const node = {
241
+ id,
242
+ type,
243
+ }
244
+
245
+ const path = `/inventory/type=${type};nav=${nav};id=${id}/summary`
246
+ navigateTo(path)
247
+
248
+ $store.dispatch('inventory/A_SELECT_NODE', { node, type })
249
+ }
250
+ </script>
251
+
252
+ <style>
253
+ /*TODO move up*/
254
+ :root {
255
+ --actions-icon-color: #4d5d69;
256
+ --actions-icon-hover-color: #213444;
257
+ --actions-icon-icative-color: #008fd6;
258
+ }
259
+ :root.dark-theme {
260
+ --actions-icon-color: #e9eaec;
261
+ --actions-icon-hover-color: #ffffff;
262
+ --actions-icon-icative-color: #2ba2de;
263
+ }
264
+ </style>
265
+ <style scoped lang="scss">
266
+ .task-table {
267
+ height: inherit;
268
+
269
+ .target-link {
270
+ font-family: Inter, serif;
271
+ font-size: 13px;
272
+ color: var(--bottom-pannel-rtask-link-text);
273
+ font-weight: 400;
274
+ line-height: 15.73px;
275
+ cursor: pointer;
276
+ &:hover {
277
+ color: var(--bottom-pannel-rtask-link-hover-text);
278
+ }
279
+ }
280
+ .chip-icon {
281
+ min-width: 14px;
282
+ }
283
+ .icon {
284
+ margin-right: 4px;
285
+ }
286
+
287
+ .actions {
288
+ width: 100%;
289
+
290
+ .action-icon {
291
+ width: 16px;
292
+ height: 16px;
293
+ color: var(--actions-icon-color);
294
+
295
+ &:hover {
296
+ color: var(--actions-icon-hover-color);
297
+ }
298
+ &.active {
299
+ color: var(--actions-icon-icative-color);
300
+ }
301
+ }
302
+
303
+ .action-text {
304
+ margin-left: 8px;
305
+ }
306
+ }
307
+ }
308
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.792",
4
+ "version": "1.4.794",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",