@dataloop-ai/components 0.19.128 → 0.19.130
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/package.json
CHANGED
|
@@ -84,6 +84,18 @@
|
|
|
84
84
|
:single-selection="true"
|
|
85
85
|
@change="onDateSelection"
|
|
86
86
|
/>
|
|
87
|
+
<div class="dl-smart-search-input__date-picker-buttons">
|
|
88
|
+
<dl-button
|
|
89
|
+
label="Cancel"
|
|
90
|
+
outlined
|
|
91
|
+
@mousedown="onDateSelectionCancel"
|
|
92
|
+
/>
|
|
93
|
+
<dl-button
|
|
94
|
+
label="Apply"
|
|
95
|
+
:disabled="!datePickerSelection"
|
|
96
|
+
@mousedown="onDateSelectionApply"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
87
99
|
</div>
|
|
88
100
|
</dl-menu>
|
|
89
101
|
</div>
|
|
@@ -118,6 +130,7 @@ import { DateInterval } from '../../../DlDateTime/types'
|
|
|
118
130
|
import {
|
|
119
131
|
isEndingWithDateIntervalPattern,
|
|
120
132
|
replaceDateInterval,
|
|
133
|
+
removeDateInterval,
|
|
121
134
|
updateEditor,
|
|
122
135
|
isEligibleToChange,
|
|
123
136
|
createColorSchema,
|
|
@@ -538,8 +551,27 @@ export default defineComponent({
|
|
|
538
551
|
|
|
539
552
|
const onDateSelection = (value: DateInterval) => {
|
|
540
553
|
datePickerSelection.value = value
|
|
541
|
-
|
|
542
|
-
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const onDateSelectionCancel = () => {
|
|
557
|
+
searchQuery.value = removeDateInterval(searchQuery.value)
|
|
558
|
+
showDatePicker.value = false
|
|
559
|
+
showSuggestions.value = true
|
|
560
|
+
datePickerSelection.value = null
|
|
561
|
+
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
562
|
+
setCaretAtTheEnd(input.value)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
const onDateSelectionApply = () => {
|
|
566
|
+
searchQuery.value = replaceDateInterval(
|
|
567
|
+
searchQuery.value,
|
|
568
|
+
datePickerSelection.value
|
|
569
|
+
)
|
|
570
|
+
showDatePicker.value = false
|
|
571
|
+
showSuggestions.value = true
|
|
572
|
+
datePickerSelection.value = null
|
|
573
|
+
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
574
|
+
setCaretAtTheEnd(input.value)
|
|
543
575
|
}
|
|
544
576
|
|
|
545
577
|
const readModelValue = (val: { [key: string]: any }) => {
|
|
@@ -628,15 +660,6 @@ export default defineComponent({
|
|
|
628
660
|
return
|
|
629
661
|
}
|
|
630
662
|
|
|
631
|
-
if (showDatePicker.value) {
|
|
632
|
-
showDatePicker.value = false
|
|
633
|
-
showSuggestions.value = true
|
|
634
|
-
datePickerSelection.value = null
|
|
635
|
-
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
636
|
-
setCaretAtTheEnd(input.value)
|
|
637
|
-
return
|
|
638
|
-
}
|
|
639
|
-
|
|
640
663
|
if (showSuggestions.value) {
|
|
641
664
|
showSuggestions.value = false
|
|
642
665
|
return
|
|
@@ -897,6 +920,8 @@ export default defineComponent({
|
|
|
897
920
|
onKeyPress,
|
|
898
921
|
onInput,
|
|
899
922
|
onDateSelection,
|
|
923
|
+
onDateSelectionCancel,
|
|
924
|
+
onDateSelectionApply,
|
|
900
925
|
computedStatus,
|
|
901
926
|
setInputFromSuggestion,
|
|
902
927
|
inputPlaceholder,
|
|
@@ -1129,6 +1154,14 @@ export default defineComponent({
|
|
|
1129
1154
|
&__date-picker-wrapper {
|
|
1130
1155
|
width: 562px;
|
|
1131
1156
|
}
|
|
1157
|
+
|
|
1158
|
+
&__date-picker-buttons {
|
|
1159
|
+
padding: 0 16px 16px;
|
|
1160
|
+
text-align: right;
|
|
1161
|
+
> * {
|
|
1162
|
+
margin-left: 16px;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1132
1165
|
}
|
|
1133
1166
|
.focus {
|
|
1134
1167
|
word-break: break-all;
|
|
@@ -47,6 +47,10 @@ export const replaceDateInterval = (str: string, date: DateInterval) => {
|
|
|
47
47
|
return replaced
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export const removeDateInterval = (str: string) => {
|
|
51
|
+
return replaceFirstOrLastOccurrence(str, '', datePattern)
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
const formatDate = (date: Date | string | number): string => {
|
|
51
55
|
return moment(date).format('DD/MM/YYYY')
|
|
52
56
|
}
|
|
@@ -85,7 +85,7 @@ export const parseSmartQuery = (
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const andQuery: { [key: string]: any } =
|
|
88
|
+
const andQuery: { [key: string]: any }[] = []
|
|
89
89
|
let queryValue: any
|
|
90
90
|
|
|
91
91
|
let key: string
|
|
@@ -106,42 +106,42 @@ export const parseSmartQuery = (
|
|
|
106
106
|
[key, value] = term.split('>=').map((x) => x.trim())
|
|
107
107
|
pureValue = GeneratePureValue(value)
|
|
108
108
|
if (pureValue !== null) {
|
|
109
|
-
andQuery[key]
|
|
109
|
+
andQuery.push({ [key]: { $gte: pureValue } })
|
|
110
110
|
}
|
|
111
111
|
break
|
|
112
112
|
case term.includes('<='):
|
|
113
113
|
[key, value] = term.split('<=').map((x) => x.trim())
|
|
114
114
|
pureValue = GeneratePureValue(value)
|
|
115
115
|
if (pureValue !== null) {
|
|
116
|
-
andQuery[key]
|
|
116
|
+
andQuery.push({ [key]: { $lte: pureValue } })
|
|
117
117
|
}
|
|
118
118
|
break
|
|
119
119
|
case term.includes('>'):
|
|
120
120
|
[key, value] = term.split('>').map((x) => x.trim())
|
|
121
121
|
pureValue = GeneratePureValue(value)
|
|
122
122
|
if (pureValue !== null) {
|
|
123
|
-
andQuery[key]
|
|
123
|
+
andQuery.push({ [key]: { $gt: pureValue } })
|
|
124
124
|
}
|
|
125
125
|
break
|
|
126
126
|
case term.includes('<'):
|
|
127
127
|
[key, value] = term.split('<').map((x) => x.trim())
|
|
128
128
|
pureValue = GeneratePureValue(value)
|
|
129
129
|
if (pureValue !== null) {
|
|
130
|
-
andQuery[key]
|
|
130
|
+
andQuery.push({ [key]: { $lt: pureValue } })
|
|
131
131
|
}
|
|
132
132
|
break
|
|
133
133
|
case term.includes('!='):
|
|
134
134
|
[key, value] = term.split('!=').map((x) => x.trim())
|
|
135
135
|
pureValue = GeneratePureValue(value)
|
|
136
136
|
if (pureValue !== null) {
|
|
137
|
-
andQuery[key]
|
|
137
|
+
andQuery.push({ [key]: { $ne: pureValue } })
|
|
138
138
|
}
|
|
139
139
|
break
|
|
140
140
|
case term.includes('='):
|
|
141
141
|
[key, value] = term.split('=').map((x) => x.trim())
|
|
142
142
|
pureValue = GeneratePureValue(value)
|
|
143
143
|
if (pureValue !== null) {
|
|
144
|
-
andQuery[key]
|
|
144
|
+
andQuery.push({ [key]: pureValue })
|
|
145
145
|
}
|
|
146
146
|
break
|
|
147
147
|
case term.includes('IN'):
|
|
@@ -159,7 +159,7 @@ export const parseSmartQuery = (
|
|
|
159
159
|
|
|
160
160
|
pureValue = GeneratePureValue(queryValue)
|
|
161
161
|
if (pureValue !== null && Array.isArray(pureValue)) {
|
|
162
|
-
andQuery[key]
|
|
162
|
+
andQuery.push({ [key]: { $nin: pureValue } })
|
|
163
163
|
}
|
|
164
164
|
} else {
|
|
165
165
|
queryValue = term
|
|
@@ -171,14 +171,24 @@ export const parseSmartQuery = (
|
|
|
171
171
|
|
|
172
172
|
pureValue = GeneratePureValue(queryValue)
|
|
173
173
|
if (pureValue !== null && Array.isArray(pureValue)) {
|
|
174
|
-
andQuery[key]
|
|
174
|
+
andQuery.push({ [key]: { $in: pureValue } })
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
break
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
const simlifiedAndQuery: { [key: string]: any } = {}
|
|
182
|
+
for (const term of andQuery) {
|
|
183
|
+
const key = Object.keys(term)[0]
|
|
184
|
+
simlifiedAndQuery[key] = term[key]
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
orTerms.push(
|
|
188
|
+
andQuery.length > Object.keys(simlifiedAndQuery).length
|
|
189
|
+
? { $and: andQuery }
|
|
190
|
+
: simlifiedAndQuery
|
|
191
|
+
)
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
const builtQuery = orTerms.length > 1 ? { $or: orTerms } : orTerms[0]
|
|
@@ -211,14 +221,13 @@ export const stringifySmartQuery = (query: { [key: string]: any }): string => {
|
|
|
211
221
|
|
|
212
222
|
if (key === '$and') {
|
|
213
223
|
if (Array.isArray(value)) {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
return stringifySmartQuery(andObject)
|
|
224
|
+
const subQueries = value.map(
|
|
225
|
+
(subQuery: { [key: string]: any }) =>
|
|
226
|
+
stringifySmartQuery(subQuery)
|
|
227
|
+
)
|
|
228
|
+
result += subQueries.join(' AND ')
|
|
221
229
|
}
|
|
230
|
+
continue
|
|
222
231
|
}
|
|
223
232
|
|
|
224
233
|
if (result.length) {
|