bfg-common 1.4.185 → 1.4.187

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,230 +1,230 @@
1
- <template>
2
- <div class="horizontal-flex-container overview-chart-title-bar">
3
- <div class="horizontal-flex-container">
4
- <label for="periodSelect" class="label-select"
5
- >{{ localization.inventoryMonitor.period }}:</label
6
- >
7
- <div v-if="!disabledPeriodOptions" class="select">
8
- <select
9
- id="periodSelect"
10
- v-model="selectedPeriod"
11
- data-id="period-select"
12
- >
13
- <option
14
- v-for="(item, index) in periodOptions"
15
- :key="index"
16
- :value="item.value"
17
- >
18
- {{ item.text }}
19
- </option>
20
- </select>
21
- </div>
22
- <span v-else class="single-option">{{ periodOptions[0].text }}</span>
23
- </div>
24
- <div v-show="isShowCustomIntervalButton">
25
- <a
26
- id="show-interval-modal-button"
27
- data-id="show-interval-modal-button"
28
- @click="onShowIntervalModal"
29
- >{{ localization.inventoryMonitor.changeCustomInterval }}</a
30
- >
31
- </div>
32
- <div v-if="!disabledPeriodOptions" class="chart-title">
33
- {{ chartTitleDate }}
34
- </div>
35
- <div class="view-select-label horizontal-flex-container">
36
- <label for="viewSelect" class="label-select"
37
- >{{ localization.common.view }}:</label
38
- >
39
- <div class="select">
40
- <select id="viewSelect" v-model="selectedView" data-id="view-select">
41
- <option
42
- v-for="(item, index) in viewOptions"
43
- :key="index"
44
- :value="item.value"
45
- >
46
- {{ item.text }}
47
- </option>
48
- </select>
49
- </div>
50
- </div>
51
- </div>
52
-
53
- <common-monitor-overview-filters-custom-interval-modal
54
- v-if="isShowIntervalModal"
55
- :selected-periods="props.selectedPeriods"
56
- :format-date="props.formatDate"
57
- :current-lang="props.currentLang"
58
- @hide="onHideIntervalModal"
59
- @submit="onSubmitIntervalModal"
60
- />
61
- </template>
62
-
63
- <script setup lang="ts">
64
- import type { UI_I_Localization } from '~/lib/models/interfaces'
65
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
66
- import type { UI_T_Project } from '~/lib/models/types'
67
- import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
68
- import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
69
- import {
70
- periodFunc,
71
- viewFunc,
72
- } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
73
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
74
-
75
- const localization = computed<UI_I_Localization>(() => useLocal())
76
- const { $formattedDatetime } = useNuxtApp()
77
-
78
- const props = defineProps<{
79
- startDate: number
80
- endDate: number
81
- chartType: 'spline' | 'pie'
82
- view: UI_T_OverviewViewType
83
- selectedPeriods: number[]
84
- formatDate: string
85
- project: UI_T_Project
86
- currentLang: string
87
- formatTime?: string
88
- }>()
89
-
90
- const emits = defineEmits<{
91
- (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
92
- (event: 'update-custom-date', value: number[]): void
93
- }>()
94
-
95
- const selectedPeriod = ref<string>('')
96
- const periodOptions = computed<UI_I_OptionItem[]>(() =>
97
- periodFunc(localization.value)
98
- )
99
- watch(
100
- () => periodOptions.value,
101
- (newValue: UI_I_OptionItem[]) => {
102
- if (newValue) selectedPeriod.value = newValue[0].value
103
- },
104
- { immediate: true }
105
- )
106
-
107
- const isShowCustomIntervalButton = computed<boolean>(
108
- () => selectedPeriod.value === 'custom_interval'
109
- )
110
-
111
- const isShowIntervalModal = ref<boolean>(false)
112
- const onShowIntervalModal = (): void => {
113
- isShowIntervalModal.value = true
114
- }
115
- const onHideIntervalModal = (): void => {
116
- isShowIntervalModal.value = false
117
- }
118
- const onSubmitIntervalModal = (customDates: number[]): void => {
119
- customDatesData.value = customDates
120
- sendUpdatedFilters()
121
- onHideIntervalModal()
122
- emits('update-custom-date', customDates)
123
- }
124
-
125
- const chartTitleDate = computed<string>(() => {
126
- const startValue = props.startDate
127
- const endValue = props.endDate
128
- if (!startValue && !endValue) return ''
129
-
130
- const start = $formattedDatetime(
131
- startValue,
132
- props.formatDate,
133
- true,
134
- '',
135
- props.formatTime
136
- )
137
- const end = $formattedDatetime(
138
- endValue,
139
- props.formatDate,
140
- true,
141
- '',
142
- props.formatTime
143
- )
144
- return `${start} - ${end}`
145
- })
146
-
147
- // const disabledPeriodOptions = computed<boolean>(
148
- // () => props.chartType === 'pie' || !chartTitleDate.value
149
- // )
150
-
151
- const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
152
-
153
- const selectedView = ref<string>('')
154
- const viewOptions = computed<UI_I_OptionItem[]>(() =>
155
- viewFunc(localization.value, props.view, props.project)
156
- )
157
- watch(
158
- () => viewOptions.value,
159
- (newValue: UI_I_OptionItem[]) => {
160
- if (newValue) selectedView.value = newValue[0].value
161
- },
162
- { immediate: true }
163
- )
164
-
165
- const customDatesData = ref<number[]>([])
166
- const sendUpdatedFilters = (): void => {
167
- const currentPeriod =
168
- selectedPeriod.value === 'custom_interval'
169
- ? customDatesData.value
170
- : getValidDateByOptionFunc(selectedPeriod.value)
171
- const filters: UI_I_MonitorGraphPayload = {
172
- period: currentPeriod,
173
- view: selectedView.value,
174
- periodName: selectedPeriod.value,
175
- }
176
-
177
- emits('update-filters', filters)
178
- }
179
- watch(
180
- () => [selectedPeriod.value, selectedView.value],
181
- (newValue: string[]) => {
182
- newValue[0] !== 'custom_interval' && sendUpdatedFilters()
183
- },
184
- { immediate: true }
185
- )
186
- </script>
187
-
188
- <style scoped lang="scss">
189
- .horizontal-flex-container {
190
- display: flex;
191
- flex-direction: row;
192
- align-items: center;
193
- line-height: 20px;
194
- flex-shrink: 0;
195
- padding-top: 5px;
196
-
197
- .select select {
198
- height: 20px;
199
- margin: 5px;
200
- color: var(--global-font-color);
201
- }
202
- .single-option {
203
- margin-left: 5px;
204
- }
205
-
206
- .chart-title {
207
- color: var(--global-font-color);
208
- text-overflow: ellipsis;
209
- white-space: nowrap;
210
- overflow: hidden;
211
- margin: 6px;
212
- font-weight: 700;
213
- text-transform: uppercase;
214
- }
215
-
216
- #show-interval-modal-button {
217
- cursor: pointer;
218
- color: var(--dropdown-item-color);
219
- }
220
-
221
- .view-select-label {
222
- margin-left: auto;
223
- padding-right: 7px;
224
- padding-left: 7px;
225
- text-overflow: ellipsis;
226
- white-space: nowrap;
227
- align-items: center;
228
- }
229
- }
230
- </style>
1
+ <template>
2
+ <div class="horizontal-flex-container overview-chart-title-bar">
3
+ <div class="horizontal-flex-container">
4
+ <label for="periodSelect" class="label-select"
5
+ >{{ localization.inventoryMonitor.period }}:</label
6
+ >
7
+ <div v-if="!disabledPeriodOptions" class="select">
8
+ <select
9
+ id="periodSelect"
10
+ v-model="selectedPeriod"
11
+ data-id="period-select"
12
+ >
13
+ <option
14
+ v-for="(item, index) in periodOptions"
15
+ :key="index"
16
+ :value="item.value"
17
+ >
18
+ {{ item.text }}
19
+ </option>
20
+ </select>
21
+ </div>
22
+ <span v-else class="single-option">{{ periodOptions[0].text }}</span>
23
+ </div>
24
+ <div v-show="isShowCustomIntervalButton">
25
+ <a
26
+ id="show-interval-modal-button"
27
+ data-id="show-interval-modal-button"
28
+ @click="onShowIntervalModal"
29
+ >{{ localization.inventoryMonitor.changeCustomInterval }}</a
30
+ >
31
+ </div>
32
+ <div v-if="!disabledPeriodOptions" class="chart-title">
33
+ {{ chartTitleDate }}
34
+ </div>
35
+ <div class="view-select-label horizontal-flex-container">
36
+ <label for="viewSelect" class="label-select"
37
+ >{{ localization.common.view }}:</label
38
+ >
39
+ <div class="select">
40
+ <select id="viewSelect" v-model="selectedView" data-id="view-select">
41
+ <option
42
+ v-for="(item, index) in viewOptions"
43
+ :key="index"
44
+ :value="item.value"
45
+ >
46
+ {{ item.text }}
47
+ </option>
48
+ </select>
49
+ </div>
50
+ </div>
51
+ </div>
52
+
53
+ <common-monitor-overview-filters-custom-interval-modal
54
+ v-if="isShowIntervalModal"
55
+ :selected-periods="props.selectedPeriods"
56
+ :format-date="props.formatDate"
57
+ :current-lang="props.currentLang"
58
+ @hide="onHideIntervalModal"
59
+ @submit="onSubmitIntervalModal"
60
+ />
61
+ </template>
62
+
63
+ <script setup lang="ts">
64
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
65
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
66
+ import type { UI_T_Project } from '~/lib/models/types'
67
+ import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
68
+ import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
69
+ import {
70
+ periodFunc,
71
+ viewFunc,
72
+ } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
73
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
74
+
75
+ const localization = computed<UI_I_Localization>(() => useLocal())
76
+ const { $formattedDatetime } = useNuxtApp()
77
+
78
+ const props = defineProps<{
79
+ startDate: number
80
+ endDate: number
81
+ chartType: 'spline' | 'pie'
82
+ view: UI_T_OverviewViewType
83
+ selectedPeriods: number[]
84
+ formatDate: string
85
+ project: UI_T_Project
86
+ currentLang: string
87
+ formatTime?: string
88
+ }>()
89
+
90
+ const emits = defineEmits<{
91
+ (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
92
+ (event: 'update-custom-date', value: number[]): void
93
+ }>()
94
+
95
+ const selectedPeriod = ref<string>('')
96
+ const periodOptions = computed<UI_I_OptionItem[]>(() =>
97
+ periodFunc(localization.value)
98
+ )
99
+ watch(
100
+ () => periodOptions.value,
101
+ (newValue: UI_I_OptionItem[]) => {
102
+ if (newValue) selectedPeriod.value = newValue[0].value
103
+ },
104
+ { immediate: true }
105
+ )
106
+
107
+ const isShowCustomIntervalButton = computed<boolean>(
108
+ () => selectedPeriod.value === 'custom_interval'
109
+ )
110
+
111
+ const isShowIntervalModal = ref<boolean>(false)
112
+ const onShowIntervalModal = (): void => {
113
+ isShowIntervalModal.value = true
114
+ }
115
+ const onHideIntervalModal = (): void => {
116
+ isShowIntervalModal.value = false
117
+ }
118
+ const onSubmitIntervalModal = (customDates: number[]): void => {
119
+ customDatesData.value = customDates
120
+ sendUpdatedFilters()
121
+ onHideIntervalModal()
122
+ emits('update-custom-date', customDates)
123
+ }
124
+
125
+ const chartTitleDate = computed<string>(() => {
126
+ const startValue = props.startDate
127
+ const endValue = props.endDate
128
+ if (!startValue && !endValue) return ''
129
+
130
+ const start = $formattedDatetime(
131
+ startValue,
132
+ props.formatDate,
133
+ true,
134
+ '',
135
+ props.formatTime
136
+ )
137
+ const end = $formattedDatetime(
138
+ endValue,
139
+ props.formatDate,
140
+ true,
141
+ '',
142
+ props.formatTime
143
+ )
144
+ return `${start} - ${end}`
145
+ })
146
+
147
+ // const disabledPeriodOptions = computed<boolean>(
148
+ // () => props.chartType === 'pie' || !chartTitleDate.value
149
+ // )
150
+
151
+ const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
152
+
153
+ const selectedView = ref<string>('')
154
+ const viewOptions = computed<UI_I_OptionItem[]>(() =>
155
+ viewFunc(localization.value, props.view, props.project)
156
+ )
157
+ watch(
158
+ () => viewOptions.value,
159
+ (newValue: UI_I_OptionItem[]) => {
160
+ if (newValue) selectedView.value = newValue[0].value
161
+ },
162
+ { immediate: true }
163
+ )
164
+
165
+ const customDatesData = ref<number[]>([])
166
+ const sendUpdatedFilters = (): void => {
167
+ const currentPeriod =
168
+ selectedPeriod.value === 'custom_interval'
169
+ ? customDatesData.value
170
+ : getValidDateByOptionFunc(selectedPeriod.value)
171
+ const filters: UI_I_MonitorGraphPayload = {
172
+ period: currentPeriod,
173
+ view: selectedView.value,
174
+ periodName: selectedPeriod.value,
175
+ }
176
+
177
+ emits('update-filters', filters)
178
+ }
179
+ watch(
180
+ () => [selectedPeriod.value, selectedView.value],
181
+ (newValue: string[]) => {
182
+ newValue[0] !== 'custom_interval' && sendUpdatedFilters()
183
+ },
184
+ { immediate: true }
185
+ )
186
+ </script>
187
+
188
+ <style scoped lang="scss">
189
+ .horizontal-flex-container {
190
+ display: flex;
191
+ flex-direction: row;
192
+ align-items: center;
193
+ line-height: 20px;
194
+ flex-shrink: 0;
195
+ padding-top: 5px;
196
+
197
+ .select select {
198
+ height: 20px;
199
+ margin: 5px;
200
+ color: var(--global-font-color);
201
+ }
202
+ .single-option {
203
+ margin-left: 5px;
204
+ }
205
+
206
+ .chart-title {
207
+ color: var(--global-font-color);
208
+ text-overflow: ellipsis;
209
+ white-space: nowrap;
210
+ overflow: hidden;
211
+ margin: 6px;
212
+ font-weight: 700;
213
+ text-transform: uppercase;
214
+ }
215
+
216
+ #show-interval-modal-button {
217
+ cursor: pointer;
218
+ color: var(--dropdown-item-color);
219
+ }
220
+
221
+ .view-select-label {
222
+ margin-left: auto;
223
+ padding-right: 7px;
224
+ padding-left: 7px;
225
+ text-overflow: ellipsis;
226
+ white-space: nowrap;
227
+ align-items: center;
228
+ }
229
+ }
230
+ </style>