@eturnity/eturnity_reusable_components 6.42.1-EPDM-3013.6 → 6.42.1-EPDM-8599.0

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,644 +0,0 @@
1
- <template>
2
- <container-wrapper>
3
- <upper-container v-if="filterViews && filterViews.length">
4
- <view-container :maxWidth="activeView.length">
5
- <select-component
6
- selectWidth="100%"
7
- selectHeight="36px"
8
- fontSize="13px"
9
- :label="$gettext('active_filter')"
10
- alignItems="vertical"
11
- >
12
- <template #selector>
13
- <option-title>
14
- {{ activeView }}
15
- </option-title>
16
- </template>
17
- <template #dropdown>
18
- <Option
19
- v-for="(item, idx) in filterViews"
20
- :key="idx + '_view'"
21
- @click.native="$emit('on-view-select', item)"
22
- :value="item.name"
23
- >{{ item.name }}
24
- <delete-icon @click.native.stop="$emit('on-view-delete', item)"
25
- /></Option>
26
- </template>
27
- </select-component>
28
- </view-container>
29
- <reset-button @click="$emit('on-reset-filters')">
30
- <icon :name="'update'" size="14px" :color="theme.colors.blue" />
31
- <div>{{ $gettext('reset_filters') }}</div>
32
- </reset-button>
33
- </upper-container>
34
- <column-wrapper
35
- :numCols="filterData.length"
36
- :hasActiveView="!!filterViews && !!filterViews.length"
37
- >
38
- <column-container
39
- v-for="(item, idx) in filterData"
40
- :key="idx + '_filterdata'"
41
- >
42
- <column-title :showBorder="idx + 1 !== filterData.length">
43
- {{ item.columnName }}
44
- </column-title>
45
- <row-container v-if="item.type === 'columns'">
46
- <checkbox-container>
47
- <draggable
48
- @change="onDragChange({ data: item.dataOptions })"
49
- handle=".drag-container"
50
- style="display: contents"
51
- ghost-class="ghost"
52
- :setData="modifyDragItem"
53
- v-model="item.dataOptions"
54
- >
55
- <checkbox-wrapper
56
- v-for="(column, index) in item.dataOptions"
57
- :key="index + 'dataOption'"
58
- >
59
- <drag-container class="drag-container">
60
- <icon :name="'duplicate-1'" size="12px" />
61
- </drag-container>
62
- <checkbox
63
- :label="column.text"
64
- :isChecked="column.selected"
65
- @on-event-handler="
66
- onChange({
67
- dataType: item.type,
68
- value: $event,
69
- choice: column.choice
70
- })
71
- "
72
- size="small"
73
- :isDisabled="column.selected && isCheckboxDisabled"
74
- />
75
- </checkbox-wrapper>
76
- </draggable>
77
- </checkbox-container>
78
- </row-container>
79
- <row-container v-if="item.type === 'filter'" showBorder>
80
- <row-wrapper
81
- v-for="(filter, index) in item.dataOptions"
82
- :key="index + '_field'"
83
- >
84
- <select-component
85
- v-if="isMultipleSelector(filter.filter_type)"
86
- selectWidth="100%"
87
- selectHeight="36px"
88
- fontSize="13px"
89
- :label="filter.label"
90
- alignItems="vertical"
91
- :disabled="!filter.choices.length"
92
- >
93
- <template #selector>
94
- <option-title>
95
- {{ filter.selectedText }}
96
- </option-title>
97
- </template>
98
- <template #dropdown>
99
- <dropdown-checkbox-container @click.stop>
100
- <checkbox
101
- v-for="(filterOption, optionIdx) in filter.choices"
102
- :key="optionIdx + 'optionIdx'"
103
- :label="filterOption.text"
104
- :isChecked="filterOption.selected"
105
- @on-event-handler="
106
- onChange({
107
- dataType: item.type,
108
- value: $event,
109
- choice: filterOption.choice,
110
- field: filter.field
111
- })
112
- "
113
- size="small"
114
- />
115
- </dropdown-checkbox-container>
116
- </template>
117
- </select-component>
118
- <section-container v-else-if="isRangeSelector(filter.filter_type)">
119
- <row-label>{{ filter.label }}</row-label>
120
- <grid-container>
121
- <input-number
122
- :placeholder="
123
- filter.unit
124
- ? $gettext('min_amount') + ' (' + filter.unit + ')'
125
- : $gettext('min_amount')
126
- "
127
- :numberPrecision="0"
128
- :value="filter.range.start"
129
- @input-change="
130
- onChange({
131
- dataType: item.type,
132
- value: $event,
133
- choice: 'start',
134
- field: filter.field
135
- })
136
- "
137
- fontSize="13px"
138
- inputHeight="36px"
139
- :unitName="filter.unit"
140
- />
141
- <input-number
142
- :placeholder="
143
- filter.unit
144
- ? $gettext('max_amount') + ' (' + filter.unit + ')'
145
- : $gettext('max_amount')
146
- "
147
- :numberPrecision="0"
148
- :value="filter.range.end"
149
- @input-change="
150
- onChange({
151
- dataType: item.type,
152
- value: $event,
153
- choice: 'end',
154
- field: filter.field
155
- })
156
- "
157
- fontSize="13px"
158
- inputHeight="36px"
159
- :unitName="filter.unit"
160
- />
161
- </grid-container>
162
- </section-container>
163
- <section-container
164
- v-else-if="isDateSelector(filter.filter_type)"
165
- @click.stop
166
- >
167
- <row-label>{{ filter.label }}</row-label>
168
- <grid-container>
169
- <date-picker-input
170
- :placeholder="$gettext('Date from')"
171
- :lang="getDatePickerLanguage()"
172
- type="date"
173
- :value="filter.range.start"
174
- @change="
175
- onChange({
176
- dataType: item.type,
177
- value: $event,
178
- choice: 'start',
179
- field: filter.field
180
- })
181
- "
182
- @focus="onDatepickerFocus(filter.range)"
183
- @close="onDatepickerBlur()"
184
- format="YYYY-MM-DD"
185
- valueType="format"
186
- :disabled-date="disableFutureDates"
187
- />
188
- <date-picker-input
189
- :placeholder="$gettext('Date to')"
190
- :lang="getDatePickerLanguage()"
191
- type="date"
192
- :value="filter.range.end"
193
- @change="
194
- onChange({
195
- dataType: item.type,
196
- value: $event,
197
- choice: 'end',
198
- field: filter.field
199
- })
200
- "
201
- @focus="onDatepickerFocus(filter.range)"
202
- @close="onDatepickerBlur()"
203
- format="YYYY-MM-DD"
204
- valueType="format"
205
- :disabled-date="disablePastDates"
206
- />
207
- </grid-container>
208
- </section-container>
209
- <select-component
210
- v-else
211
- selectWidth="100%"
212
- selectHeight="36px"
213
- fontSize="13px"
214
- :label="filter.label"
215
- alignItems="vertical"
216
- :disabled="!filter.choices.length"
217
- >
218
- <template #selector="{ selectedValue }">
219
- <option-title>
220
- {{
221
- getSelectedValue({
222
- value: selectedValue,
223
- options: filter.choices,
224
- filter
225
- })
226
- }}
227
- </option-title>
228
- </template>
229
- <template #dropdown>
230
- <Option
231
- v-for="(filterOption, filterIdx) in filter.choices"
232
- :key="filterIdx + '_filterIdx'"
233
- :value="filterOption.choice"
234
- >{{ filterOption.text }}</Option
235
- >
236
- </template>
237
- </select-component>
238
- </row-wrapper>
239
- </row-container>
240
- </column-container>
241
- </column-wrapper>
242
- <button-container>
243
- <main-button
244
- v-if="buttonText.apply_view"
245
- type="primary"
246
- :text="buttonText.apply_view"
247
- @click.native="$emit('on-apply-current-view')"
248
- />
249
- <main-button
250
- type="secondary"
251
- v-if="buttonText.save_view"
252
- :text="buttonText.save_view"
253
- @click.native="$emit('on-save-new-view')"
254
- />
255
- <main-button
256
- type="cancel"
257
- v-if="buttonText.cancel"
258
- :text="buttonText.cancel"
259
- @click.native="$emit('on-cancel-view')"
260
- />
261
- </button-container>
262
- </container-wrapper>
263
- </template>
264
-
265
- <script>
266
- import styled from 'vue-styled-components'
267
- import DatePicker from 'vue2-datepicker'
268
- import SelectComponent from '../inputs/select'
269
- import Option from '../inputs/select/option'
270
- import InputNumber from '../inputs/inputNumber'
271
- import MainButton from '../buttons/mainButton'
272
- import Checkbox from '../inputs/checkbox'
273
- import draggable from 'vuedraggable'
274
- import Icon from '../icon'
275
- import DeleteIcon from '../deleteIcon'
276
- import { datePickerLang } from '../../helpers/translateLang'
277
- import theme from '@/assets/theme.js'
278
- import 'vue2-datepicker/index.css'
279
- import 'vue2-datepicker/locale/de'
280
- import 'vue2-datepicker/locale/en'
281
- import 'vue2-datepicker/locale/es'
282
- import 'vue2-datepicker/locale/fr'
283
- import 'vue2-datepicker/locale/it'
284
-
285
- const ContainerWrapper = styled.div`
286
- position: absolute;
287
- margin-top: 4px;
288
- background-color: ${(props) => props.theme.colors.white};
289
- min-width: 100%;
290
- width: max-content;
291
- border: 1px solid ${(props) => props.theme.colors.grey4};
292
- border-radius: 4px;
293
- z-index: 9999;
294
- font-size: 13px;
295
- `
296
-
297
- const ColAttrs = { numCols: Number, hasActiveView: Boolean }
298
- const ColumnWrapper = styled('div', ColAttrs)`
299
- display: grid;
300
- grid-template-columns: repeat(${(props) => props.numCols}, auto);
301
-
302
- ${({ hasActiveView, theme }) =>
303
- hasActiveView &&
304
- `
305
- border-top: 1px solid ${theme.colors.grey4};
306
- `}
307
- `
308
-
309
- const TitleAttrs = { showBorder: Boolean }
310
- const ColumnTitle = styled('div', TitleAttrs)`
311
- font-size: 14px;
312
- font-weight: 700;
313
- color: ${(props) => props.theme.colors.eturnityGrey};
314
- padding: 10px 14px;
315
- ${({ showBorder, theme }) =>
316
- showBorder &&
317
- `
318
- border-right: 1px solid ${theme.colors.grey4};
319
- `}
320
- `
321
-
322
- const ButtonContainer = styled.div`
323
- display: flex;
324
- gap: 10px;
325
- padding: 15px;
326
- `
327
-
328
- const ColumnContainer = styled.div``
329
-
330
- const DragContainer = styled.div`
331
- cursor: grab;
332
-
333
- &:active {
334
- cursor: grabbing;
335
- }
336
- `
337
-
338
- const RowContainer = styled('div', TitleAttrs)`
339
- padding: 10px 14px;
340
- width: 300px;
341
-
342
- ${({ showBorder, theme }) =>
343
- showBorder &&
344
- `
345
- border-right: 1px solid ${theme.colors.grey4};
346
- `}
347
-
348
- .ghost {
349
- opacity: 0.5;
350
- background-color: #e5fcb4;
351
- }
352
- `
353
-
354
- const OptionTitle = styled.div`
355
- cursor: pointer !important;
356
- `
357
-
358
- const CheckboxContainer = styled.div`
359
- display: grid;
360
- gap: 6px;
361
- `
362
-
363
- const CheckboxWrapper = styled.div`
364
- display: grid;
365
- grid-template-columns: auto 1fr;
366
- gap: 16px;
367
- padding: 2px;
368
- align-items: center;
369
- `
370
-
371
- const DropdownCheckboxContainer = styled.div`
372
- display: grid;
373
- gap: 6px;
374
- width: 100%;
375
- padding: 12px 10px;
376
- `
377
-
378
- const RowWrapper = styled.div`
379
- margin-bottom: 12px;
380
- `
381
-
382
- const DatePickerInput = styled(DatePicker)`
383
- border: 1px solid ${(props) => props.theme.colors.grey4};
384
- border-radius: 4px;
385
- padding: 7px 12px 7px 7px;
386
- width: 100%;
387
- position: relative;
388
-
389
- &.mx-datepicker {
390
- width: 100% !important;
391
- max-width: 100%;
392
- height: 36px;
393
- align-self: flex-end;
394
- }
395
-
396
- .mx-input-wrapper {
397
- position: unset;
398
-
399
- input {
400
- border: none;
401
- height: auto;
402
- padding: 0;
403
- font-size: 13px;
404
- box-shadow: none;
405
- color: #393939;
406
- vertical-align: bottom;
407
- }
408
-
409
- .mx-input-append {
410
- top: 1px;
411
- }
412
- }
413
-
414
- .mx-input-append {
415
- left: 0;
416
- top: 5px;
417
- height: auto;
418
- cursor: pointer;
419
- }
420
- `
421
-
422
- const LabelAttrs = {
423
- marginTop: Boolean
424
- }
425
- const RowLabel = styled('div', LabelAttrs)`
426
- font-weight: 700;
427
- font-size: 13px;
428
- margin-bottom: 8px;
429
- margin-top: ${(props) => (props.marginTop ? '12px' : '0')};
430
- `
431
-
432
- const SectionContainer = styled.div``
433
-
434
- const GridContainer = styled.div`
435
- display: grid;
436
- grid-template-columns: 1fr 1fr;
437
- grid-gap: 12px;
438
- `
439
-
440
- const ViewContainerAttrs = { maxWidth: Number }
441
- const ViewContainer = styled('div', ViewContainerAttrs)`
442
- max-width: ${(props) =>
443
- props.maxWidth && props.maxWidth > 300 ? props.maxWidth + 'ch' : '300px'};
444
- `
445
-
446
- const UpperContainer = styled.div`
447
- display: grid;
448
- grid-gap: 20px
449
- grid-template-columns: 1fr 1fr;
450
- padding: 10px 14px;
451
- `
452
-
453
- const ResetButton = styled.div`
454
- display: inline-flex;
455
- gap: 16px;
456
- width: max-content;
457
- margin-top: 20px;
458
- align-self: center;
459
- font-size: 13px;
460
- color: ${(props) => props.theme.colors.blue};
461
- cursor: pointer;
462
- `
463
-
464
- export default {
465
- name: 'filter-settings',
466
- components: {
467
- ContainerWrapper,
468
- ColumnWrapper,
469
- ColumnTitle,
470
- ColumnContainer,
471
- SelectComponent,
472
- RowContainer,
473
- OptionTitle,
474
- Option,
475
- ButtonContainer,
476
- MainButton,
477
- CheckboxContainer,
478
- CheckboxWrapper,
479
- Checkbox,
480
- RowWrapper,
481
- DropdownCheckboxContainer,
482
- draggable,
483
- Icon,
484
- DragContainer,
485
- InputNumber,
486
- DatePickerInput,
487
- RowLabel,
488
- SectionContainer,
489
- GridContainer,
490
- ViewContainer,
491
- DeleteIcon,
492
- UpperContainer,
493
- ResetButton
494
- },
495
- props: {
496
- filterData: {
497
- required: true
498
- },
499
- hasActiveView: {
500
- required: false
501
- },
502
- buttonText: {
503
- required: true
504
- // example:
505
- // {
506
- // 'save_new_view': '$gettext("save_new_view")',
507
- // 'cancel': '$gettext("cancel")',
508
- // 'save_view': '$gettext("save_view")'
509
- // }
510
- },
511
- filterViews: {
512
- required: true
513
- },
514
- activeLanguage: {
515
- required: false
516
- },
517
- settingsTranslations: {
518
- required: false
519
- },
520
- activeView: {
521
- required: false
522
- }
523
- },
524
- data() {
525
- return {
526
- selectedDates: null,
527
- value1: null,
528
- dateStart: null,
529
- dateEnd: null
530
- }
531
- },
532
- methods: {
533
- onChange({ dataType, value, choice, field }) {
534
- if (
535
- dataType === 'columns' &&
536
- this.isCheckboxDisabled &&
537
- value === false
538
- ) {
539
- return
540
- }
541
- const data = { dataType, value, choice, field }
542
- this.$emit('on-filter-change', data)
543
- },
544
- onDatepickerFocus(range) {
545
- this.dateStart = range.start
546
- this.dateEnd = range.end
547
- this.$emit('on-prevent-close', true)
548
- },
549
- onDatepickerBlur() {
550
- this.$emit('on-prevent-close', false)
551
- },
552
- disablePastDates(date) {
553
- const dateString = this.dateStart
554
- if (!dateString) {
555
- return
556
- }
557
- const dateParts = dateString.split('-')
558
-
559
- const year = parseInt(dateParts[0])
560
- const month = parseInt(dateParts[1]) - 1 // Subtract 1 since January is month 0
561
- const day = parseInt(dateParts[2])
562
-
563
- const currentDate = new Date(year, month, day)
564
- const selectedDate = new Date(date)
565
-
566
- // Disable dates that are greater than or equal to the current date
567
- return selectedDate <= currentDate
568
- },
569
- disableFutureDates(date) {
570
- const dateString = this.dateEnd
571
- if (!dateString) {
572
- return
573
- }
574
- const dateParts = dateString.split('-')
575
-
576
- const year = parseInt(dateParts[0])
577
- const month = parseInt(dateParts[1]) - 1 // Subtract 1 since January is month 0
578
- const day = parseInt(dateParts[2])
579
-
580
- const currentDate = new Date(year, month, day)
581
- const selectedDate = new Date(date)
582
-
583
- // Disable dates that are greater than or equal to the current date
584
- return selectedDate >= currentDate
585
- },
586
- getDatePickerLanguage() {
587
- return datePickerLang(this.activeLanguage)
588
- },
589
- onDragChange({ data }) {
590
- this.$emit('on-drag-change', data)
591
- },
592
- modifyDragItem(dataTransfer) {
593
- const isSafari = /^((?!chrome|android).)*safari/i.test(
594
- navigator.userAgent
595
- )
596
- // prevents the dragged element from dragging the whole row as a "ghost"
597
- // Safari fix because this does not work on Safari
598
- let img = new Image()
599
- if (!isSafari) {
600
- dataTransfer.setDragImage(img, 0, 0)
601
- } else {
602
- img.src =
603
- 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
604
- dataTransfer.setDragImage(img, 0, 0)
605
- }
606
- },
607
- getSelectedValue({ value, options, filter }) {
608
- const foundItem = options.find((item) => item.choice === value)
609
- return foundItem ? foundItem.text : value ? value : filter.selectedText
610
- },
611
- isMultipleSelector(type) {
612
- return type === 'multi_select_integer' || type === 'multi_select_string'
613
- },
614
- isRangeSelector(type) {
615
- return type === 'integer_range'
616
- },
617
- isDateSelector(type) {
618
- return type === 'datetime'
619
- }
620
- },
621
- computed: {
622
- isCheckboxDisabled() {
623
- // if only 1 item left, disable checkbox
624
- let isDisabled = false
625
- let columnsData = this.filterData.filter(
626
- (item) => item.type === 'columns'
627
- )
628
- if (columnsData.length) {
629
- columnsData = columnsData[0]
630
- const filteredColumns = columnsData.dataOptions.filter(
631
- (item) => item.selected
632
- )
633
- if (filteredColumns.length === 1) {
634
- isDisabled = true
635
- }
636
- }
637
- return isDisabled
638
- },
639
- theme() {
640
- return theme
641
- }
642
- }
643
- }
644
- </script>