bfg-common 1.4.358 → 1.4.359

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,137 @@
1
+ import type {
2
+ UI_I_DataTableOptions,
3
+ UI_I_DataTableHeader,
4
+ UI_I_DataTableBody,
5
+ } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
6
+ import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
7
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
8
+ import type { UI_I_NewAttributeData } from '~/components/common/portlets/customAttributes/lib/models/interfaces'
9
+
10
+ export const attributeTableHeaderOptions: UI_I_DataTableOptions = {
11
+ perPageOptions: [],
12
+ selectType: 'checkbox',
13
+ showPagination: false,
14
+ showPageInfo: false,
15
+ isSortable: true,
16
+ server: false,
17
+ isResizable: false,
18
+ showSearch: false,
19
+ showColumnManager: false,
20
+ isSelectable: false,
21
+ }
22
+
23
+ export const attributeTableHeaderDataFunc = (
24
+ localization: UI_I_Localization
25
+ ): UI_I_DataTableHeader[] => [
26
+ {
27
+ col: 0,
28
+ colName: 'Attribute',
29
+ text: localization.common.attribute,
30
+ isSortable: true,
31
+ sort: 'asc',
32
+ width: '31%',
33
+ show: true,
34
+ filter: false,
35
+ },
36
+ {
37
+ col: 1,
38
+ colName: 'value',
39
+ text: localization.common.value,
40
+ isSortable: true,
41
+ sort: 'asc',
42
+ width: '31%',
43
+ show: true,
44
+ filter: false,
45
+ },
46
+ {
47
+ col: 2,
48
+ colName: 'type',
49
+ text: localization.common.type,
50
+ isSortable: true,
51
+ sort: 'asc',
52
+ width: '31%',
53
+ show: true,
54
+ filter: false,
55
+ },
56
+ {
57
+ col: 3,
58
+ colName: '',
59
+ text: '',
60
+ width: '7%',
61
+ show: true,
62
+ },
63
+ ]
64
+
65
+ export const createRow = (
66
+ row: number,
67
+ data: UI_I_NewAttributeData
68
+ ): UI_I_DataTableBody => ({
69
+ row,
70
+ isSelected: false,
71
+ data: [
72
+ { col: 0, text: data.attribute },
73
+ { col: 1, text: data.value },
74
+ { col: 2, text: data.type },
75
+ {
76
+ col: 3,
77
+ text: '',
78
+ key: 'icon',
79
+ data: {
80
+ type: 'options',
81
+ icon: 'vertical-dotes',
82
+ row,
83
+ },
84
+ },
85
+ ],
86
+ })
87
+
88
+ export const makeNewAttributeCreateActionRowFunc = (
89
+ row: number
90
+ ): UI_I_DataTableBody => ({
91
+ row,
92
+ isSelected: false,
93
+ actionRow: true,
94
+ data: [
95
+ {
96
+ col: 0,
97
+ text: '',
98
+ key: 'icon',
99
+ data: {
100
+ type: 'attribute',
101
+ },
102
+ },
103
+ {
104
+ col: 1,
105
+ text: '',
106
+ key: 'icon',
107
+ data: {
108
+ type: 'value',
109
+ },
110
+ },
111
+ {
112
+ col: 2,
113
+ text: '',
114
+ key: 'icon',
115
+ data: {
116
+ type: 'type',
117
+ },
118
+ },
119
+ {
120
+ col: 3,
121
+ text: '',
122
+ key: 'icon',
123
+ data: {
124
+ type: 'actions',
125
+ },
126
+ },
127
+ ],
128
+ })
129
+
130
+ export const availableTypesFunc = (type: UI_I_Dropdown): UI_I_Dropdown[] => [
131
+ {
132
+ text: 'Global',
133
+ value: 'Global',
134
+ selected: false,
135
+ },
136
+ type,
137
+ ]
@@ -0,0 +1,5 @@
1
+ export interface UI_I_NewAttributeData {
2
+ attribute: string
3
+ value: string
4
+ type: string
5
+ }
@@ -116,7 +116,7 @@ import type {
116
116
  UI_I_Localization,
117
117
  } from '~/lib/models/interfaces'
118
118
  import type { UI_I_ModalTexts } from '~/node_modules/bfg-uikit/components/ui/modal/models/interfaces'
119
- import type { I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
119
+ import type { UI_I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
120
120
  import {
121
121
  createCategoryData,
122
122
  createCategoryTypes,
@@ -128,7 +128,7 @@ const props = defineProps<{
128
128
 
129
129
  const emits = defineEmits<{
130
130
  (event: 'cancel'): void
131
- (event: 'create', value: I_CreateCategoryData): void
131
+ (event: 'create', value: UI_I_CreateCategoryData): void
132
132
  }>()
133
133
 
134
134
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -138,7 +138,7 @@ const createCategoryTexts = computed<UI_I_ModalTexts>(() => ({
138
138
  button2: localization.value.common.create,
139
139
  }))
140
140
 
141
- const data = ref<I_CreateCategoryData>(useDeepCopy(createCategoryData))
141
+ const data = ref<UI_I_CreateCategoryData>(useDeepCopy(createCategoryData))
142
142
 
143
143
  const isAllSelected = computed<boolean>(() => {
144
144
  let result = true
@@ -3,7 +3,7 @@
3
3
  <ui-portlet
4
4
  class="tags"
5
5
  test-id="tags-portlet"
6
- :title="localization.common.assignedTags"
6
+ :title="portletTitle"
7
7
  :dragged="props.dragged"
8
8
  :dragged-any="props.draggedAny"
9
9
  :is-open="props.isOpen"
@@ -45,7 +45,7 @@
45
45
  data-id="view-tag-details-action"
46
46
  @click="onShowDetails(item.data.row)"
47
47
  >
48
- <ui-icon name="details" width="16" height="16" />
48
+ <ui-icon name="view-details" width="16" height="16" />
49
49
  <span>{{ localization.common.viewDetails }}</span>
50
50
  </div>
51
51
  <div
@@ -98,7 +98,6 @@
98
98
  @cancel="onHideAssignModal"
99
99
  @assign="onAssignSelectedTags"
100
100
  />
101
-
102
101
  </div>
103
102
  </template>
104
103
 
@@ -114,7 +113,7 @@ import type {
114
113
  UI_I_DataTableBody,
115
114
  } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
116
115
  import type { UI_I_ModalTexts } from '~/node_modules/bfg-uikit/components/ui/modal/models/interfaces'
117
- import type { I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
116
+ import type { UI_I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
118
117
  import {
119
118
  tagTableHeaderOptions,
120
119
  tagTableHeaderDataFunc,
@@ -127,7 +126,7 @@ const props = defineProps<{
127
126
  isOpen?: boolean
128
127
  draggedAny?: boolean
129
128
  selectedItemName: string
130
- objectSummary: any
129
+ bodyItems: UI_I_DataTableBody[]
131
130
  }>()
132
131
 
133
132
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -178,6 +177,13 @@ const removeTagDialogTexts = computed<UI_I_ModalTexts>(() => ({
178
177
 
179
178
  const onRemoveTag = (): void => {
180
179
  onHideRemoveDialog()
180
+
181
+ const removeItem = tagsBodyItems.value.find(
182
+ (row) => row.row === tagIdForRemove.value
183
+ )
184
+ if (!removeItem) return
185
+
186
+ emits('remove-tag', removeItem)
181
187
  tagsBodyItems.value = tagsBodyItems.value.filter(
182
188
  (row) => row.row !== tagIdForRemove.value
183
189
  )
@@ -200,41 +206,13 @@ const tagsHeadItems = computed<UI_I_DataTableHeader[]>(() =>
200
206
  const tagsBodyItems = ref<UI_I_DataTableBody[]>([])
201
207
 
202
208
  watch(
203
- () => props.objectSummary,
204
- (newValue: any) => {
205
- let result: UI_I_DataTableBody[] = []
206
- const attr = newValue.portlets?.find((portlet) => portlet.kind === 2)
207
-
208
- if (attr) {
209
- const rows = []
210
-
211
- for (const key in attr.rows) {
212
- // @ts-ignore
213
- rows.push({
214
- row: +key,
215
- data: [
216
- { col: 0, text: attr.rows[key][0] },
217
- { col: 1, text: attr.rows[key][1] },
218
- { col: 2, text: attr.rows[key][2] },
219
- {
220
- col: 3,
221
- text: '',
222
- key: 'icon',
223
- data: {
224
- icon: 'vertical-dotes',
225
- row: +key,
226
- },
227
- },
228
- ],
229
- })
230
- }
231
- result = rows
232
- }
233
-
234
- tagsBodyItems.value = result
209
+ () => props.bodyItems,
210
+ (newValue: UI_I_DataTableBody[]) => {
211
+ tagsBodyItems.value = newValue
235
212
  },
236
213
  { deep: true, immediate: true }
237
214
  )
215
+
238
216
  const tagsAssignBodyItems = ref<UI_I_DataTableBody[]>(
239
217
  useDeepCopy(tagsAssignBodyItemsTemporary)
240
218
  )
@@ -285,7 +263,9 @@ const onAssignSelectedTags = async (
285
263
  data: UI_I_DataTableBody[]
286
264
  ): Promise<void> => {
287
265
  if (data.length > 0) {
288
- const sortedIds = tagsBodyItems.value.map((row: UI_I_DataTableBody) => Number(row.row)).sort()
266
+ const sortedIds = tagsBodyItems.value
267
+ .map((row: UI_I_DataTableBody) => Number(row.row))
268
+ .sort()
289
269
  let lastId = sortedIds[sortedIds.length - 1]
290
270
  lastId = lastId === undefined ? -1 : lastId
291
271
 
@@ -337,19 +317,26 @@ const onAssignSelectedTags = async (
337
317
  //
338
318
  // globalRefresh()
339
319
  }
320
+
321
+ const portletTitle = computed<string>(
322
+ () =>
323
+ localization.value.common.assignedTags +
324
+ (tagsBodyItems.value.length ? ` (${tagsBodyItems.value.length})` : '')
325
+ )
340
326
  // const globalRefresh = (): void => {
341
327
  // $store.dispatch('main/A_GLOBAL_REFRESH', null)
342
328
  // }
343
329
 
344
- const onCreateCategory = (data: I_CreateCategoryData): void => {
330
+ const onCreateCategory = (data: UI_I_CreateCategoryData): void => {
345
331
  emits('create-category', data)
346
332
  }
347
333
 
348
334
  const emits = defineEmits<{
349
335
  (event: 'toggle-portlet', id: string): void
350
- (event: 'create-category', value: I_CreateCategoryData): void
336
+ (event: 'create-category', value: UI_I_CreateCategoryData): void
351
337
  (event: 'create-new-tag', value: UI_I_DataTableBody): void
352
338
  (event: 'assign-new-tags', value: UI_I_DataTableBody[]): void
339
+ (event: 'remove-tag', value: UI_I_DataTableBody): void
353
340
  }>()
354
341
 
355
342
  const onTogglePortlet = (id: string): void => {
@@ -357,34 +344,7 @@ const onTogglePortlet = (id: string): void => {
357
344
  }
358
345
  </script>
359
346
 
360
- <style>
361
- :root {
362
- --table-actions-icon: #4d5d69;
363
- --table-actions-icon-hover: #008fd6;
364
- --table-actions-view: #182531;
365
- --table-actions-remove: #ea3223;
366
- --table-actions-bg-hover: #e9ebed66;
367
- }
368
- :root.dark-theme {
369
- --table-actions-icon: #e9eaec;
370
- --table-actions-icon-hover: #ffffff;
371
- --table-actions-view: #ffffff;
372
- --table-actions-remove: #ea3223;
373
- --table-actions-bg-hover: #e9ebed0f;
374
- }
375
- </style>
376
-
377
347
  <style scoped lang="scss">
378
- .footer {
379
- padding: 0 10px 5px;
380
-
381
- .edit-trigger {
382
- color: var(--global-text-color);
383
- cursor: pointer;
384
- margin-right: 10px;
385
- }
386
- }
387
-
388
348
  .icon-container {
389
349
  width: 16px;
390
350
  height: 16px;
@@ -440,6 +400,8 @@ const onTogglePortlet = (id: string): void => {
440
400
  }
441
401
 
442
402
  .footer {
403
+ padding: 0 16px 8px;
404
+
443
405
  :deep(button.ui-btn) {
444
406
  line-height: 16px;
445
407
  margin-bottom: 11px;
@@ -19,6 +19,18 @@
19
19
  :messages="[localization.common.pleaseFillAllRequiredFields]"
20
20
  test-id="required-alert"
21
21
  simple-error
22
+ hide-close-button
23
+ />
24
+ </div>
25
+ <div
26
+ v-if="!isShowRequiredFieldsError && selectedRowsCount > 1"
27
+ style="margin: 8px 0"
28
+ >
29
+ <ui-alert
30
+ :messages="[localization.common.multipleTagsSelectedAlert]"
31
+ test-id="multiple-tags-alert"
32
+ type="info"
33
+ hide-close-button
22
34
  />
23
35
  </div>
24
36
  <div class="modal-top">
@@ -29,7 +41,7 @@
29
41
  <ui-data-table
30
42
  test-id="assign-tags-data-table"
31
43
  :data="assignDataLocal"
32
- :options="options"
44
+ :options="tagTableHeaderOptions"
33
45
  server-off
34
46
  :default-layout="false"
35
47
  size="sm"
@@ -121,28 +133,20 @@
121
133
  style="display: flex; align-items: center; column-gap: 12px"
122
134
  >
123
135
  <span
136
+ class="hide-row"
124
137
  style="cursor: pointer; line-height: 16px"
125
138
  data-id="hide-create-new-tag-row"
126
139
  @click.prevent.stop="onHideEditRow"
127
140
  >
128
- <ui-icon
129
- name="close"
130
- width="16"
131
- height="16"
132
- color="#4D5D69"
133
- />
141
+ <ui-icon name="close" width="16" height="16" />
134
142
  </span>
135
143
  <span
144
+ class="create-row"
136
145
  style="cursor: pointer; line-height: 16px"
137
146
  data-id="create-new-tag-accept"
138
147
  @click.prevent.stop="onAddTag"
139
148
  >
140
- <ui-icon
141
- name="status-check"
142
- width="16"
143
- height="16"
144
- color="#008FD6"
145
- />
149
+ <ui-icon name="status-check" width="16" height="16" />
146
150
  </span>
147
151
  </div>
148
152
  </template>
@@ -214,8 +218,8 @@ import type {
214
218
  import type { UI_I_ModalTexts } from '~/node_modules/bfg-uikit/components/ui/modal/models/interfaces'
215
219
  import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
216
220
  import type {
217
- I_NewTagData,
218
- I_CreateCategoryData,
221
+ UI_I_NewTagData,
222
+ UI_I_CreateCategoryData,
219
223
  } from '~/components/common/portlets/tag/lib/models/interfaces'
220
224
  import {
221
225
  tagTableHeaderOptions,
@@ -233,8 +237,6 @@ const onShowDetails = (_id: number): void => {
233
237
  navigateTo('/tags-attributes/tags')
234
238
  }
235
239
 
236
- const options: UI_I_DataTableOptions = tagTableHeaderOptions
237
-
238
240
  const assignTagTexts = computed<UI_I_ModalTexts>(() => ({
239
241
  button1: localization.value.common.cancel,
240
242
  button2: localization.value.common.assign,
@@ -285,7 +287,7 @@ const onAddNewRow = (): void => {
285
287
  assignDataLocal.value.body.push(makeNewTagCreateActionRowFunc(lastId + 1))
286
288
  }
287
289
 
288
- const editData = ref<I_NewTagData>({
290
+ const editData = ref<UI_I_NewTagData>({
289
291
  tagName: '',
290
292
  category: '',
291
293
  description: '',
@@ -398,7 +400,7 @@ const onHideCreateCategoryModal = (): void => {
398
400
  isShowCreateCategoryModal.value = false
399
401
  }
400
402
 
401
- const onCreateCategory = (data: I_CreateCategoryData): void => {
403
+ const onCreateCategory = (data: UI_I_CreateCategoryData): void => {
402
404
  selectItems.value.push({
403
405
  text: data.categoryName,
404
406
  value: data.categoryName.replaceAll(' ', ''),
@@ -416,6 +418,10 @@ const onCreateCategory = (data: I_CreateCategoryData): void => {
416
418
  --input-color: #4d5d69;
417
419
  --input-caret-color: #000000;
418
420
  --input-bg: #ffffff;
421
+ --hide-row-icon: #4d5d69;
422
+ --hide-row-icon-hover: #213444;
423
+ --create-row-icon: #008fd6;
424
+ --create-row-icon-hover: #0081c1;
419
425
  }
420
426
  :root.dark-theme {
421
427
  --separator-color: #e9ebed1f;
@@ -423,6 +429,10 @@ const onCreateCategory = (data: I_CreateCategoryData): void => {
423
429
  --input-color: #d3d6da;
424
430
  --input-caret-color: #ffffff;
425
431
  --input-bg: transparent;
432
+ --hide-row-icon: #e9eaec;
433
+ --hide-row-icon-hover: #ffffff;
434
+ --create-row-icon: #2ba2de;
435
+ --create-row-icon-hover: #008fd6;
426
436
  }
427
437
  </style>
428
438
 
@@ -446,12 +456,14 @@ const onCreateCategory = (data: I_CreateCategoryData): void => {
446
456
  font-weight: 400;
447
457
  line-height: 14.52px;
448
458
  color: #9da6ad;
459
+ padding: 4px 0;
449
460
  }
450
461
  .modal-top {
451
462
  display: flex;
452
463
  justify-content: space-between;
453
464
  align-items: center;
454
465
  margin-bottom: 12px;
466
+ padding-top: 8px;
455
467
 
456
468
  //&-manager-button {
457
469
  // display: flex;
@@ -575,4 +587,24 @@ const onCreateCategory = (data: I_CreateCategoryData): void => {
575
587
  border-bottom: 1px solid var(--separator-color);
576
588
  height: 0;
577
589
  }
590
+
591
+ .hide-row {
592
+ cursor: pointer;
593
+ line-height: 16px;
594
+ color: var(--hide-row-icon);
595
+
596
+ &:hover {
597
+ color: var(--hide-row-icon-hover);
598
+ }
599
+ }
600
+
601
+ .create-row {
602
+ cursor: pointer;
603
+ line-height: 16px;
604
+ color: var(--create-row-icon);
605
+
606
+ &:hover {
607
+ color: var(--create-row-icon-hover);
608
+ }
609
+ }
578
610
  </style>
@@ -5,9 +5,9 @@ import type {
5
5
  } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
6
6
  import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
7
7
  import type { UI_I_Localization } from '~/lib/models/interfaces'
8
- import type { I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
9
- import type { T_CreateCategoryTypes } from '~/components/common/portlets/tag/lib/models/types'
10
- export const createCategoryData: I_CreateCategoryData = {
8
+ import type { UI_I_CreateCategoryData } from '~/components/common/portlets/tag/lib/models/interfaces'
9
+ import type { UI_T_CreateCategoryTypes } from '~/components/common/portlets/tag/lib/models/types'
10
+ export const createCategoryData: UI_I_CreateCategoryData = {
11
11
  categoryName: '',
12
12
  description: '',
13
13
  tagsPerObject: '0',
@@ -29,7 +29,7 @@ export const createCategoryData: I_CreateCategoryData = {
29
29
  },
30
30
  }
31
31
 
32
- export const createCategoryTypes: Readonly<T_CreateCategoryTypes> = [
32
+ export const createCategoryTypes: Readonly<UI_T_CreateCategoryTypes> = [
33
33
  'folder',
34
34
  'datacenter',
35
35
  'datastoreCluster',
@@ -1,4 +1,4 @@
1
- export interface I_CreateCategoryData {
1
+ export interface UI_I_CreateCategoryData {
2
2
  categoryName: string
3
3
  description: string
4
4
  tagsPerObject: '0' | '1'
@@ -20,7 +20,7 @@ export interface I_CreateCategoryData {
20
20
  }
21
21
  }
22
22
 
23
- export interface I_NewTagData {
23
+ export interface UI_I_NewTagData {
24
24
  tagName: string
25
25
  category: string
26
26
  description: string
@@ -1,4 +1,4 @@
1
- export type T_CreateCategoryTypes = [
1
+ export type UI_T_CreateCategoryTypes = [
2
2
  'folder',
3
3
  'datacenter',
4
4
  'datastoreCluster',