bfg-common 1.5.896 → 1.5.898

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,9 +1,30 @@
1
1
  <template>
2
2
  <form class="form" @submit.prevent>
3
3
  <section>
4
- <div class="form__target">
5
- {{ localization.common.target }}
4
+ <div class="flex justify-between column-gap-4 form__target">
5
+ <div class="flex items-center column-gap-2 text-ellipsis">
6
+ <p class="text">{{ localization.common.target }}:</p>
7
+ <span class="icon vsphere-icon-vm"></span>
8
+ <span class="text">{{ props.target }}</span>
9
+ </div>
10
+ <div class="flex items-center column-gap-3">
11
+ <p class="text">{{ localization.common.active }}</p>
12
+ <ui-switch
13
+ v-model="model.toggle"
14
+ test-id="scheduled-task-active-switch-input"
15
+ />
16
+ </div>
6
17
  </div>
18
+
19
+ <ui-input
20
+ id="schedule-task-name-field"
21
+ v-model="model.task_name"
22
+ :label="localization.common.taskName"
23
+ :error="props.taskNameErrorText"
24
+ test-id="schedule-task-name-field"
25
+ class="form__user-name"
26
+ @input="onInitValidation(['taskName'])"
27
+ />
7
28
  </section>
8
29
  </form>
9
30
  </template>
@@ -12,31 +33,26 @@
12
33
  import type { UI_I_Localization } from '~/lib/models/interfaces'
13
34
  import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
14
35
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
15
- import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
36
+ import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/models/interfaces'
16
37
  import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
17
- import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
38
+ import * as cron from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/utils'
18
39
  import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
19
40
 
41
+ const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
20
42
  const props = defineProps<{
21
43
  target: string
44
+ formValidationFields: UI_I_InitialValidationFields
45
+ taskNameErrorText: string
46
+ }>()
47
+ const emits = defineEmits<{
48
+ (event: 'init-validation', value: string[]): void
22
49
  }>()
23
- const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
24
50
 
25
51
  const localization = computed<UI_I_Localization>(() => useLocal())
26
52
 
27
- const initValidationFields = ref<UI_I_InitialValidationFields>({
28
- taskName: false,
29
- })
30
53
  const onInitValidation = (types: string[]): void => {
31
- types.forEach((type) => (initValidationFields.value[type] = true))
54
+ emits('init-validation', types)
32
55
  }
33
- const userNameErrorText = computed<string>(() => {
34
- if (!initValidationFields.value.taskName) return ''
35
-
36
- model.value.task_name = model.value.task_name.replace(/^\s+/, '')
37
-
38
- return !model.value.task_name ? localization.value.common.fieldRequired : ''
39
- })
40
56
 
41
57
  const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
42
58
  frequencyMethodFunc(localization.value)
@@ -95,31 +111,29 @@ const generateCronExpression = (
95
111
  background-color: var(--info-block-bg);
96
112
  border-radius: 8px;
97
113
  padding: 12px;
98
- & > p {
114
+ .text {
99
115
  font-family: 'Inter', sans-serif;
100
- color: #9da6ad; // for light and dark theme
101
- font-weight: 400;
102
116
  font-size: 13px;
103
- line-height: 18px;
104
- margin-bottom: 8px;
117
+ font-weight: 400;
118
+ color: var(--title-form-first-color);
119
+ }
120
+ /* Target */
121
+ > div:first-child p.text {
122
+ color: #9da6ad; // for dark and light theme
105
123
  }
124
+ /* Active */
125
+ > div:last-child p.text {
126
+ text-transform: Capitalize;
127
+ }
128
+
129
+ span.text {
130
+ color: var(--title-color);
131
+ }
132
+
106
133
  .icon {
107
134
  min-width: 20px;
108
135
  width: 20px;
109
136
  height: 20px;
110
- margin-right: 6px;
111
- }
112
- .text {
113
- font-family: 'Inter', sans-serif;
114
- color: var(--title-form-first-color);
115
- font-weight: 400;
116
- font-size: 13px;
117
- line-height: 18px;
118
- word-break: break-word;
119
-
120
- .highlight {
121
- color: var(--text-red);
122
- }
123
137
  }
124
138
  }
125
139
  }
@@ -9,7 +9,7 @@
9
9
  <label
10
10
  :class="[
11
11
  'clr-control-container tooltip tooltip-validation tooltip-xs tooltip-bottom-left clr-col-md-8',
12
- userNameErrorText && 'invalid',
12
+ props.taskNameErrorText && 'invalid',
13
13
  ]"
14
14
  >
15
15
  <input
@@ -22,7 +22,7 @@
22
22
  @blur="onInitValidation(['taskName'])"
23
23
  />
24
24
  <span class="tooltip-content">
25
- {{ userNameErrorText }}
25
+ {{ props.taskNameErrorText }}
26
26
  </span>
27
27
  </label>
28
28
  </div>
@@ -101,31 +101,26 @@
101
101
  import type { UI_I_Localization } from '~/lib/models/interfaces'
102
102
  import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
103
103
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
104
- import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
104
+ import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/models/interfaces'
105
105
  import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
106
- import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
106
+ import * as cron from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/utils'
107
107
  import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
108
108
 
109
+ const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
109
110
  const props = defineProps<{
110
111
  target: string
112
+ formValidationFields: UI_I_InitialValidationFields
113
+ taskNameErrorText: string
114
+ }>()
115
+ const emits = defineEmits<{
116
+ (event: 'init-validation', value: string[]): void
111
117
  }>()
112
- const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
113
118
 
114
119
  const localization = computed<UI_I_Localization>(() => useLocal())
115
120
 
116
- const initValidationFields = ref<UI_I_InitialValidationFields>({
117
- taskName: false,
118
- })
119
121
  const onInitValidation = (types: string[]): void => {
120
- types.forEach((type) => (initValidationFields.value[type] = true))
122
+ emits('init-validation', types)
121
123
  }
122
- const userNameErrorText = computed<string>(() => {
123
- if (!initValidationFields.value.taskName) return ''
124
-
125
- model.value.task_name = model.value.task_name.replace(/^\s+/, '')
126
-
127
- return !model.value.task_name ? localization.value.common.fieldRequired : ''
128
- })
129
124
 
130
125
  const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
131
126
  frequencyMethodFunc(localization.value)
@@ -3,6 +3,9 @@
3
3
  :is="currentComponent"
4
4
  v-model="scheduledTaskFormModel"
5
5
  :target="props.target"
6
+ :form-validation-fields="initValidationFields"
7
+ :task-name-error-text="taskNameErrorText"
8
+ @init-validation="onInitValidation"
6
9
  />
7
10
  </template>
8
11
 
@@ -10,9 +13,9 @@
10
13
  import type { UI_I_Localization } from '~/lib/models/interfaces'
11
14
  import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
12
15
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
13
- import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
16
+ import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/models/interfaces'
14
17
  import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
15
- import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
18
+ import * as cron from '~/components/common/pages/scheduledTasks/modals/common/taskForm/lib/utils'
16
19
  import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
17
20
 
18
21
  const scheduledTaskFormModel = defineModel<UI_I_ScheduleNewTasksForm>({
@@ -35,10 +38,13 @@ const currentComponent = computed(() =>
35
38
  const initValidationFields = ref<UI_I_InitialValidationFields>({
36
39
  taskName: false,
37
40
  })
38
- const onInitValidation = (types: string[]): void => {
41
+ const onInitValidation = (
42
+ types: (keyof UI_I_InitialValidationFields)[]
43
+ ): void => {
39
44
  types.forEach((type) => (initValidationFields.value[type] = true))
40
45
  }
41
- const userNameErrorText = computed<string>(() => {
46
+
47
+ const taskNameErrorText = computed<string>(() => {
42
48
  if (!initValidationFields.value.taskName) return ''
43
49
 
44
50
  scheduledTaskFormModel.value.task_name =
@@ -98,4 +104,18 @@ const generateCronExpression = (
98
104
 
99
105
  return cronExpression
100
106
  }
107
+
108
+ // Используется только для нового интерфейса и вызывается в родительском компоненте
109
+ // Запускаем валидацию всех полей
110
+ const isValidateForm = (): boolean => {
111
+ onInitValidation(['taskName'])
112
+
113
+ const errorChecks = [userNameErrorText.value]
114
+
115
+ // если поле невалидно — значение будет непустым
116
+ return errorChecks.every((text) => !text?.length)
117
+ }
118
+ defineExpose({
119
+ isValidateForm,
120
+ })
101
121
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.896",
4
+ "version": "1.5.898",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",