bfg-common 1.3.455 → 1.3.456

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.
@@ -55,11 +55,8 @@
55
55
  :datastore-type="datastoreType"
56
56
  :alert-messages="alertMessages[selectedStep.id]"
57
57
  :messages-fields="selectedStep.fields"
58
- :nfs-configuration-submit="nfsConfigurationSubmit"
59
58
  :host-accessibility-submit="hostAccessibilitySubmit"
60
59
  :hosts="props.nfsHosts"
61
- @loading="(e) => (loading = e)"
62
- @change-nfs-version="updateNfsVersion"
63
60
  @submit="saveChangesAndNextNfs"
64
61
  />
65
62
 
@@ -136,7 +133,6 @@ const datastoreType = ref<UI_T_DatastoreType>(
136
133
  // const nfsVersion = ref<UI_T_NfsType>('nfs-3')
137
134
  // const dataReadyView = ref<any>([])
138
135
 
139
-
140
136
  const form = ref<any>({
141
137
  name: '',
142
138
  lunDisk: [],
@@ -221,7 +217,7 @@ const checkNameAsync = async (
221
217
  }
222
218
  }
223
219
 
224
- const checkNetwork2 = async (
220
+ const checkNameAndDevice = async (
225
221
  form: any,
226
222
  localization: UI_I_Localization,
227
223
  wizard: Wizard
@@ -245,7 +241,7 @@ const checkNetwork2 = async (
245
241
  }
246
242
  }
247
243
  }
248
- const checkName2Async = async (
244
+ const checkNameAndDeviceAsync = async (
249
245
  localization: UI_I_Localization,
250
246
  value: UI_I_WizardStep[],
251
247
  form: any,
@@ -256,7 +252,7 @@ const checkName2Async = async (
256
252
  const labelValidation: {
257
253
  isValid: boolean
258
254
  message: string
259
- } = await checkNetwork2(form, localization, wizard)
255
+ } = await checkNameAndDevice(form, localization, wizard)
260
256
 
261
257
  if (!labelValidation.isValid) {
262
258
  stepHasError = wizard.setValidation(2, 'datastoreName', {
@@ -273,6 +269,58 @@ const checkName2Async = async (
273
269
  }
274
270
  }
275
271
 
272
+ const checkNameAndConfiguration = async (
273
+ form: any,
274
+ localization: UI_I_Localization,
275
+ wizard: Wizard
276
+ // emits: UI_I_AddNetworkingEmits
277
+ ): Promise<UI_I_AsyncCheckReturn> => {
278
+ if (form.name && form.folder && form.server) {
279
+ return new Promise((resolve, _reject) =>
280
+ checkValidityName(form.name, wizard, (message: string) => {
281
+ resolve({
282
+ isValid: message === '',
283
+ message: message === '' ? '' : message,
284
+ })
285
+ })
286
+ )
287
+ } else {
288
+ return {
289
+ isValid: false,
290
+ message: !form.name
291
+ ? localization.specifyDatastoreName
292
+ : localization.selectHostToContinueAlert,
293
+ }
294
+ }
295
+ }
296
+ const checkNameAndNfsConfigurationAsync = async (
297
+ localization: UI_I_Localization,
298
+ value: UI_I_WizardStep[],
299
+ form: any,
300
+ wizard: Wizard
301
+ ): Promise<UI_I_ValidationReturn> => {
302
+ let stepHasError = false
303
+
304
+ const labelValidation: {
305
+ isValid: boolean
306
+ message: string
307
+ } = await checkNameAndConfiguration(form, localization, wizard)
308
+
309
+ if (!labelValidation.isValid) {
310
+ stepHasError = wizard.setValidation(5, 'name', {
311
+ fieldMessage: labelValidation.message,
312
+ alertMessage: form.name ? labelValidation.message : '',
313
+ })
314
+ } else if (wizard.hasMessage(5, 'name')) {
315
+ value = wizard.removeValidation(5, 'name', value)
316
+ }
317
+
318
+ return {
319
+ newValue: value,
320
+ stepHasError,
321
+ }
322
+ }
323
+
276
324
  const validationFunc = async (
277
325
  value: UI_I_WizardStep[],
278
326
  currentStep: UI_I_WizardStep,
@@ -294,7 +342,20 @@ const validationFunc = async (
294
342
  }
295
343
 
296
344
  if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
297
- const nameValidation = await checkName2Async(
345
+ const nameValidation = await checkNameAndDeviceAsync(
346
+ localization.value,
347
+ value,
348
+ form.value,
349
+ wizard
350
+ )
351
+
352
+ value = nameValidation.newValue
353
+
354
+ stepHasError = nameValidation.stepHasError
355
+ }
356
+
357
+ if (wizard.isValidateForStep(5, currentStep.id, nextStep.id)) {
358
+ const nameValidation = await checkNameAndNfsConfigurationAsync(
298
359
  localization.value,
299
360
  value,
300
361
  form.value,
@@ -343,50 +404,8 @@ const dataReadyView = computed<UI_I_DetailsItem>(() =>
343
404
  form.value
344
405
  )
345
406
  )
407
+ const onNextStep = (_force = false): void => {}
346
408
 
347
- // let cashStep = -1
348
- const onNextStep = (_force = false): void => {
349
- // const isValid = checkSubmit(force)
350
- //
351
- // if (!isValid) {
352
- // return
353
- // }
354
- //
355
- // const isDisabled = stepItems.value[cashStep]?.disabled
356
- // if (cashStep !== -1 && !isDisabled) {
357
- // stepPosition.value = cashStep
358
- // cashStep = -1
359
- // return
360
- // }
361
- //
362
- // stepItems.value[stepPosition.value].complete = true
363
- // stepItems.value[stepPosition.value + 1].disabled = false
364
- // stepPosition.value++
365
- }
366
-
367
- // const onChangeStep = (key: number): void => {
368
- // if (key < stepPosition.value) {
369
- // stepPosition.value = key
370
- // return
371
- // }
372
- //
373
- // const isValid = checkSubmit()
374
- //
375
- // if (!isValid) {
376
- // cashStep = key
377
- // return
378
- // }
379
- //
380
- // stepPosition.value = key
381
- // }
382
-
383
- const updateNfsVersion = (event: UI_T_NfsType): void => {
384
- // nfsVersion.value = event
385
- const { name, server, folder, hosts } = datastoreForm.value.nfs
386
- saveChangesAndNextNfs({ name, server, folder, hosts }, false)
387
- }
388
-
389
- const nfsConfigurationSubmit = ref<number>(0)
390
409
  const hostAccessibilitySubmit = ref<number>(0)
391
410
 
392
411
  const isWizardModeForSphere = computed<boolean>(
@@ -10,9 +10,7 @@
10
10
  v-model="model"
11
11
  :project="props.project"
12
12
  :alert-messages="props.alertMessages"
13
- :messages-fields="props.selectedStep"
14
- :nfs-configuration-submit="nfsConfigurationSubmit"
15
- @loading="(e) => emits('loading', e)"
13
+ :messages-fields="props.messagesFields"
16
14
  @next="onChangeConfigurationAndNext"
17
15
  />
18
16
 
@@ -46,13 +44,11 @@ const props = defineProps<{
46
44
  datastoreType: UI_T_DatastoreType
47
45
  alertMessages: string[]
48
46
  messagesFields: UI_I_ArbitraryObject<UI_I_ErrorFields>
49
- nfsConfigurationSubmit: number
50
47
  hostAccessibilitySubmit: number
51
48
  hosts?: any
52
49
  }>()
53
50
  const model = defineModel<any>()
54
51
  const emits = defineEmits<{
55
- (event: 'loading', value: boolean): void
56
52
  (event: 'submit', value: UI_I_ConfigurationSendDataNfs): void
57
53
  }>()
58
54
 
@@ -2,11 +2,11 @@
2
2
  <div class="configuration">
3
3
  <div>
4
4
  <atoms-alert
5
- v-show="errors.length"
5
+ v-show="props.alertMessages?.length"
6
6
  test-id="configuration-error"
7
7
  status="alert-danger"
8
- :items="errors"
9
- @remove="onCloseAlertDanger"
8
+ :items="props.alertMessages"
9
+ @remove="onHideAlert"
10
10
  />
11
11
 
12
12
  <atoms-alert
@@ -124,9 +124,9 @@
124
124
  </div>
125
125
 
126
126
  <div v-if="false" class="clr-form-control clr-row mt-1">
127
- <label for="" class="clr-control-label clr-col-md-2">{{
128
- localization.accessMode
129
- }}</label>
127
+ <label for="" class="clr-control-label clr-col-md-2">
128
+ {{ localization.accessMode }}
129
+ </label>
130
130
 
131
131
  <div class="clr-col-md-10 clr-col-12 clr-checkbox-wrapper">
132
132
  <input
@@ -145,54 +145,26 @@
145
145
 
146
146
  <script lang="ts" setup>
147
147
  import type { UI_T_Project } from '~/lib/models/types'
148
- import { UI_I_ValidationTouchResult } from '~/lib/models/plugins/validation/interfaces'
149
148
  import type {
150
149
  UI_I_Localization,
151
150
  UI_I_ArbitraryObject,
152
151
  } from '~/lib/models/interfaces'
153
152
  import type { UI_I_ErrorFields } from '~/components/atoms/wizard/lib/models/interfaces'
154
- import {
155
- UI_I_DataServersListItem,
156
- UI_I_FormValidationConfiguration,
157
- } from '~/components/common/wizards/datastore/add/nfs/configuration/serversList/lib/models/interfaces'
158
- import {
159
- UI_I_ConfigurationSendDataNfs,
160
- UI_I_InitialValidationFields,
161
- } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/lib/models/interfaces'
162
- import { defaultFormFunc } from '~/components/common/wizards/datastore/add/nfs/configuration/lib/config/defaultForm'
163
- import { checkValidityName } from '~/components/common/wizards/datastore/add/lib/utils'
153
+ import type { UI_I_DataServersListItem } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/serversList/lib/models/interfaces'
154
+ import type { UI_I_InitialValidationFields } from '~/components/common/wizards/datastoreNew/add/nfs/configuration/lib/models/interfaces'
164
155
 
165
156
  const props = defineProps<{
166
157
  project: UI_T_Project
167
158
  alertMessages: string[]
168
159
  messagesFields: UI_I_ArbitraryObject<UI_I_ErrorFields>
169
- nfsConfigurationSubmit: number
170
160
  }>()
171
161
  const model = defineModel<any>()
172
162
  const emits = defineEmits<{
173
- (event: 'loading', value: boolean): void
174
- (event: 'next', value: UI_I_ConfigurationSendDataNfs): void
163
+ (event: 'hide-alert', value: number): void
175
164
  }>()
176
165
 
177
166
  const localization = computed<UI_I_Localization>(() => useLocal())
178
- const { $validation } = useNuxtApp()
179
167
 
180
- const validation = $validation.call({})
181
- const defaultForm: UI_I_FormValidationConfiguration = defaultFormFunc(
182
- localization.value
183
- )
184
- const form = ref<UI_I_FormValidationConfiguration>(useDeepCopy(defaultForm))
185
- const setForm = () => {
186
- form.value = useDeepCopy(defaultForm)
187
- validation.setForm(form)
188
- }
189
- setForm()
190
-
191
- const validForm = ref<UI_I_ValidationTouchResult | null>(null)
192
-
193
- const isInitNameValidation = ref<boolean>(false) // Удалить
194
- const isInitFolderValidation = ref<boolean>(false) // Удалить
195
- const isInitServerValidation = ref<boolean>(false) // Удалить
196
168
  const initValidationFields = ref<UI_I_InitialValidationFields>({
197
169
  name: false,
198
170
  folder: false,
@@ -219,7 +191,7 @@ const folderErrorText = computed<string>(() => {
219
191
  }
220
192
 
221
193
  if (!initValidationFields.value.folder) return ''
222
- return !model.value.folder ? localization.value.specifyDatastoreName : ''
194
+ return !model.value.folder ? localization.value.specifyFolderName : ''
223
195
  })
224
196
 
225
197
  /* Validation error text for Server input field */
@@ -230,11 +202,10 @@ const serverErrorText = computed<string>(() => {
230
202
 
231
203
  // if (!initValidationFields.value.server || dataServers.value.length) return ''
232
204
  if (!initValidationFields.value.server) return ''
233
- return !model.value.server ? localization.value.specifyDatastoreName : ''
205
+ return !model.value.server ? localization.value.specifyServerName : ''
234
206
  })
235
207
 
236
208
  const accessMode = ref<boolean>(false)
237
-
238
209
  const dataServers = ref<UI_I_DataServersListItem[]>([])
239
210
  // const onAddServerToList = (): void => {
240
211
  // const { server } = form.value
@@ -261,72 +232,10 @@ const dataServers = ref<UI_I_DataServersListItem[]>([])
261
232
  //
262
233
  // // if (nfsVersion === 'nfs-4.1') server.value = ''
263
234
  // }
264
-
265
- const alertInfo = ref<boolean>(props.project === 'procurator')
266
-
267
- const resetValidation = (): void => {
268
- isInitNameValidation.value =
269
- isInitFolderValidation.value =
270
- isInitServerValidation.value =
271
- false
272
- validForm.value = null
273
- errors.value = []
274
- }
275
-
276
- watch(
277
- () => props.nfsConfigurationSubmit,
278
- () => {
279
- submit()
280
- }
281
- )
282
- const submit = async (): Promise<void> => {
283
- const { name, server, folder } = form.value
284
-
285
- validForm.value = validation.touch()
286
- isInitNameValidation.value =
287
- isInitFolderValidation.value =
288
- isInitServerValidation.value =
289
- true
290
-
291
- if (nameErrorText.value || folderErrorText.value || serverErrorText.value) {
292
- return
293
- }
294
-
295
- emits('loading', true)
296
-
297
- const { valid, msg } = await checkValidityName(name.value, props.project)
298
-
299
- emits('loading', false)
300
-
301
- if (!valid) {
302
- showValidationErrors(msg)
303
- return
304
- }
305
-
306
- // if (server.value) onAddServerToList()
307
-
308
- resetValidation()
309
-
310
- const configurationData: UI_I_ConfigurationSendDataNfs = {
311
- name: name.value,
312
- folder: folder.value,
313
- server: server.value,
314
- }
315
-
316
- emits('next', configurationData)
317
- // if (props.nfsVersion !== 'nfs-4.1') {
318
- // dataServers.value = []
319
- // }
320
- }
321
-
322
- const errors = ref<string[]>([])
323
-
324
- const showValidationErrors = (errorText: string): void => {
325
- errors.value = [errorText]
326
- }
327
- const onCloseAlertDanger = (): void => {
328
- errors.value = []
235
+ const onHideAlert = (): void => {
236
+ emits('hide-alert', 5)
329
237
  }
238
+ const alertInfo = ref<boolean>(props.project === 'procurator')
330
239
  </script>
331
240
 
332
241
  <style lang="scss" scoped>
@@ -1,11 +1,3 @@
1
- import { UI_I_Validation } from '~/lib/models/plugins/validation/interfaces'
2
-
3
- export interface UI_I_FormValidationConfiguration {
4
- name: UI_I_Validation
5
- folder: UI_I_Validation
6
- server: UI_I_Validation
7
- }
8
-
9
1
  export interface UI_I_DataServersListItem {
10
2
  server_name: string
11
3
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.455",
4
+ "version": "1.3.456",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,33 +0,0 @@
1
- import { UI_I_Localization } from '~/lib/models/interfaces'
2
-
3
- export const defaultFormFunc = (localization: UI_I_Localization): any => {
4
- return {
5
- name: {
6
- value: 'Datastore',
7
- validations: [
8
- {
9
- value: 'required',
10
- errorText: localization.specifyDatastoreName,
11
- },
12
- ],
13
- },
14
- folder: {
15
- value: '',
16
- validations: [
17
- {
18
- value: 'required',
19
- errorText: localization.specifyFolderName,
20
- },
21
- ],
22
- },
23
- server: {
24
- value: '',
25
- validations: [
26
- {
27
- value: 'required',
28
- errorText: localization.specifyServerName,
29
- },
30
- ],
31
- },
32
- }
33
- }