@dataloop-ai/components 0.16.62 → 0.17.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.
- package/package.json +1 -1
- package/src/components/basic/DlAlert/DlAlert.vue +7 -8
- package/src/components/basic/DlButton/DlButton.vue +33 -11
- package/src/components/basic/DlButton/utils.ts +12 -2
- package/src/components/basic/DlChip/DlChip.vue +1 -8
- package/src/components/basic/DlPanelContainer/DlPanelContainer.vue +5 -5
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/utils.ts +6 -2
- package/src/components/compound/DlDialogBox/DlDialogBox.vue +3 -3
- package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +21 -15
- package/src/components/compound/DlDropdownButton/components/ButtonGroup.vue +11 -9
- package/src/components/compound/DlInput/DlInput.vue +7 -7
- package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +14 -14
- package/src/components/compound/DlPagination/components/PageNavigation.vue +21 -21
- package/src/components/compound/DlRange/DlRange.vue +1 -1
- package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +3 -3
- package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +132 -42
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchFilters.vue +75 -0
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +183 -173
- package/src/components/compound/DlSearches/DlSmartSearch/components/FiltersQuery.vue +101 -0
- package/src/components/compound/DlSearches/DlSmartSearch/types.ts +4 -4
- package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +9 -4
- package/src/components/compound/DlSearches/DlSmartSearch/utils/utils.ts +18 -1
- package/src/components/compound/DlSelect/DlSelect.vue +3 -4
- package/src/components/compound/DlSlider/DlSlider.vue +1 -1
- package/src/components/compound/DlStepper/DlStepper.vue +2 -2
- package/src/components/compound/DlStepper/components/DlStepperFooter.vue +3 -3
- package/src/components/compound/DlStepper/components/DlStepperHeader.vue +2 -2
- package/src/components/compound/DlTabs/components/TabsWrapper.vue +1 -1
- package/src/components/compound/DlToggleButton/DlToggleButton.vue +14 -11
- package/src/components/essential/DlIcon/DlIcon.vue +1 -1
- package/src/components/essential/DlSpinner/styles/spinnerStyles.scss +1 -1
- package/src/components/essential/DlTypography/DlTypography.vue +18 -2
- package/src/components/shared/types.ts +7 -1
- package/src/demos/DlAlertDemo.vue +17 -3
- package/src/demos/DlDialogBoxDemo.vue +15 -1
- package/src/demos/DlDropdownButtonDemo.vue +4 -4
- package/src/demos/DlSearchDemo.vue +1 -1
- package/src/demos/DlStepperDemo/SimpleStepper.vue +1 -1
- package/src/demos/DlStepperDemo/steps/DataStep.vue +1 -1
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +40 -75
- package/src/hooks/use-suggestions.ts +8 -3
- package/src/utils/parse-smart-query.ts +109 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { SyntaxColorSchema } from '../types'
|
|
2
2
|
|
|
3
|
+
const SPAN_STYLES = `overflow: hidden;
|
|
4
|
+
text-overflow: ellipsis;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
max-width: 100%`
|
|
7
|
+
|
|
3
8
|
let editor = document.getElementById('editor')
|
|
4
9
|
let styleModel: SyntaxColorSchema
|
|
5
10
|
|
|
@@ -90,13 +95,13 @@ function renderText(text: string) {
|
|
|
90
95
|
const words = text?.split(/(\s+)/)
|
|
91
96
|
const output = words?.map((word) => {
|
|
92
97
|
if (styleModel.keywords.values.includes(word)) {
|
|
93
|
-
return `<strong>${word}</strong>`
|
|
98
|
+
return `<strong style='${SPAN_STYLES}'>${word}</strong>`
|
|
94
99
|
} else if (styleModel.fields.values.includes(word)) {
|
|
95
|
-
return `<span style='color:${styleModel.fields.color}'>${word}</span>`
|
|
100
|
+
return `<span style='color:${styleModel.fields.color}; ${SPAN_STYLES}'>${word}</span>`
|
|
96
101
|
} else if (styleModel.operators.values.includes(word)) {
|
|
97
|
-
return `<span style='color:${styleModel.operators.color}'>${word}</span>`
|
|
102
|
+
return `<span style='color:${styleModel.operators.color}; ${SPAN_STYLES}'>${word}</span>`
|
|
98
103
|
} else {
|
|
99
|
-
return `<span>${word}</span>`
|
|
104
|
+
return `<span style='${SPAN_STYLES}'>${word}</span>`
|
|
100
105
|
}
|
|
101
106
|
})
|
|
102
107
|
return output?.join('')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorSchema, SyntaxColorSchema } from '../types'
|
|
1
|
+
import { ColorSchema, SyntaxColorSchema, Filters } from '../types'
|
|
2
2
|
import {
|
|
3
3
|
operators,
|
|
4
4
|
Alias,
|
|
@@ -7,6 +7,23 @@ import {
|
|
|
7
7
|
dateIntervalPattern
|
|
8
8
|
} from '../../../../../hooks/use-suggestions'
|
|
9
9
|
|
|
10
|
+
export function getTabItems(filters: Filters) {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
label: `Saved DQL Queries (${filters.saved.length})`,
|
|
14
|
+
name: 'saved'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: `Recent Searches (${filters.recent.length})`,
|
|
18
|
+
name: 'recent'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: `Suggested Searches (${filters.suggested.length})`,
|
|
22
|
+
name: 'suggested'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
|
|
10
27
|
export function replaceWithJsDates(str: string) {
|
|
11
28
|
const intervals = str.match(dateIntervalPattern)
|
|
12
29
|
const starts = str.match(startDatePattern)
|
|
@@ -326,8 +326,7 @@ export default defineComponent({
|
|
|
326
326
|
validator: optionsValidator
|
|
327
327
|
},
|
|
328
328
|
capitalizedOptions: { type: Boolean, default: false },
|
|
329
|
-
|
|
330
|
-
disableDropdownIconPadding: { type: Boolean, default: false },
|
|
329
|
+
withoutDropdownIconPadding: { type: Boolean, default: false },
|
|
331
330
|
clearButtonTooltip: { type: Boolean, default: false },
|
|
332
331
|
dropdownMaxHeight: { type: String, default: '30vh' },
|
|
333
332
|
preserveSearch: { type: Boolean, default: false }
|
|
@@ -513,7 +512,7 @@ export default defineComponent({
|
|
|
513
512
|
classes.push(`dl_select__select--${this.size}`)
|
|
514
513
|
classes.push('dl_select__select--append')
|
|
515
514
|
|
|
516
|
-
if (this.
|
|
515
|
+
if (this.withoutDropdownIconPadding) {
|
|
517
516
|
classes.push('dl_select__select--append-without_padding')
|
|
518
517
|
}
|
|
519
518
|
if (this.selectedIndex !== -1) {
|
|
@@ -547,7 +546,7 @@ export default defineComponent({
|
|
|
547
546
|
cssVars(): Record<string, string> {
|
|
548
547
|
return {
|
|
549
548
|
'--dl-select-width': this.width,
|
|
550
|
-
'--dl-select-expand-icon-width': this.
|
|
549
|
+
'--dl-select-expand-icon-width': this.withoutDropdownIconPadding
|
|
551
550
|
? '16px'
|
|
552
551
|
: '28px'
|
|
553
552
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
>
|
|
10
10
|
<dl-stepper-header
|
|
11
11
|
:header-title="headerTitle"
|
|
12
|
-
:hide-close-
|
|
12
|
+
:hide-close-button="hideCloseButton"
|
|
13
13
|
@close="closeStepper"
|
|
14
14
|
/>
|
|
15
15
|
<div class="dl-stepper-content">
|
|
@@ -131,7 +131,7 @@ export default defineComponent({
|
|
|
131
131
|
disabledNextStep: Boolean,
|
|
132
132
|
disabledPrevStep: Boolean,
|
|
133
133
|
isDone: Boolean,
|
|
134
|
-
|
|
134
|
+
hideCloseButton: Boolean,
|
|
135
135
|
sidebarNavigation: { type: Boolean, default: true }
|
|
136
136
|
},
|
|
137
137
|
emits: ['update:modelValue', 'done', 'next', 'prev', 'set-step', 'close'],
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<dl-button
|
|
6
6
|
:disabled="disabledPrevStep"
|
|
7
7
|
outlined
|
|
8
|
-
:colors-object="
|
|
8
|
+
:colors-object="prevButtonColorsObject"
|
|
9
9
|
:label="prevLabel"
|
|
10
10
|
@click="$emit('prev')"
|
|
11
11
|
/>
|
|
@@ -60,10 +60,10 @@ export default defineComponent({
|
|
|
60
60
|
},
|
|
61
61
|
emits: ['close', 'done', 'next', 'prev'],
|
|
62
62
|
data(): {
|
|
63
|
-
|
|
63
|
+
prevButtonColorsObject: ButtonColors
|
|
64
64
|
} {
|
|
65
65
|
return {
|
|
66
|
-
|
|
66
|
+
prevButtonColorsObject: {
|
|
67
67
|
[ButtonState.Active]: {
|
|
68
68
|
[ButtonPart.Text]: 'var(--dl-color-darker)',
|
|
69
69
|
[ButtonPart.Background]: 'var(--dl-color-transparent)',
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</dl-typography>
|
|
10
10
|
</slot>
|
|
11
11
|
<dl-button
|
|
12
|
-
v-if="!
|
|
12
|
+
v-if="!hideCloseButton"
|
|
13
13
|
text-color="dl-color-darker"
|
|
14
14
|
flat
|
|
15
15
|
icon="icon-dl-close"
|
|
@@ -34,7 +34,7 @@ export default defineComponent({
|
|
|
34
34
|
required: false,
|
|
35
35
|
default: ''
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
hideCloseButton: Boolean
|
|
38
38
|
},
|
|
39
39
|
emits: ['close']
|
|
40
40
|
})
|
|
@@ -4,26 +4,29 @@
|
|
|
4
4
|
class="container"
|
|
5
5
|
>
|
|
6
6
|
<dl-button
|
|
7
|
-
v-for="(
|
|
7
|
+
v-for="(button, idx) in toggleButtons"
|
|
8
8
|
:key="idx"
|
|
9
9
|
:styles="
|
|
10
|
-
getStyles(
|
|
10
|
+
getStyles(
|
|
11
|
+
button.value === scopedValue,
|
|
12
|
+
hoverButton === button.value
|
|
13
|
+
)
|
|
11
14
|
"
|
|
12
15
|
data-test="button"
|
|
13
16
|
fluid
|
|
14
|
-
@mouseenter="
|
|
15
|
-
@mouseleave="
|
|
16
|
-
@click="value =
|
|
17
|
+
@mouseenter="hoverButton = button.value"
|
|
18
|
+
@mouseleave="hoverButton = null"
|
|
19
|
+
@click="value = button.value"
|
|
17
20
|
>
|
|
18
21
|
<span v-if="!$slots.button && !$slots[`button-${idx}`]">
|
|
19
|
-
{{
|
|
22
|
+
{{ button.label }}
|
|
20
23
|
</span>
|
|
21
24
|
<slot
|
|
22
|
-
:label="
|
|
25
|
+
:label="button.label"
|
|
23
26
|
:name="`button-${idx}`"
|
|
24
27
|
/>
|
|
25
28
|
<slot
|
|
26
|
-
:label="
|
|
29
|
+
:label="button.label"
|
|
27
30
|
name="button"
|
|
28
31
|
/>
|
|
29
32
|
</dl-button>
|
|
@@ -60,7 +63,7 @@ export default defineComponent({
|
|
|
60
63
|
emits: ['update:modelValue', 'change'],
|
|
61
64
|
data: () => ({
|
|
62
65
|
scopedValue: null as string | number,
|
|
63
|
-
|
|
66
|
+
hoverButton: null as string | number
|
|
64
67
|
}),
|
|
65
68
|
computed: {
|
|
66
69
|
value: {
|
|
@@ -87,8 +90,8 @@ export default defineComponent({
|
|
|
87
90
|
this.scopedValue = this.value
|
|
88
91
|
},
|
|
89
92
|
methods: {
|
|
90
|
-
getStyles(
|
|
91
|
-
if (
|
|
93
|
+
getStyles(activeButton: boolean, hovered: boolean) {
|
|
94
|
+
if (activeButton) {
|
|
92
95
|
return ButtonsStyles.activeStyles
|
|
93
96
|
} else if (hovered) {
|
|
94
97
|
return ButtonsStyles.hoverStyles
|
|
@@ -101,7 +101,7 @@ export default defineComponent({
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
inlineStyles(): Record<string, string> {
|
|
104
|
-
return { display: this.inline ? 'inline' : 'flex
|
|
104
|
+
return { display: this.inline ? 'inline' : 'flex' }
|
|
105
105
|
},
|
|
106
106
|
// needed to allow external source of icons that do not use class based
|
|
107
107
|
externalIcon(): boolean {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { v4 } from 'uuid'
|
|
13
13
|
import { defineComponent, PropType } from 'vue-demi'
|
|
14
14
|
import { getColor } from '../../../utils'
|
|
15
|
+
import { transformOptions } from '../../shared/types'
|
|
15
16
|
|
|
16
17
|
type Variant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p'
|
|
17
18
|
|
|
@@ -30,7 +31,12 @@ export default defineComponent({
|
|
|
30
31
|
required: false,
|
|
31
32
|
default: null
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
+
transform: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: 'default',
|
|
37
|
+
validator: (value: string): boolean =>
|
|
38
|
+
transformOptions.includes(value)
|
|
39
|
+
},
|
|
34
40
|
bold: Boolean,
|
|
35
41
|
color: {
|
|
36
42
|
type: String,
|
|
@@ -46,7 +52,7 @@ export default defineComponent({
|
|
|
46
52
|
styles(): Record<string, string | number> {
|
|
47
53
|
const styles: Record<string, string | number> = {
|
|
48
54
|
color: getColor(this.color as string, 'dl-color-darker'),
|
|
49
|
-
textTransform: this.
|
|
55
|
+
textTransform: this.letterClass ? null : this.transform,
|
|
50
56
|
fontWeight: this.bold ? 'bold' : 400
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -56,6 +62,12 @@ export default defineComponent({
|
|
|
56
62
|
|
|
57
63
|
return styles
|
|
58
64
|
},
|
|
65
|
+
letterClass(): string {
|
|
66
|
+
if (this.transform === 'default') {
|
|
67
|
+
return 'first-letter-capitalized'
|
|
68
|
+
}
|
|
69
|
+
return null
|
|
70
|
+
},
|
|
59
71
|
classes(): string[] {
|
|
60
72
|
const classes = [`dl-typography`]
|
|
61
73
|
|
|
@@ -71,6 +83,10 @@ export default defineComponent({
|
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
|
|
86
|
+
if (this.letterClass) {
|
|
87
|
+
classes.push(this.letterClass)
|
|
88
|
+
}
|
|
89
|
+
|
|
74
90
|
return classes
|
|
75
91
|
}
|
|
76
92
|
}
|
|
@@ -39,10 +39,23 @@
|
|
|
39
39
|
>
|
|
40
40
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
|
41
41
|
</DlAlert>
|
|
42
|
+
<dl-alert
|
|
43
|
+
style="margin-top: 20px"
|
|
44
|
+
fluid
|
|
45
|
+
type="warning"
|
|
46
|
+
>
|
|
47
|
+
this is an annoying message with link, this is an annoying message
|
|
48
|
+
with linkthis is an annoying message with linkthis is an annoying
|
|
49
|
+
message with linkthis is an annoying message with linkthis is an
|
|
50
|
+
annoying message with linkthis is an annoying message with linkthis
|
|
51
|
+
is an annoying message with link
|
|
52
|
+
<span>
|
|
53
|
+
Please
|
|
54
|
+
<dl-link color="dl-color-link">Contact us</dl-link>.</span>
|
|
55
|
+
</dl-alert>
|
|
42
56
|
<DlAlert
|
|
43
57
|
type="success"
|
|
44
58
|
text="Text: Lorem ipsum dolor sit amet, consectetur adipisicing elit. "
|
|
45
|
-
:closable="true"
|
|
46
59
|
>
|
|
47
60
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
|
48
61
|
</DlAlert>
|
|
@@ -50,13 +63,14 @@
|
|
|
50
63
|
</template>
|
|
51
64
|
|
|
52
65
|
<script lang="ts">
|
|
53
|
-
import { DlAlert } from '../components'
|
|
66
|
+
import { DlAlert, DlLink } from '../components'
|
|
54
67
|
import { defineComponent } from 'vue-demi'
|
|
55
68
|
|
|
56
69
|
export default defineComponent({
|
|
57
70
|
name: 'DlAlertDemo',
|
|
58
71
|
components: {
|
|
59
|
-
DlAlert
|
|
72
|
+
DlAlert,
|
|
73
|
+
DlLink
|
|
60
74
|
},
|
|
61
75
|
template: 'dl-alert-demo'
|
|
62
76
|
})
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
v-model="draggable"
|
|
5
5
|
left-label="Draggable"
|
|
6
6
|
/>
|
|
7
|
+
<dl-switch
|
|
8
|
+
v-model="fullscreen"
|
|
9
|
+
left-label="Full screen"
|
|
10
|
+
/>
|
|
11
|
+
<dl-switch
|
|
12
|
+
v-model="fullHeight"
|
|
13
|
+
left-label="Full height"
|
|
14
|
+
/>
|
|
7
15
|
<dl-button @click="openModal">
|
|
8
16
|
Open modal
|
|
9
17
|
</dl-button>
|
|
@@ -11,6 +19,8 @@
|
|
|
11
19
|
ref="modalOne"
|
|
12
20
|
v-model="isOpenedFirstModal"
|
|
13
21
|
:draggable="draggable"
|
|
22
|
+
:full-height="fullHeight"
|
|
23
|
+
:fullscreen="fullscreen"
|
|
14
24
|
>
|
|
15
25
|
<template #header>
|
|
16
26
|
<dl-dialog-box-header
|
|
@@ -136,6 +146,8 @@ export default defineComponent({
|
|
|
136
146
|
const modalOne = ref<any>(null)
|
|
137
147
|
const modalTwo = ref<any>(null)
|
|
138
148
|
const draggable = ref(true)
|
|
149
|
+
const fullscreen = ref(false)
|
|
150
|
+
const fullHeight = ref(false)
|
|
139
151
|
const isOpenedFirstModal = ref(false)
|
|
140
152
|
|
|
141
153
|
const openModal = () => {
|
|
@@ -178,7 +190,9 @@ export default defineComponent({
|
|
|
178
190
|
modalOne,
|
|
179
191
|
modalTwo,
|
|
180
192
|
isOpenedFirstModal,
|
|
181
|
-
draggable
|
|
193
|
+
draggable,
|
|
194
|
+
fullscreen,
|
|
195
|
+
fullHeight
|
|
182
196
|
}
|
|
183
197
|
}
|
|
184
198
|
})
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
auto-close
|
|
70
70
|
split
|
|
71
71
|
:label="name"
|
|
72
|
-
main-
|
|
72
|
+
main-button-style="width: 120px"
|
|
73
73
|
@click="onClick"
|
|
74
74
|
>
|
|
75
75
|
<dl-list>
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
auto-close
|
|
199
199
|
:model-value="showing"
|
|
200
200
|
:label="name"
|
|
201
|
-
main-
|
|
201
|
+
main-button-style="width: 150px;"
|
|
202
202
|
@show="onOpen"
|
|
203
203
|
>
|
|
204
204
|
<dl-list>
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
auto-close
|
|
240
240
|
:model-value="showing"
|
|
241
241
|
label="Ellipsis for very long text"
|
|
242
|
-
main-
|
|
242
|
+
main-button-style="width: 150px;"
|
|
243
243
|
:overflow="true"
|
|
244
244
|
:no-wrap="true"
|
|
245
245
|
tooltip="Tooltip message"
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
auto-close
|
|
289
289
|
:model-value="showing"
|
|
290
290
|
:label="arrowNavigationLabel"
|
|
291
|
-
main-
|
|
291
|
+
main-button-style="width: 150px;"
|
|
292
292
|
:overflow="true"
|
|
293
293
|
:no-wrap="true"
|
|
294
294
|
tooltip="Tooltip message"
|
|
@@ -41,100 +41,65 @@ export default defineComponent({
|
|
|
41
41
|
DlSmartSearch,
|
|
42
42
|
DlCheckbox
|
|
43
43
|
},
|
|
44
|
-
setup() {
|
|
45
|
-
return { aliases, schema }
|
|
46
|
-
},
|
|
47
44
|
data() {
|
|
48
45
|
return {
|
|
46
|
+
schema,
|
|
47
|
+
aliases,
|
|
49
48
|
switchState: false,
|
|
50
49
|
isLoading: false,
|
|
51
|
-
filters:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
label: 'Recent Searches',
|
|
79
|
-
name: 'recent',
|
|
80
|
-
queries: [
|
|
81
|
-
{
|
|
82
|
-
name: 'Query 4',
|
|
83
|
-
query: ''
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'Query 5',
|
|
87
|
-
query: ''
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'Query 6',
|
|
91
|
-
query: ''
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
label: 'Suggested Searches',
|
|
97
|
-
name: 'suggested',
|
|
98
|
-
queries: [
|
|
99
|
-
{
|
|
100
|
-
name: 'Query 7',
|
|
101
|
-
query: ''
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: 'Query 8',
|
|
105
|
-
query: ''
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'Query 9',
|
|
109
|
-
query: ''
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
]
|
|
50
|
+
filters: {
|
|
51
|
+
saved: [
|
|
52
|
+
{
|
|
53
|
+
name: 'Query 1',
|
|
54
|
+
query: '{"q": 1}'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'Query 2',
|
|
58
|
+
query: '{"query2": "query2"}'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Query 3',
|
|
62
|
+
query: '{"query3": "query3"}'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'Query 4',
|
|
66
|
+
query: '{"age": 12, "name": "john"}'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
recent: [],
|
|
70
|
+
suggested: []
|
|
71
|
+
} as { [key: string]: Query[] }
|
|
114
72
|
}
|
|
115
73
|
},
|
|
116
74
|
methods: {
|
|
117
|
-
handleSearchQuery(
|
|
75
|
+
handleSearchQuery(query: Query, queryString: string) {
|
|
118
76
|
this.isLoading = true
|
|
119
|
-
console.log(`Searching for: ${query}...`)
|
|
77
|
+
console.log(`Searching for: ${query.query}...`)
|
|
120
78
|
const search = setTimeout(() => {
|
|
121
|
-
console.log(`Results: ${query}`)
|
|
79
|
+
console.log(`Results: ${query.query}`)
|
|
122
80
|
this.isLoading = false
|
|
123
81
|
}, 2000)
|
|
82
|
+
|
|
83
|
+
if (this.filters.recent[-1]?.name !== queryString) {
|
|
84
|
+
this.filters.recent.push({
|
|
85
|
+
name: queryString || query.name,
|
|
86
|
+
query: query.query
|
|
87
|
+
})
|
|
88
|
+
}
|
|
124
89
|
},
|
|
125
|
-
handleSaveQuery(query: Query) {
|
|
126
|
-
const saveQueryIndex = this.filters[
|
|
90
|
+
handleSaveQuery(query: Query, type: string) {
|
|
91
|
+
const saveQueryIndex = this.filters[type].findIndex(
|
|
127
92
|
(q: Query) => q.name === query.name || q.query === query.query
|
|
128
93
|
)
|
|
129
94
|
if (saveQueryIndex !== -1) {
|
|
130
|
-
this.filters[
|
|
95
|
+
this.filters[type][saveQueryIndex] = query
|
|
131
96
|
} else {
|
|
132
|
-
this.filters[
|
|
97
|
+
this.filters[type].push(query)
|
|
133
98
|
}
|
|
134
99
|
},
|
|
135
100
|
|
|
136
|
-
handleRemoveQuery(query: Query) {
|
|
137
|
-
this.filters[
|
|
101
|
+
handleRemoveQuery(query: Query, type: string) {
|
|
102
|
+
this.filters[type] = this.filters[type].filter(
|
|
138
103
|
(q: Query) => q.name !== query.name
|
|
139
104
|
)
|
|
140
105
|
}
|
|
@@ -213,6 +213,7 @@ const getError = (
|
|
|
213
213
|
return expressions
|
|
214
214
|
.filter(({ field, value }) => field !== null && value !== null)
|
|
215
215
|
.reduce<string | null>((acc, { field, value, operator }, _, arr) => {
|
|
216
|
+
if (acc === 'warning') return acc
|
|
216
217
|
const aliasObj = getAliasObjByAlias(aliases, field)
|
|
217
218
|
if (!aliasObj) return 'warning'
|
|
218
219
|
const valid = isValidByDataType(
|
|
@@ -276,9 +277,9 @@ const isValidBoolean = (str: string) => {
|
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
const isValidString = (str: string) => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
)
|
|
280
|
+
const match = str.match(/(?<=\")(.*?)(?=\")|(?<=\')(.*?)(?=\')/)
|
|
281
|
+
if (!match) return false
|
|
282
|
+
return match[0] === removeQuotes(str)
|
|
282
283
|
}
|
|
283
284
|
|
|
284
285
|
const getOperatorByDataType = (dataType: string) => {
|
|
@@ -376,3 +377,7 @@ const matchStringEnd = (input: string, str: string) =>
|
|
|
376
377
|
export const removeBrackets = (str: string) => {
|
|
377
378
|
return str.replace(/\(/g, '').replace(/\)/g, '')
|
|
378
379
|
}
|
|
380
|
+
|
|
381
|
+
const removeQuotes = (str: string) => {
|
|
382
|
+
return str.replaceAll('"', '').replaceAll("'", '')
|
|
383
|
+
}
|