bfg-common 1.4.264 → 1.4.266

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.
@@ -35,6 +35,7 @@
35
35
  import type { UI_I_Localization } from '~/lib/models/interfaces'
36
36
  import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
37
37
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
38
+ import { validateDate } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/utils'
38
39
  import { frequencyEndTimeFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/end/lib/config/endOptions'
39
40
 
40
41
  const modelFrequencyLocal = defineModel<UI_I_ScheduleNewTasksForm>({
@@ -51,9 +52,10 @@ const frequencyEndTimeOptions = computed<UI_I_SelectInputItem[]>(() =>
51
52
  const selectedFrequencyEndMode = ref<'never' | 'on'>('never')
52
53
 
53
54
  const schedulerEndDateErrorText = computed<string>(() => {
54
- return !modelFrequencyLocal.value.frg_end_time
55
+ const { frg_end_time, frg_start_on_time } = modelFrequencyLocal.value
56
+ return !frg_end_time
55
57
  ? localization.value.common.fieldRequired
56
- : ''
58
+ : validateDate(localization.value, frg_end_time, frg_start_on_time)
57
59
  })
58
60
  watch(
59
61
  [schedulerEndDateErrorText, selectedFrequencyEndMode],
@@ -87,14 +87,26 @@ export const validateField = (
87
87
  export const validateDate = (
88
88
  localization: UI_I_Localization,
89
89
  date: string,
90
- _predefinedDate?: string
90
+ predefinedDate?: string
91
91
  ): string => {
92
92
  const currentDateTime = new Date()
93
93
  const thresholdDate = subMinutes(currentDateTime, 4) // Используем date-fns для вычитания 4 минут
94
94
 
95
95
  const selectedDate = parseISO(date) // Начало дня выбранной даты theValueLargeThanStartTime
96
96
 
97
- return isBefore(selectedDate, thresholdDate)
98
- ? localization.common.theValueTooSmall
99
- : ''
97
+ const comparisonDate = predefinedDate
98
+ ? parseISO(predefinedDate)
99
+ : thresholdDate
100
+
101
+ if (predefinedDate) {
102
+ if (isBefore(comparisonDate, subMinutes(selectedDate, 1))) {
103
+ return localization.common.theValueLargeThanStartTime
104
+ }
105
+ }
106
+
107
+ if (isBefore(selectedDate, comparisonDate)) {
108
+ return localization.common.theValueTooSmall
109
+ }
110
+
111
+ return ''
100
112
  }
@@ -24,8 +24,10 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts" setup>
27
+ import { format } from 'date-fns'
27
28
  import type { UI_I_Localization } from '~/lib/models/interfaces'
28
29
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
30
+ import { validateDate } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/utils'
29
31
 
30
32
  const modelFrequencyLocal = defineModel<UI_I_ScheduleNewTasksForm>({
31
33
  required: true,
@@ -37,7 +39,10 @@ const localization = computed<UI_I_Localization>(() => useLocal())
37
39
  const schedulerStartOnErrorText = computed<string>(() => {
38
40
  return !modelFrequencyLocal.value.frg_start_on_time
39
41
  ? localization.value.common.fieldRequired
40
- : ''
42
+ : validateDate(
43
+ localization.value,
44
+ modelFrequencyLocal.value.frg_start_on_time
45
+ )
41
46
  })
42
47
  watch(
43
48
  schedulerStartOnErrorText,
@@ -47,19 +52,16 @@ watch(
47
52
  { immediate: true }
48
53
  )
49
54
 
50
- // const onUpdateDateTo = (val: number): void => {
51
- // if (!val) return
52
- //
53
- // modelTimeLocal.value = val // milliseconds
54
- //
55
- // currentDateLocal.value = $formattedDate(new Date(val), 'MM.dd.yyyy, hh:mm')
56
- // }
57
- //
58
- // watch(currentDateLocal, (newValue) => {
59
- // $isDate(newValue) &&
60
- // (calendarDefaultDate.value = modelTimeLocal.value =
61
- // $getUnixByDate(newValue))
62
- // })
55
+ onMounted(() => {
56
+ setDefaultDateTime()
57
+ })
58
+ const setDefaultDateTime = () => {
59
+ const currentDateTime = new Date()
60
+ modelFrequencyLocal.value.frg_start_on_time = format(
61
+ currentDateTime,
62
+ "yyyy-MM-dd'T'HH:mm"
63
+ )
64
+ }
63
65
  </script>
64
66
 
65
67
  <style lang="scss" scoped>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.264",
4
+ "version": "1.4.266",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",