@enso-ui/filters 3.0.14 → 3.0.18
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.
- package/bulma/index.js +2 -4
- package/package.json +2 -2
- package/renderless/index.js +1 -2
- package/src/bulma/BooleanFilter.vue +1 -2
- package/src/bulma/DateFilter.vue +2 -1
- package/src/bulma/EnsoDateFilter.vue +1 -1
- package/src/bulma/EnsoFilter.vue +1 -1
- package/src/bulma/EnsoInputFilter.vue +1 -1
- package/src/bulma/EnsoIntervalFilter.vue +1 -1
- package/src/bulma/EnsoSelectFilter.vue +4 -1
- package/src/bulma/EnsoToggleFilter.vue +1 -1
- package/src/bulma/InputFilter.vue +4 -1
- package/src/bulma/IntervalFilter.vue +7 -4
- package/src/bulma/SelectFilter.vue +4 -1
- package/src/renderless/CoreDateFilter.vue +107 -85
- package/src/renderless/CoreIntervalFilter.vue +2 -2
- package/src/renderless/FilterState.vue +5 -1
- package/src/renderless/intervals.js +1 -1
- package/src/bulma/DateIntervalFilter.vue +0 -102
- package/src/bulma/EnsoDateIntervalFilter.vue +0 -32
- package/src/renderless/CoreDateIntervalFilter.vue +0 -50
- package/src/renderless/dateIntervals.js +0 -51
package/bulma/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import IntervalFilter from '../src/bulma/IntervalFilter.vue';
|
|
2
2
|
import InputFilter from '../src/bulma/InputFilter.vue';
|
|
3
3
|
import DateFilter from '../src/bulma/DateFilter.vue';
|
|
4
|
-
import DateIntervalFilter from '../src/bulma/DateIntervalFilter.vue';
|
|
5
4
|
import VueFilter from '../src/bulma/VueFilter.vue';
|
|
6
5
|
import ToggleFilter from '../src/bulma/ToggleFilter.vue';
|
|
7
6
|
import SelectFilter from '../src/bulma/SelectFilter.vue';
|
|
@@ -9,13 +8,12 @@ import BooleanFilter from '../src/bulma/BooleanFilter.vue';
|
|
|
9
8
|
import EnsoIntervalFilter from '../src/bulma/EnsoIntervalFilter.vue';
|
|
10
9
|
import EnsoInputFilter from '../src/bulma/EnsoInputFilter.vue';
|
|
11
10
|
import EnsoDateFilter from '../src/bulma/EnsoDateFilter.vue';
|
|
12
|
-
import EnsoDateIntervalFilter from '../src/bulma/EnsoDateIntervalFilter.vue';
|
|
13
11
|
import EnsoFilter from '../src/bulma/EnsoFilter.vue';
|
|
14
12
|
import EnsoToggleFilter from '../src/bulma/EnsoToggleFilter.vue';
|
|
15
13
|
import EnsoSelectFilter from '../src/bulma/EnsoSelectFilter.vue';
|
|
16
14
|
|
|
17
15
|
export {
|
|
18
16
|
InputFilter, IntervalFilter, EnsoIntervalFilter, DateFilter, EnsoDateFilter,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
BooleanFilter, VueFilter, ToggleFilter, EnsoFilter, EnsoToggleFilter,
|
|
18
|
+
SelectFilter, EnsoSelectFilter, EnsoInputFilter,
|
|
21
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enso-ui/filters",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18",
|
|
4
4
|
"description": "Renderless Vue Filter Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@fortawesome/vue-fontawesome": "3.0.0-5",
|
|
35
35
|
"bulma": "^0.9.0",
|
|
36
36
|
"date-fns": "^2.0.0",
|
|
37
|
-
"v-tooltip": "4.0.0-beta.2",
|
|
37
|
+
"v-tooltip": "^4.0.0-beta.2",
|
|
38
38
|
"vue": "^3.0",
|
|
39
39
|
"vuex": "^4.0.0"
|
|
40
40
|
},
|
package/renderless/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import CoreIntervalFilter from '../src/renderless/CoreIntervalFilter.vue';
|
|
2
2
|
import CoreDateFilter from '../src/renderless/CoreDateFilter.vue';
|
|
3
|
-
import CoreDateIntervalFilter from '../src/renderless/CoreDateIntervalFilter.vue';
|
|
4
3
|
import FilterState from '../src/renderless/FilterState.vue';
|
|
5
4
|
|
|
6
5
|
export {
|
|
7
|
-
CoreIntervalFilter, CoreDateFilter,
|
|
6
|
+
CoreIntervalFilter, CoreDateFilter, FilterState,
|
|
8
7
|
};
|
package/src/bulma/DateFilter.vue
CHANGED
package/src/bulma/EnsoFilter.vue
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<base-select-filter :
|
|
2
|
+
<base-select-filter :class="$attrs.class"
|
|
3
|
+
:compact="compact"
|
|
3
4
|
:i18n="i18n"
|
|
4
5
|
:name="name">
|
|
5
6
|
<enso-select v-bind="{...$attrs, class: 'select-wrapper'}"
|
|
@@ -24,6 +25,8 @@ export default {
|
|
|
24
25
|
|
|
25
26
|
inject: ['i18n'],
|
|
26
27
|
|
|
28
|
+
inheritAttrs: false,
|
|
29
|
+
|
|
27
30
|
props: {
|
|
28
31
|
compact: {
|
|
29
32
|
type: Boolean,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="interval-filter is-paddingless"
|
|
2
|
+
<div class="interval-filter is-paddingless"
|
|
3
|
+
:class="$attrs.class">
|
|
3
4
|
<div v-if="!compact"
|
|
4
5
|
class="header has-text-centered has-background-light">
|
|
5
6
|
<b>{{ i18n(name) }}</b>
|
|
@@ -44,6 +45,8 @@ export default {
|
|
|
44
45
|
|
|
45
46
|
components: { CoreInputFilter },
|
|
46
47
|
|
|
48
|
+
inheritAttrs: false,
|
|
49
|
+
|
|
47
50
|
props: {
|
|
48
51
|
compact: {
|
|
49
52
|
type: Boolean,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="interval-filter is-paddingless"
|
|
2
|
+
<div class="interval-filter is-paddingless"
|
|
3
|
+
:class="$attrs.class">
|
|
3
4
|
<div v-if="!compact"
|
|
4
5
|
class="header has-text-centered has-background-light">
|
|
5
6
|
<b>{{ i18n(name) }}</b>
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
:class="['input-wrapper', {'has-background-light': compact}]">
|
|
9
10
|
<core-interval-filter v-bind="$attrs">
|
|
10
11
|
<template #default="{
|
|
11
|
-
|
|
12
|
+
modelValue, invalid, minBindings, minEvents, maxBindings,
|
|
12
13
|
maxEvents, minClearEvents, maxClearEvents,
|
|
13
14
|
}">
|
|
14
15
|
<div class="columns is-mobile">
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
v-bind="minBindings"
|
|
20
21
|
:placeholder="i18n(minLabel)"
|
|
21
22
|
v-on="minEvents">
|
|
22
|
-
<span v-if="
|
|
23
|
+
<span v-if="modelValue.min"
|
|
23
24
|
class="icon is-small is-right clear-button"
|
|
24
25
|
v-on="minClearEvents">
|
|
25
26
|
<a class="delete is-small"/>
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
v-bind="maxBindings"
|
|
34
35
|
:placeholder="i18n(maxLabel)"
|
|
35
36
|
v-on="maxEvents">
|
|
36
|
-
<span v-if="
|
|
37
|
+
<span v-if="modelValue.max"
|
|
37
38
|
class="icon is-small is-right clear-button"
|
|
38
39
|
v-on="maxClearEvents">
|
|
39
40
|
<a class="delete is-small"/>
|
|
@@ -59,6 +60,8 @@ export default {
|
|
|
59
60
|
|
|
60
61
|
components: { CoreIntervalFilter },
|
|
61
62
|
|
|
63
|
+
inheritAttrs: false,
|
|
64
|
+
|
|
62
65
|
props: {
|
|
63
66
|
compact: {
|
|
64
67
|
type: Boolean,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<base-select-filter :
|
|
2
|
+
<base-select-filter :class="$attrs.class"
|
|
3
|
+
:compact="compact"
|
|
3
4
|
:i18n="i18n"
|
|
4
5
|
:name="name">
|
|
5
6
|
<vue-select v-bind="{...$attrs, class: 'select-wrapper'}"
|
|
@@ -23,6 +24,8 @@ export default {
|
|
|
23
24
|
|
|
24
25
|
components: { BaseSelectFilter, VueSelect },
|
|
25
26
|
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
|
|
26
29
|
props: {
|
|
27
30
|
compact: {
|
|
28
31
|
type: Boolean,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {
|
|
3
|
-
format, addDays, startOfDay, endOfDay, addWeeks,
|
|
4
|
-
|
|
3
|
+
compareAsc, format, addDays, startOfDay, endOfDay, addWeeks,
|
|
4
|
+
startOfWeek, endOfWeek, addMonths, startOfMonth, endOfMonth,
|
|
5
|
+
addYears, startOfYear, endOfYear, parse
|
|
5
6
|
} from 'date-fns';
|
|
6
7
|
import { lcwords } from '@enso-ui/strings';
|
|
7
|
-
import dateIntervals from './dateIntervals';
|
|
8
8
|
import {
|
|
9
9
|
Intervals, Base, Past, Future, Adjustments,
|
|
10
10
|
} from './intervals';
|
|
@@ -12,36 +12,42 @@ import {
|
|
|
12
12
|
export default {
|
|
13
13
|
name: 'CoreDateFilter',
|
|
14
14
|
|
|
15
|
-
mixins: [dateIntervals],
|
|
16
|
-
|
|
17
15
|
inheritAttrs: false,
|
|
18
16
|
|
|
19
17
|
props: {
|
|
20
|
-
default: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: Intervals.today,
|
|
23
|
-
validator: v => Base.concat(Past)
|
|
24
|
-
.concat(Future).includes(v),
|
|
25
|
-
},
|
|
26
18
|
direction: {
|
|
27
19
|
type: Boolean,
|
|
28
20
|
default: false,
|
|
29
21
|
},
|
|
30
|
-
|
|
22
|
+
excluded: {
|
|
31
23
|
type: Array,
|
|
32
24
|
default: () => ([]),
|
|
33
25
|
validator: v => !v.some(val => !Base.concat(Past)
|
|
34
26
|
.concat(Future).includes(val)),
|
|
35
27
|
},
|
|
28
|
+
filter: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true,
|
|
31
|
+
validator: v => Base.concat(Past)
|
|
32
|
+
.concat(Future).includes(v),
|
|
33
|
+
},
|
|
34
|
+
format: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: 'Y-m-d H:i:s',
|
|
37
|
+
},
|
|
36
38
|
future: {
|
|
37
39
|
type: Boolean,
|
|
38
40
|
default: false,
|
|
39
41
|
},
|
|
40
|
-
|
|
42
|
+
interval: {
|
|
43
|
+
type: Object,
|
|
44
|
+
required: true,
|
|
45
|
+
validator: v => Object.keys(v).includes('min')
|
|
46
|
+
&& Object.keys(v).includes('max'),
|
|
47
|
+
},
|
|
48
|
+
locale: {
|
|
41
49
|
type: String,
|
|
42
|
-
default:
|
|
43
|
-
validator: v => Base.concat(Past)
|
|
44
|
-
.concat(Future).includes(v),
|
|
50
|
+
default: 'en',
|
|
45
51
|
},
|
|
46
52
|
weekStartsOn: {
|
|
47
53
|
type: Number,
|
|
@@ -50,11 +56,10 @@ export default {
|
|
|
50
56
|
},
|
|
51
57
|
},
|
|
52
58
|
|
|
53
|
-
emits: ['update', 'update:
|
|
59
|
+
emits: ['update:filter', 'update:interval'],
|
|
54
60
|
|
|
55
61
|
data: v => ({
|
|
56
|
-
|
|
57
|
-
isFuture: false,
|
|
62
|
+
isFuture: v.future,
|
|
58
63
|
}),
|
|
59
64
|
|
|
60
65
|
computed: {
|
|
@@ -64,6 +69,14 @@ export default {
|
|
|
64
69
|
custom() {
|
|
65
70
|
return this.filter === Intervals.custom;
|
|
66
71
|
},
|
|
72
|
+
default() {
|
|
73
|
+
return Base.find(value => !this.excluded.includes(value));
|
|
74
|
+
},
|
|
75
|
+
equals() {
|
|
76
|
+
return !!this.interval.min
|
|
77
|
+
&& !!this.interval.max
|
|
78
|
+
&& compareAsc(this.parsedMin, this.parsedMax) === 0;
|
|
79
|
+
},
|
|
67
80
|
filters() {
|
|
68
81
|
return Object.keys(Intervals)
|
|
69
82
|
.filter(option => this.options.includes(Intervals[option]))
|
|
@@ -72,20 +85,27 @@ export default {
|
|
|
72
85
|
return filters;
|
|
73
86
|
}, {});
|
|
74
87
|
},
|
|
88
|
+
internalFormat() {
|
|
89
|
+
return this.format.replace('d', 'dd')
|
|
90
|
+
.replace('m', 'MM')
|
|
91
|
+
.replace('Y', 'yyyy')
|
|
92
|
+
.replace('H', 'HH')
|
|
93
|
+
.replace('i', 'mm')
|
|
94
|
+
.replace('s', 'ss');
|
|
95
|
+
},
|
|
75
96
|
options() {
|
|
76
97
|
return Base.concat(this.isFuture ? Future : Past);
|
|
77
98
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
this.update();
|
|
99
|
+
parsedMax() {
|
|
100
|
+
return parse(this.interval.max, this.internalFormat, new Date());
|
|
101
|
+
},
|
|
102
|
+
parsedMin() {
|
|
103
|
+
return parse(this.interval.min, this.internalFormat, new Date());
|
|
84
104
|
},
|
|
85
105
|
},
|
|
86
106
|
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
watch: {
|
|
108
|
+
filter: 'update',
|
|
89
109
|
},
|
|
90
110
|
|
|
91
111
|
created() {
|
|
@@ -93,75 +113,77 @@ export default {
|
|
|
93
113
|
},
|
|
94
114
|
|
|
95
115
|
methods: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
update(filter = this.filter) {
|
|
117
|
+
switch (filter) {
|
|
118
|
+
case Intervals.today:
|
|
119
|
+
case Intervals.yesterday:
|
|
120
|
+
case Intervals.tomorrow:
|
|
121
|
+
this.daily();
|
|
122
|
+
break;
|
|
123
|
+
case Intervals.lastWeek:
|
|
124
|
+
case Intervals.thisWeek:
|
|
125
|
+
case Intervals.nextWeek:
|
|
126
|
+
this.weekly();
|
|
127
|
+
break;
|
|
128
|
+
case Intervals.lastMonth:
|
|
129
|
+
case Intervals.thisMonth:
|
|
130
|
+
case Intervals.nextMonth:
|
|
131
|
+
this.monthly();
|
|
132
|
+
break;
|
|
133
|
+
case Intervals.lastYear:
|
|
134
|
+
case Intervals.thisYear:
|
|
135
|
+
case Intervals.nextYear:
|
|
136
|
+
this.yearly();
|
|
137
|
+
break;
|
|
138
|
+
case Intervals.all:
|
|
139
|
+
this.all();
|
|
140
|
+
break;
|
|
141
|
+
case Intervals.custom:
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
throw Error('Unknown Interval');
|
|
145
|
+
}
|
|
104
146
|
},
|
|
105
147
|
label(option) {
|
|
106
148
|
return lcwords(option);
|
|
107
149
|
},
|
|
108
|
-
adjust() {
|
|
109
|
-
switch (this.filter) {
|
|
110
|
-
case Intervals.today:
|
|
111
|
-
case Intervals.yesterday:
|
|
112
|
-
case Intervals.tomorrow:
|
|
113
|
-
this.daily();
|
|
114
|
-
break;
|
|
115
|
-
case Intervals.lastWeek:
|
|
116
|
-
case Intervals.thisWeek:
|
|
117
|
-
case Intervals.nextWeek:
|
|
118
|
-
this.weekly();
|
|
119
|
-
break;
|
|
120
|
-
case Intervals.lastMonth:
|
|
121
|
-
case Intervals.thisMonth:
|
|
122
|
-
case Intervals.nextMonth:
|
|
123
|
-
this.monthly();
|
|
124
|
-
break;
|
|
125
|
-
case Intervals.lastYear:
|
|
126
|
-
case Intervals.thisYear:
|
|
127
|
-
case Intervals.nextYear:
|
|
128
|
-
this.yearly();
|
|
129
|
-
break;
|
|
130
|
-
case Intervals.all:
|
|
131
|
-
this.all();
|
|
132
|
-
break;
|
|
133
|
-
case Intervals.custom:
|
|
134
|
-
break;
|
|
135
|
-
default:
|
|
136
|
-
throw Error('Unknown Interval');
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
150
|
daily() {
|
|
140
151
|
const min = startOfDay(addDays(new Date(), this.adjustment));
|
|
141
152
|
const max = endOfDay(addDays(new Date(), this.adjustment));
|
|
142
153
|
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
const interval = { min: this.date(min), max: this.date(max) };
|
|
155
|
+
|
|
156
|
+
this.$emit('update:interval', interval);
|
|
145
157
|
},
|
|
146
158
|
weekly() {
|
|
147
159
|
const options = { weekStartsOn: this.weekStartsOn };
|
|
148
160
|
const min = startOfWeek(addWeeks(new Date(), this.adjustment), options);
|
|
149
161
|
const max = endOfWeek(addWeeks(new Date(), this.adjustment), options);
|
|
150
162
|
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
const interval = { min: this.date(min), max: this.date(max) };
|
|
164
|
+
|
|
165
|
+
this.$emit('update:interval', interval);
|
|
153
166
|
},
|
|
154
167
|
monthly() {
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
const min = startOfMonth(addMonths(new Date(), this.adjustment));
|
|
169
|
+
const max = endOfMonth(addMonths(new Date(), this.adjustment));
|
|
170
|
+
|
|
171
|
+
const interval = { min: this.date(min), max: this.date(max) };
|
|
172
|
+
|
|
173
|
+
this.$emit('update:interval', interval);
|
|
157
174
|
},
|
|
158
175
|
yearly() {
|
|
159
|
-
|
|
160
|
-
|
|
176
|
+
const min = startOfYear(addYears(new Date(), this.adjustment));
|
|
177
|
+
const max = endOfYear(addYears(new Date(), this.adjustment));
|
|
178
|
+
|
|
179
|
+
const interval = { min: this.date(min), max: this.date(max) };
|
|
180
|
+
|
|
181
|
+
this.$emit('update:interval', interval);
|
|
161
182
|
},
|
|
162
183
|
all() {
|
|
163
|
-
|
|
164
|
-
|
|
184
|
+
const interval = { min: null, max: null };
|
|
185
|
+
|
|
186
|
+
this.$emit('update:interval', interval);
|
|
165
187
|
},
|
|
166
188
|
date(date) {
|
|
167
189
|
return format(date, this.internalFormat);
|
|
@@ -171,7 +193,7 @@ export default {
|
|
|
171
193
|
render() {
|
|
172
194
|
return this.$slots.default({
|
|
173
195
|
backEvents: {
|
|
174
|
-
click: () => this
|
|
196
|
+
click: () => this.$emit('update:filter', this.default),
|
|
175
197
|
},
|
|
176
198
|
custom: this.custom,
|
|
177
199
|
direction: this.direction,
|
|
@@ -181,18 +203,18 @@ export default {
|
|
|
181
203
|
directionEvents: {
|
|
182
204
|
'update:modelValue': e => {
|
|
183
205
|
this.isFuture = e;
|
|
184
|
-
this
|
|
206
|
+
this.$emit('update:filter', this.default);
|
|
185
207
|
},
|
|
186
208
|
},
|
|
187
209
|
filter: this.filter,
|
|
188
210
|
filters: Object.keys(this.filters)
|
|
189
|
-
.filter(key => !this.
|
|
211
|
+
.filter(key => !this.excluded.includes(key))
|
|
190
212
|
.reduce((filters, key) => {
|
|
191
213
|
filters[key] = this.filters[key];
|
|
192
214
|
return filters;
|
|
193
215
|
}, {}),
|
|
194
|
-
filterEvents:
|
|
195
|
-
click: () => this
|
|
216
|
+
filterEvents: filter => ({
|
|
217
|
+
click: () => this.$emit('update:filter', filter),
|
|
196
218
|
}),
|
|
197
219
|
minBindings: {
|
|
198
220
|
modelValue: this.interval.min,
|
|
@@ -204,8 +226,8 @@ export default {
|
|
|
204
226
|
},
|
|
205
227
|
minEvents: {
|
|
206
228
|
'update:modelValue': e => {
|
|
207
|
-
this.interval.
|
|
208
|
-
this
|
|
229
|
+
const interval = { min: e, max: this.interval.max };
|
|
230
|
+
this.$emit('update:interval', interval);
|
|
209
231
|
},
|
|
210
232
|
},
|
|
211
233
|
maxBindings: {
|
|
@@ -218,8 +240,8 @@ export default {
|
|
|
218
240
|
},
|
|
219
241
|
maxEvents: {
|
|
220
242
|
'update:modelValue': e => {
|
|
221
|
-
this.interval.max
|
|
222
|
-
this
|
|
243
|
+
const interval = { min: this.interval.min, max: e };
|
|
244
|
+
this.$emit('update:interval', interval);
|
|
223
245
|
},
|
|
224
246
|
},
|
|
225
247
|
});
|
|
@@ -47,7 +47,7 @@ export default {
|
|
|
47
47
|
type: this.type,
|
|
48
48
|
},
|
|
49
49
|
minEvents: {
|
|
50
|
-
|
|
50
|
+
input: e => {
|
|
51
51
|
this.modelValue.min = e.target.value;
|
|
52
52
|
this.update();
|
|
53
53
|
},
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
type: this.type,
|
|
58
58
|
},
|
|
59
59
|
maxEvents: {
|
|
60
|
-
|
|
60
|
+
input: e => {
|
|
61
61
|
this.modelValue.max = e.target.value;
|
|
62
62
|
this.update();
|
|
63
63
|
},
|
|
@@ -35,6 +35,7 @@ export default {
|
|
|
35
35
|
defaultParams: null,
|
|
36
36
|
state: null,
|
|
37
37
|
keys: null,
|
|
38
|
+
ready: false,
|
|
38
39
|
}),
|
|
39
40
|
|
|
40
41
|
computed: {
|
|
@@ -61,6 +62,7 @@ export default {
|
|
|
61
62
|
created() {
|
|
62
63
|
this.init();
|
|
63
64
|
this.load();
|
|
65
|
+
this.ready = true;
|
|
64
66
|
},
|
|
65
67
|
|
|
66
68
|
methods: {
|
|
@@ -93,7 +95,9 @@ export default {
|
|
|
93
95
|
});
|
|
94
96
|
},
|
|
95
97
|
persist() {
|
|
96
|
-
|
|
98
|
+
if (this.ready) {
|
|
99
|
+
localStorage.setItem(this.name, JSON.stringify(this.state));
|
|
100
|
+
}
|
|
97
101
|
},
|
|
98
102
|
reset() {
|
|
99
103
|
localStorage.removeItem(this.name);
|
|
@@ -17,7 +17,7 @@ const Intervals = {
|
|
|
17
17
|
|
|
18
18
|
const Base = [
|
|
19
19
|
Intervals.today, Intervals.thisWeek, Intervals.thisMonth,
|
|
20
|
-
Intervals.thisYear, Intervals.
|
|
20
|
+
Intervals.thisYear, Intervals.all, Intervals.custom,
|
|
21
21
|
];
|
|
22
22
|
|
|
23
23
|
const Past = [Intervals.yesterday, Intervals.lastWeek, Intervals.lastMonth, Intervals.lastYear];
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="date-interval-filter is-paddingless">
|
|
3
|
-
<div class="header has-background-light has-text-centered"
|
|
4
|
-
v-if="!compact">
|
|
5
|
-
<strong>
|
|
6
|
-
{{ i18n(name) }}
|
|
7
|
-
</strong>
|
|
8
|
-
</div>
|
|
9
|
-
<div v-tooltip="compact ? i18n(name) : null"
|
|
10
|
-
class="dates-wrapper"
|
|
11
|
-
:class="{ 'has-background-light': compact }">
|
|
12
|
-
<core-date-interval-filter v-bind="$attrs">
|
|
13
|
-
<template #default="{ minBindings, minEvents, maxBindings, maxEvents }">
|
|
14
|
-
<div class="columns is-mobile is-variable is-1 is-centered">
|
|
15
|
-
<div class="column">
|
|
16
|
-
<datepicker v-bind="minBindings"
|
|
17
|
-
:placeholder="i18n(minLabel)"
|
|
18
|
-
:alt-format="altFormat"
|
|
19
|
-
:alt-input="altInput"
|
|
20
|
-
v-on="minEvents"/>
|
|
21
|
-
</div>
|
|
22
|
-
<div class="column">
|
|
23
|
-
<datepicker v-bind="maxBindings"
|
|
24
|
-
:placeholder="i18n(maxLabel)"
|
|
25
|
-
:alt-format="altFormat"
|
|
26
|
-
:alt-input="altInput"
|
|
27
|
-
v-on="maxEvents"/>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
</core-date-interval-filter>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script>
|
|
37
|
-
import 'v-tooltip/dist/v-tooltip.css';
|
|
38
|
-
import { VTooltip } from 'v-tooltip';
|
|
39
|
-
import { Datepicker } from '@enso-ui/datepicker/bulma';
|
|
40
|
-
import CoreDateIntervalFilter from '../renderless/CoreDateIntervalFilter.vue';
|
|
41
|
-
|
|
42
|
-
export default {
|
|
43
|
-
name: 'DateIntervalFilter',
|
|
44
|
-
|
|
45
|
-
directives: { tooltip: VTooltip },
|
|
46
|
-
|
|
47
|
-
components: { CoreDateIntervalFilter, Datepicker },
|
|
48
|
-
|
|
49
|
-
props: {
|
|
50
|
-
altFormat: {
|
|
51
|
-
type: String,
|
|
52
|
-
default: null,
|
|
53
|
-
},
|
|
54
|
-
altInput: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false,
|
|
57
|
-
},
|
|
58
|
-
compact: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: false,
|
|
61
|
-
},
|
|
62
|
-
i18n: {
|
|
63
|
-
type: Function,
|
|
64
|
-
default: v => v,
|
|
65
|
-
},
|
|
66
|
-
maxLabel: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: 'To',
|
|
69
|
-
},
|
|
70
|
-
minLabel: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: 'From',
|
|
73
|
-
},
|
|
74
|
-
name: {
|
|
75
|
-
type: String,
|
|
76
|
-
default: null,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
data: () => ({
|
|
81
|
-
interval: {
|
|
82
|
-
min: null,
|
|
83
|
-
max: null,
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
86
|
-
};
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<style lang="scss">
|
|
90
|
-
.date-interval-filter {
|
|
91
|
-
.header {
|
|
92
|
-
border-top-left-radius: inherit;
|
|
93
|
-
border-top-right-radius: inherit;
|
|
94
|
-
padding-top: 0.5em;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.dates-wrapper {
|
|
98
|
-
border-radius: inherit;
|
|
99
|
-
padding: 0.25em;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
</style>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<enso-date-filter v-bind="$attrs"
|
|
3
|
-
alt-input
|
|
4
|
-
:alt-format="altFormat || meta.dateFormat"
|
|
5
|
-
:i18n="i18n"
|
|
6
|
-
:locale="lang"/>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import { mapState, mapGetters } from 'vuex';
|
|
11
|
-
import EnsoDateFilter from './EnsoDateFilter.vue';
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
name: 'EnsoDateIntervalFilter',
|
|
15
|
-
|
|
16
|
-
components: { EnsoDateFilter },
|
|
17
|
-
|
|
18
|
-
inject: ['i18n'],
|
|
19
|
-
|
|
20
|
-
props: {
|
|
21
|
-
altFormat: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: null,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
computed: {
|
|
28
|
-
...mapState(['meta']),
|
|
29
|
-
...mapGetters('preferences', ['lang']),
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
</script>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import dateIntervals from './dateIntervals';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
name: 'CoreDateIntervalFilter',
|
|
6
|
-
|
|
7
|
-
mixins: [dateIntervals],
|
|
8
|
-
|
|
9
|
-
emits: ['update'],
|
|
10
|
-
|
|
11
|
-
inheritAttrs: false,
|
|
12
|
-
|
|
13
|
-
methods: {
|
|
14
|
-
update() {
|
|
15
|
-
this.$emit('update', this.sanitizedInterval);
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
render() {
|
|
20
|
-
return this.$slots.default({
|
|
21
|
-
minBindings: {
|
|
22
|
-
modelValue: this.interval.min,
|
|
23
|
-
format: this.format,
|
|
24
|
-
isWarning: this.equals,
|
|
25
|
-
locale: this.locale,
|
|
26
|
-
max: this.interval.max,
|
|
27
|
-
},
|
|
28
|
-
minEvents: {
|
|
29
|
-
'update:modelValue': e => {
|
|
30
|
-
this.interval.min = e;
|
|
31
|
-
this.update();
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
maxBindings: {
|
|
35
|
-
modelValue: this.interval.max,
|
|
36
|
-
format: this.format,
|
|
37
|
-
isWarning: this.equals,
|
|
38
|
-
locale: this.locale,
|
|
39
|
-
min: this.interval.min,
|
|
40
|
-
},
|
|
41
|
-
maxEvents: {
|
|
42
|
-
'update:modelValue': e => {
|
|
43
|
-
this.interval.max = e;
|
|
44
|
-
this.update();
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
</script>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { compareAsc, parse } from 'date-fns';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
props: {
|
|
5
|
-
format: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: 'Y-m-d H:i:s',
|
|
8
|
-
},
|
|
9
|
-
interval: {
|
|
10
|
-
type: Object,
|
|
11
|
-
default: () => ({
|
|
12
|
-
min: null,
|
|
13
|
-
max: null,
|
|
14
|
-
}),
|
|
15
|
-
validator: v => Object.keys(v).includes('min')
|
|
16
|
-
&& Object.keys(v).includes('max'),
|
|
17
|
-
},
|
|
18
|
-
locale: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: 'en',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
computed: {
|
|
25
|
-
internalFormat() {
|
|
26
|
-
return this.format.replace('d', 'dd')
|
|
27
|
-
.replace('m', 'MM')
|
|
28
|
-
.replace('Y', 'yyyy')
|
|
29
|
-
.replace('H', 'HH')
|
|
30
|
-
.replace('i', 'mm')
|
|
31
|
-
.replace('s', 'ss');
|
|
32
|
-
},
|
|
33
|
-
sanitizedInterval() {
|
|
34
|
-
return {
|
|
35
|
-
min: this.interval.min || null,
|
|
36
|
-
max: this.interval.max || null,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
parsedMax() {
|
|
40
|
-
return parse(this.interval.max, this.internalFormat, new Date());
|
|
41
|
-
},
|
|
42
|
-
parsedMin() {
|
|
43
|
-
return parse(this.interval.min, this.internalFormat, new Date());
|
|
44
|
-
},
|
|
45
|
-
equals() {
|
|
46
|
-
return !!this.interval.min
|
|
47
|
-
&& !!this.interval.max
|
|
48
|
-
&& compareAsc(this.parsedMin, this.parsedMax) === 0;
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|