bfg-common 1.5.812 → 1.5.813

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.
Files changed (105) hide show
  1. package/CODE_STYLE.md +109 -109
  2. package/assets/img/icons/icons-sprite-dark-3.svg +227 -227
  3. package/assets/img/icons/icons-sprite-dark-5.svg +488 -488
  4. package/assets/img/icons/icons-sprite-light-3.svg +227 -227
  5. package/assets/img/icons/icons-sprite-light-5.svg +488 -488
  6. package/components/atoms/TheIcon3.vue +50 -50
  7. package/components/atoms/collapse/CollapseNav.vue +170 -170
  8. package/components/atoms/perPage/PerPage.vue +58 -58
  9. package/components/atoms/table/dataGrid/DataGridPagination.vue +97 -97
  10. package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +94 -94
  11. package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -16
  12. package/components/common/backup/storage/actions/add/lib/utils.ts +51 -51
  13. package/components/common/browse/blocks/contents/filesNew/Skeleton.vue +18 -18
  14. package/components/common/configure/advancedSystemSettings/AdvancedSystemSettings.vue +47 -47
  15. package/components/common/configure/advancedSystemSettings/modals/edit/Edit.vue +78 -78
  16. package/components/common/configure/advancedSystemSettings/modals/edit/New.vue +56 -56
  17. package/components/common/configure/advancedSystemSettings/modals/edit/Old.vue +66 -66
  18. package/components/common/configure/advancedSystemSettings/tableView/TableView.vue +40 -40
  19. package/components/common/configure/advancedSystemSettings/tableView/old/Old.vue +122 -122
  20. package/components/common/configure/advancedSystemSettings/tableView/old/field/Field.vue +139 -139
  21. package/components/common/configure/advancedSystemSettings/tableView/old/field/lib/models/enums.ts +13 -13
  22. package/components/common/configure/advancedSystemSettings/tableView/old/lib/config/table.ts +131 -131
  23. package/components/common/diagramMain/modals/lib/config/vCenterModal.ts +48 -48
  24. package/components/common/diagramMain/port/Port.vue +580 -580
  25. package/components/common/layout/theHeader/userMenu/UserMenu.vue +116 -116
  26. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/models/types.ts +7 -7
  27. package/components/common/layout/topNotification/TopNotification.vue +37 -37
  28. package/components/common/layout/topNotification/lib/models/enums.ts +3 -3
  29. package/components/common/pages/backups/DetailView.vue +52 -52
  30. package/components/common/pages/backups/lib/models/interfaces.ts +36 -36
  31. package/components/common/pages/backups/modals/Modals.vue +243 -243
  32. package/components/common/pages/backups/modals/createBackup/configuration/maxBandwidth/lib/config/options.ts +6 -6
  33. package/components/common/pages/backups/modals/restore/disks/tableView/old/Table.vue +117 -117
  34. package/components/common/pages/backups/modals/restore/lib/config/readyToCompleteOptions.ts +96 -96
  35. package/components/common/pages/backups/modals/restore/lib/config/steps.ts +134 -134
  36. package/components/common/pages/backups/modals/restore/name/lib/models/interfaces.ts +6 -6
  37. package/components/common/pages/home/lib/models/interfaces.ts +48 -48
  38. package/components/common/pages/home/widgets/hosts/Hosts.vue +27 -27
  39. package/components/common/pages/home/widgets/hosts/lib/config/items.ts +23 -23
  40. package/components/common/pages/home/widgets/vms/VmsOld.vue +35 -35
  41. package/components/common/pages/home/widgets/vms/lib/config/items.ts +19 -19
  42. package/components/common/pages/scheduledTasks/lib/utils/utils.ts +84 -84
  43. package/components/common/readyToComplete/ReadyToComplete.vue +17 -17
  44. package/components/common/select/radio/RadioGroup.vue +137 -137
  45. package/components/common/spiceConsole/Drawer.vue +420 -420
  46. package/components/common/spiceConsole/SpiceConsole.vue +184 -184
  47. package/components/common/spiceConsole/lib/models/interfaces.ts +5 -5
  48. package/components/common/tools/Actions.vue +207 -207
  49. package/components/common/treeView/TreeView.vue +52 -52
  50. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/shares/lib/config/options.ts +28 -28
  51. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +283 -283
  52. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/New.vue +340 -340
  53. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +511 -502
  54. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/Old.vue +279 -279
  55. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/vmStoragePolicy/New.vue +53 -53
  56. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/vmStoragePolicy/Old.vue +45 -45
  57. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/vmStoragePolicy/VmStoragePolicy.vue +31 -31
  58. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/vmStoragePolicy/lib/config/options.ts +12 -12
  59. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/order/Order.vue +156 -156
  60. package/components/common/vm/actions/common/lib/models/interfaces.ts +192 -192
  61. package/components/common/vm/actions/common/select/compatibility/Old.vue +107 -107
  62. package/components/common/vm/actions/common/select/createType/lib/models/interfaces.ts +5 -5
  63. package/components/common/vm/actions/common/select/options/Options.vue +58 -58
  64. package/components/common/vm/actions/common/select/storage/Old.vue +125 -125
  65. package/components/common/vm/actions/common/select/storage/new/lib/models/interfaces.ts +5 -5
  66. package/components/common/vm/actions/common/select/storage/new/lib/utils/utils.ts +21 -21
  67. package/components/common/vm/actions/common/select/template/old/Old.vue +50 -50
  68. package/components/common/vm/actions/editSettings/new/Skeleton.vue +88 -88
  69. package/components/common/wizards/common/compatibility/Compatibility.vue +35 -35
  70. package/components/common/wizards/common/steps/name/Old.vue +121 -121
  71. package/components/common/wizards/common/steps/name/lib/models/interfaces.ts +4 -4
  72. package/components/common/wizards/common/steps/name/location/New.vue +40 -40
  73. package/components/common/wizards/datastore/add/steps/typeMode/lib/config/typeOptions.ts +43 -43
  74. package/components/common/wizards/network/add/steps/portProperties/PortProperties.vue +192 -192
  75. package/composables/useAppVersion.ts +21 -21
  76. package/composables/useLocal.ts +6 -6
  77. package/composables/useLocalCommon.ts +39 -39
  78. package/lib/config/regExp.ts +53 -53
  79. package/package.json +1 -1
  80. package/plugins/console.ts +21 -21
  81. package/plugins/helpers.ts +34 -34
  82. package/plugins/mouse.ts +21 -21
  83. package/plugins/panelStates.ts +70 -70
  84. package/plugins/text.ts +59 -59
  85. package/public/spice-console/application/clientgui.js +854 -854
  86. package/public/spice-console/application/packetfactory.js +211 -211
  87. package/public/spice-console/application/virtualmouse.js +147 -147
  88. package/public/spice-console/lib/images/bitmap.js +203 -203
  89. package/public/spice-console/network/spicechannel.js +440 -440
  90. package/public/spice-console/process/cursorprocess.js +128 -128
  91. package/public/spice-console/process/inputprocess.js +227 -227
  92. package/public/spice-console/process/mainprocess.js +212 -212
  93. package/public/spice-console/run.js +210 -210
  94. package/store/inventory/modules/configure/advancedSystemSettings/actions.ts +92 -92
  95. package/store/inventory/modules/configure/advancedSystemSettings/getters.ts +17 -17
  96. package/store/inventory/modules/configure/advancedSystemSettings/lib/models/interfaces.ts +45 -45
  97. package/store/inventory/modules/configure/advancedSystemSettings/lib/models/types.ts +30 -30
  98. package/store/inventory/modules/configure/advancedSystemSettings/mappers/mapSettings.ts +50 -50
  99. package/store/main/actions.ts +28 -28
  100. package/store/main/getters.ts +14 -14
  101. package/store/main/lib/interfaces.ts +18 -18
  102. package/store/main/mutations.ts +28 -28
  103. package/store/main/state.ts +9 -9
  104. package/store/tasks/mappers/recentTasks.ts +123 -123
  105. package/store/tasks/mutations.ts +82 -82
@@ -1,122 +1,122 @@
1
- <template>
2
- <div class="data-table-view">
3
- <atoms-table-data-grid
4
- v-model:column-keys="columnKeys"
5
- v-model:page-size="paginationLocal.pageSize"
6
- v-model:page="paginationLocal.page"
7
- :head-items="headItems"
8
- :body-items="bodyItems"
9
- :total-items="props.totalItems"
10
- :total-pages="props.totalPages"
11
- class="data-table"
12
- test-id="any-table"
13
- server-off
14
- >
15
- <template #value="{ item }">
16
- <common-configure-advanced-system-settings-table-view-old-field
17
- :data="item.data"
18
- @change="onChangeSetting($event, item.data.key)"
19
- @error-message="onUpdateInvalidFields($event, item.data.key)"
20
- />
21
- </template>
22
- </atoms-table-data-grid>
23
- </div>
24
- </template>
25
-
26
- <script lang="ts" setup>
27
- import type {
28
- UI_I_ColumnKey,
29
- UI_I_HeadItem,
30
- UI_I_BodyItem,
31
- } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
32
- import type {
33
- UI_I_ArbitraryObject,
34
- UI_I_Localization,
35
- } from '~/lib/models/interfaces'
36
- import type {
37
- API_UI_I_DataTable,
38
- UI_I_Pagination,
39
- } from '~/lib/models/table/interfaces'
40
- import type { UI_I_AdvancedSystemSetting } from '~/store/inventory/modules/configure/advancedSystemSettings/lib/models/interfaces'
41
- import type { UI_I_AdvancedSystemSettingsEditData } from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/models/interfaces'
42
- import * as table from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/config/table'
43
-
44
- const settings = defineModel<API_UI_I_DataTable<UI_I_AdvancedSystemSetting[]>>(
45
- 'settings',
46
- { required: true }
47
- )
48
- const invalidFields = defineModel<string[]>('invalid-fields', {
49
- required: false,
50
- })
51
-
52
- const props = defineProps<{
53
- dataTable: UI_I_AdvancedSystemSetting[]
54
- totalItems: number
55
- totalPages: number
56
- isEdit: boolean
57
- }>()
58
-
59
- const localization = computed<UI_I_Localization>(() => useLocal())
60
-
61
- const onChangeSetting = (
62
- value: UI_I_AdvancedSystemSettingsEditData['value'],
63
- key: string
64
- ): void => {
65
- settings.value.items = settings.value.items.map((item) => {
66
- if (item.key === key) {
67
- item.value = value
68
- }
69
- return item
70
- })
71
- }
72
-
73
- const invalidFieldsLocal = ref<UI_I_ArbitraryObject<string>>({})
74
- const onUpdateInvalidFields = (value: string, key: string): void => {
75
- invalidFieldsLocal.value[key] = value
76
- if (invalidFields.value)
77
- invalidFields.value = Object.values(invalidFieldsLocal.value).filter(
78
- (error) => error
79
- )
80
- }
81
-
82
- const paginationLocal = ref<UI_I_Pagination>({
83
- page: 1,
84
- pageSize: 100,
85
- })
86
-
87
- const headItems = computed<UI_I_HeadItem[]>(() =>
88
- table.headItems(localization.value, props.isEdit)
89
- )
90
-
91
- const columnKeys = computed<UI_I_ColumnKey[]>(() =>
92
- table.columnKeys(localization.value, props.isEdit)
93
- )
94
-
95
- const bodyItems = ref<UI_I_BodyItem[][]>([])
96
- watch(
97
- () => props.dataTable,
98
- (newValue) => {
99
- bodyItems.value = table.bodyItems(newValue, props.isEdit)
100
- },
101
- { deep: true, immediate: true }
102
- )
103
- </script>
104
-
105
- <style lang="scss" scoped>
106
- @import 'assets/scss/common/mixins.scss';
107
- .data-table-view {
108
- @include flex($dir: column);
109
- overflow: hidden;
110
- height: inherit;
111
- max-height: 250px;
112
- .data-table {
113
- @include flex($dir: column);
114
- flex-direction: column;
115
- overflow: hidden;
116
- height: inherit;
117
- :deep(.datagrid-outer-wrapper) {
118
- height: inherit;
119
- }
120
- }
121
- }
122
- </style>
1
+ <template>
2
+ <div class="data-table-view">
3
+ <atoms-table-data-grid
4
+ v-model:column-keys="columnKeys"
5
+ v-model:page-size="paginationLocal.pageSize"
6
+ v-model:page="paginationLocal.page"
7
+ :head-items="headItems"
8
+ :body-items="bodyItems"
9
+ :total-items="props.totalItems"
10
+ :total-pages="props.totalPages"
11
+ class="data-table"
12
+ test-id="any-table"
13
+ server-off
14
+ >
15
+ <template #value="{ item }">
16
+ <common-configure-advanced-system-settings-table-view-old-field
17
+ :data="item.data"
18
+ @change="onChangeSetting($event, item.data.key)"
19
+ @error-message="onUpdateInvalidFields($event, item.data.key)"
20
+ />
21
+ </template>
22
+ </atoms-table-data-grid>
23
+ </div>
24
+ </template>
25
+
26
+ <script lang="ts" setup>
27
+ import type {
28
+ UI_I_ColumnKey,
29
+ UI_I_HeadItem,
30
+ UI_I_BodyItem,
31
+ } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
32
+ import type {
33
+ UI_I_ArbitraryObject,
34
+ UI_I_Localization,
35
+ } from '~/lib/models/interfaces'
36
+ import type {
37
+ API_UI_I_DataTable,
38
+ UI_I_Pagination,
39
+ } from '~/lib/models/table/interfaces'
40
+ import type { UI_I_AdvancedSystemSetting } from '~/store/inventory/modules/configure/advancedSystemSettings/lib/models/interfaces'
41
+ import type { UI_I_AdvancedSystemSettingsEditData } from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/models/interfaces'
42
+ import * as table from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/config/table'
43
+
44
+ const settings = defineModel<API_UI_I_DataTable<UI_I_AdvancedSystemSetting[]>>(
45
+ 'settings',
46
+ { required: true }
47
+ )
48
+ const invalidFields = defineModel<string[]>('invalid-fields', {
49
+ required: false,
50
+ })
51
+
52
+ const props = defineProps<{
53
+ dataTable: UI_I_AdvancedSystemSetting[]
54
+ totalItems: number
55
+ totalPages: number
56
+ isEdit: boolean
57
+ }>()
58
+
59
+ const localization = computed<UI_I_Localization>(() => useLocal())
60
+
61
+ const onChangeSetting = (
62
+ value: UI_I_AdvancedSystemSettingsEditData['value'],
63
+ key: string
64
+ ): void => {
65
+ settings.value.items = settings.value.items.map((item) => {
66
+ if (item.key === key) {
67
+ item.value = value
68
+ }
69
+ return item
70
+ })
71
+ }
72
+
73
+ const invalidFieldsLocal = ref<UI_I_ArbitraryObject<string>>({})
74
+ const onUpdateInvalidFields = (value: string, key: string): void => {
75
+ invalidFieldsLocal.value[key] = value
76
+ if (invalidFields.value)
77
+ invalidFields.value = Object.values(invalidFieldsLocal.value).filter(
78
+ (error) => error
79
+ )
80
+ }
81
+
82
+ const paginationLocal = ref<UI_I_Pagination>({
83
+ page: 1,
84
+ pageSize: 100,
85
+ })
86
+
87
+ const headItems = computed<UI_I_HeadItem[]>(() =>
88
+ table.headItems(localization.value, props.isEdit)
89
+ )
90
+
91
+ const columnKeys = computed<UI_I_ColumnKey[]>(() =>
92
+ table.columnKeys(localization.value, props.isEdit)
93
+ )
94
+
95
+ const bodyItems = ref<UI_I_BodyItem[][]>([])
96
+ watch(
97
+ () => props.dataTable,
98
+ (newValue) => {
99
+ bodyItems.value = table.bodyItems(newValue, props.isEdit)
100
+ },
101
+ { deep: true, immediate: true }
102
+ )
103
+ </script>
104
+
105
+ <style lang="scss" scoped>
106
+ @import 'assets/scss/common/mixins.scss';
107
+ .data-table-view {
108
+ @include flex($dir: column);
109
+ overflow: hidden;
110
+ height: inherit;
111
+ max-height: 250px;
112
+ .data-table {
113
+ @include flex($dir: column);
114
+ flex-direction: column;
115
+ overflow: hidden;
116
+ height: inherit;
117
+ :deep(.datagrid-outer-wrapper) {
118
+ height: inherit;
119
+ }
120
+ }
121
+ }
122
+ </style>
@@ -1,139 +1,139 @@
1
- <template>
2
- <atoms-tooltip-error :has-error="invalid">
3
- <template #elem>
4
- <div v-if="props.data.type === 'number'">
5
- <input
6
- v-model="valueLocal"
7
- type="number"
8
- :class="{ 'has-error': invalid }"
9
- @input="onChangeSetting($event)"
10
- />
11
- </div>
12
- <div v-if="props.data.type === 'string'">
13
- <input
14
- v-model="valueLocal"
15
- type="text"
16
- :class="{ 'has-error': invalid }"
17
- @input="onChangeSetting($event)"
18
- />
19
- </div>
20
- <div v-if="props.data.type === 'boolean'" class="select">
21
- <select
22
- v-model="valueLocal"
23
- @change="onChangeSetting($event)"
24
- :class="{ 'has-error': invalid }"
25
- >
26
- <option value="false">false</option>
27
- <option value="true">true</option>
28
- </select>
29
- </div>
30
- <!-- <div v-if="props.data.type === 'select'" class="select">-->
31
- <!-- <select-->
32
- <!-- v-model="valueLocal"-->
33
- <!-- @change="onChangeSetting($event)"-->
34
- <!-- :class="{ 'has-error': invalid }"-->
35
- <!-- >-->
36
- <!-- <option-->
37
- <!-- v-for="item2 in props.data.options"-->
38
- <!-- :key="item2.key"-->
39
- <!-- :value="item2.key"-->
40
- <!-- >-->
41
- <!-- {{ item2.value }}-->
42
- <!-- </option>-->
43
- <!-- </select>-->
44
- <!-- </div>-->
45
- </template>
46
- <template #content>
47
- {{ errorMessage }}
48
- </template>
49
- </atoms-tooltip-error>
50
- </template>
51
-
52
- <script setup lang="ts">
53
- import type { UI_I_AdvancedSystemSettingsEditData } from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/models/interfaces'
54
- import { E_Format } from '~/components/common/configure/advancedSystemSettings/tableView/old/field/lib/models/enums'
55
- import { allRegExp } from '~/lib/config/regExp'
56
-
57
- const props = defineProps<{
58
- data: UI_I_AdvancedSystemSettingsEditData
59
- }>()
60
- const emits = defineEmits<{
61
- (event: 'change', value: UI_I_AdvancedSystemSettingsEditData['value']): void
62
- (event: 'error-message', value: string): void
63
- }>()
64
-
65
- const valueLocal = ref<UI_I_AdvancedSystemSettingsEditData['value']>(
66
- props.data.value
67
- )
68
- watch(valueLocal, (newValue, oldValue) => {
69
- // Обработка для firefox
70
- if (props.data.type === 'number' && typeof newValue === 'string') {
71
- valueLocal.value = oldValue
72
- }
73
- })
74
-
75
- const invalid = ref<boolean>(false)
76
- const errorMessage = ref<string>('')
77
-
78
- const onChangeSetting = (event: Event): void => {
79
- invalid.value = false
80
- errorMessage.value = ''
81
-
82
- const target = event.target as HTMLInputElement
83
- let value: UI_I_AdvancedSystemSettingsEditData['value'] = target.value
84
- if (props.data.type === 'boolean') value = value === 'true'
85
- if (props.data.type === 'number') value = +value
86
-
87
- const { validation } = props.data
88
- if (Object.hasOwn(validation, 'equal')) {
89
- invalid.value = !validation.equal.includes(value)
90
- errorMessage.value = invalid.value
91
- ? `Value must be equal ${validation.equal.join(', ')}`
92
- : ''
93
- }
94
- if (invalid.value) return
95
-
96
- if (Object.hasOwn(validation, 'notEqual')) {
97
- invalid.value = validation.notEqual.includes(value)
98
- errorMessage.value = invalid.value
99
- ? `Value must not be equal ${validation.notEqual.join(', ')}`
100
- : ''
101
- }
102
- if (invalid.value) return
103
-
104
- if (Object.hasOwn(validation, 'min')) {
105
- invalid.value = value < validation.min
106
- errorMessage.value = invalid.value
107
- ? `Value must be more then ${validation.min}`
108
- : ''
109
- }
110
- if (invalid.value) return
111
-
112
- if (Object.hasOwn(validation, 'max')) {
113
- invalid.value = value > validation.max
114
- errorMessage.value = invalid.value
115
- ? `Value must be less then ${validation.max}`
116
- : ''
117
- }
118
- if (invalid.value) return
119
-
120
- if (validation.Format) {
121
- const format = E_Format[validation.Format]
122
- invalid.value = !allRegExp[format].test(value)
123
- errorMessage.value = invalid.value ? `Value must be ${format}` : ''
124
- }
125
- if (invalid.value) return
126
-
127
- emits('change', value)
128
- }
129
-
130
- watch(errorMessage, (newValue) => {
131
- emits('error-message', newValue)
132
- })
133
- </script>
134
-
135
- <style scoped lang="scss">
136
- .has-error {
137
- border: 1px solid #db2100;
138
- }
139
- </style>
1
+ <template>
2
+ <atoms-tooltip-error :has-error="invalid">
3
+ <template #elem>
4
+ <div v-if="props.data.type === 'number'">
5
+ <input
6
+ v-model="valueLocal"
7
+ type="number"
8
+ :class="{ 'has-error': invalid }"
9
+ @input="onChangeSetting($event)"
10
+ />
11
+ </div>
12
+ <div v-if="props.data.type === 'string'">
13
+ <input
14
+ v-model="valueLocal"
15
+ type="text"
16
+ :class="{ 'has-error': invalid }"
17
+ @input="onChangeSetting($event)"
18
+ />
19
+ </div>
20
+ <div v-if="props.data.type === 'boolean'" class="select">
21
+ <select
22
+ v-model="valueLocal"
23
+ @change="onChangeSetting($event)"
24
+ :class="{ 'has-error': invalid }"
25
+ >
26
+ <option value="false">false</option>
27
+ <option value="true">true</option>
28
+ </select>
29
+ </div>
30
+ <!-- <div v-if="props.data.type === 'select'" class="select">-->
31
+ <!-- <select-->
32
+ <!-- v-model="valueLocal"-->
33
+ <!-- @change="onChangeSetting($event)"-->
34
+ <!-- :class="{ 'has-error': invalid }"-->
35
+ <!-- >-->
36
+ <!-- <option-->
37
+ <!-- v-for="item2 in props.data.options"-->
38
+ <!-- :key="item2.key"-->
39
+ <!-- :value="item2.key"-->
40
+ <!-- >-->
41
+ <!-- {{ item2.value }}-->
42
+ <!-- </option>-->
43
+ <!-- </select>-->
44
+ <!-- </div>-->
45
+ </template>
46
+ <template #content>
47
+ {{ errorMessage }}
48
+ </template>
49
+ </atoms-tooltip-error>
50
+ </template>
51
+
52
+ <script setup lang="ts">
53
+ import type { UI_I_AdvancedSystemSettingsEditData } from '~/components/common/configure/advancedSystemSettings/tableView/old/lib/models/interfaces'
54
+ import { E_Format } from '~/components/common/configure/advancedSystemSettings/tableView/old/field/lib/models/enums'
55
+ import { allRegExp } from '~/lib/config/regExp'
56
+
57
+ const props = defineProps<{
58
+ data: UI_I_AdvancedSystemSettingsEditData
59
+ }>()
60
+ const emits = defineEmits<{
61
+ (event: 'change', value: UI_I_AdvancedSystemSettingsEditData['value']): void
62
+ (event: 'error-message', value: string): void
63
+ }>()
64
+
65
+ const valueLocal = ref<UI_I_AdvancedSystemSettingsEditData['value']>(
66
+ props.data.value
67
+ )
68
+ watch(valueLocal, (newValue, oldValue) => {
69
+ // Обработка для firefox
70
+ if (props.data.type === 'number' && typeof newValue === 'string') {
71
+ valueLocal.value = oldValue
72
+ }
73
+ })
74
+
75
+ const invalid = ref<boolean>(false)
76
+ const errorMessage = ref<string>('')
77
+
78
+ const onChangeSetting = (event: Event): void => {
79
+ invalid.value = false
80
+ errorMessage.value = ''
81
+
82
+ const target = event.target as HTMLInputElement
83
+ let value: UI_I_AdvancedSystemSettingsEditData['value'] = target.value
84
+ if (props.data.type === 'boolean') value = value === 'true'
85
+ if (props.data.type === 'number') value = +value
86
+
87
+ const { validation } = props.data
88
+ if (Object.hasOwn(validation, 'equal')) {
89
+ invalid.value = !validation.equal.includes(value)
90
+ errorMessage.value = invalid.value
91
+ ? `Value must be equal ${validation.equal.join(', ')}`
92
+ : ''
93
+ }
94
+ if (invalid.value) return
95
+
96
+ if (Object.hasOwn(validation, 'notEqual')) {
97
+ invalid.value = validation.notEqual.includes(value)
98
+ errorMessage.value = invalid.value
99
+ ? `Value must not be equal ${validation.notEqual.join(', ')}`
100
+ : ''
101
+ }
102
+ if (invalid.value) return
103
+
104
+ if (Object.hasOwn(validation, 'min')) {
105
+ invalid.value = value < validation.min
106
+ errorMessage.value = invalid.value
107
+ ? `Value must be more then ${validation.min}`
108
+ : ''
109
+ }
110
+ if (invalid.value) return
111
+
112
+ if (Object.hasOwn(validation, 'max')) {
113
+ invalid.value = value > validation.max
114
+ errorMessage.value = invalid.value
115
+ ? `Value must be less then ${validation.max}`
116
+ : ''
117
+ }
118
+ if (invalid.value) return
119
+
120
+ if (validation.Format) {
121
+ const format = E_Format[validation.Format]
122
+ invalid.value = !allRegExp[format].test(value)
123
+ errorMessage.value = invalid.value ? `Value must be ${format}` : ''
124
+ }
125
+ if (invalid.value) return
126
+
127
+ emits('change', value)
128
+ }
129
+
130
+ watch(errorMessage, (newValue) => {
131
+ emits('error-message', newValue)
132
+ })
133
+ </script>
134
+
135
+ <style scoped lang="scss">
136
+ .has-error {
137
+ border: 1px solid #db2100;
138
+ }
139
+ </style>
@@ -1,14 +1,14 @@
1
- export enum E_Format {
2
- 'unix path' = 'unixPath',
3
- 'win path' = 'winPath',
4
- 'mac' = 'mac',
5
- 'ip4' = 'ip4',
6
- 'ip6' = 'ip6',
7
- 'url' = 'url',
8
- 'uuid' = 'uuid',
9
- 'semver' = 'semver',
10
- 'domain' = 'domain',
11
- 'base64' = 'base64',
12
- 'regex' = 'regex',
13
- 'hex color' = 'hexColor',
1
+ export enum E_Format {
2
+ 'unix path' = 'unixPath',
3
+ 'win path' = 'winPath',
4
+ 'mac' = 'mac',
5
+ 'ip4' = 'ip4',
6
+ 'ip6' = 'ip6',
7
+ 'url' = 'url',
8
+ 'uuid' = 'uuid',
9
+ 'semver' = 'semver',
10
+ 'domain' = 'domain',
11
+ 'base64' = 'base64',
12
+ 'regex' = 'regex',
13
+ 'hex color' = 'hexColor',
14
14
  }