@eturnity/eturnity_reusable_components 7.24.3-EPDM-11320.0 → 7.24.3-EPDM-11143.1
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/.prettierrc +7 -0
- package/package.json +20 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/App.vue +70 -75
- package/src/assets/svgIcons/copy.svg +10 -0
- package/src/components/addNewButton/index.vue +27 -24
- package/src/components/banner/actionBanner/index.vue +30 -32
- package/src/components/banner/banner/index.vue +80 -88
- package/src/components/banner/infoBanner/index.vue +44 -36
- package/src/components/buttons/buttonIcon/index.vue +78 -83
- package/src/components/buttons/closeButton/index.vue +26 -26
- package/src/components/buttons/mainButton/index.vue +76 -80
- package/src/components/card/index.vue +52 -56
- package/src/components/collapsableInfoText/index.vue +76 -81
- package/src/components/deleteIcon/index.vue +28 -31
- package/src/components/draggableInputHandle/index.vue +17 -20
- package/src/components/dropdown/Dropdown.stories.js +8 -8
- package/src/components/dropdown/index.vue +72 -75
- package/src/components/errorMessage/index.vue +23 -23
- package/src/components/filter/filterSettings.vue +329 -349
- package/src/components/filter/index.vue +130 -130
- package/src/components/filter/parentDropdown.vue +40 -43
- package/src/components/icon/Icons.stories.js +4 -4
- package/src/components/icon/iconCache.js +1 -1
- package/src/components/icon/iconCollection.vue +37 -40
- package/src/components/icon/index.vue +65 -72
- package/src/components/iconWrapper/index.vue +118 -122
- package/src/components/infoCard/index.vue +17 -20
- package/src/components/infoText/index.vue +82 -88
- package/src/components/inputs/checkbox/index.vue +94 -91
- package/src/components/inputs/inputNumber/index.vue +488 -508
- package/src/components/inputs/inputNumberQuestion/index.vue +124 -127
- package/src/components/inputs/inputText/index.vue +252 -265
- package/src/components/inputs/radioButton/index.vue +120 -135
- package/src/components/inputs/searchInput/index.vue +81 -84
- package/src/components/inputs/select/index.vue +631 -644
- package/src/components/inputs/select/option/index.vue +91 -91
- package/src/components/inputs/select/select.stories.js +7 -7
- package/src/components/inputs/slider/index.vue +46 -46
- package/src/components/inputs/switchField/index.vue +152 -159
- package/src/components/inputs/textAreaInput/index.vue +113 -120
- package/src/components/inputs/toggle/index.vue +127 -137
- package/src/components/label/index.vue +61 -64
- package/src/components/markerItem/index.vue +40 -40
- package/src/components/modals/actionModal/index.vue +29 -32
- package/src/components/modals/infoModal/index.vue +27 -34
- package/src/components/modals/modal/index.vue +80 -88
- package/src/components/navigationTabs/index.vue +47 -50
- package/src/components/pageSubtitle/index.vue +29 -33
- package/src/components/pageTitle/index.vue +39 -47
- package/src/components/pagination/index.vue +62 -64
- package/src/components/progressBar/index.vue +67 -70
- package/src/components/projectMarker/index.vue +163 -172
- package/src/components/rangeSlider/Slider.vue +449 -449
- package/src/components/rangeSlider/index.vue +270 -282
- package/src/components/rangeSlider/utils/dom.js +3 -3
- package/src/components/selectedOptions/index.vue +51 -51
- package/src/components/sideMenu/index.vue +109 -117
- package/src/components/spinner/index.vue +34 -37
- package/src/components/tableDropdown/index.vue +326 -343
- package/src/components/tables/mainTable/index.vue +106 -109
- package/src/components/tables/viewTable/index.vue +92 -105
- package/src/components/threeDots/index.vue +171 -174
- package/src/components/videoThumbnail/index.vue +59 -67
- package/src/components/videoThumbnail/videoThumbnail.stories.js +6 -6
- package/.eslintrc.js +0 -125
@@ -1,176 +1,159 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<dropdown-row
|
3
3
|
:colspan="colSpan"
|
4
|
-
:
|
5
|
-
:is-open="isOpen"
|
4
|
+
:isOpen="isOpen"
|
6
5
|
@click="toggleOpen"
|
6
|
+
:disabled="disabled"
|
7
7
|
>
|
8
|
-
<
|
9
|
-
|
10
|
-
:col-span="colSpan - 1"
|
11
|
-
>
|
12
|
-
<ComponentItem
|
8
|
+
<component-container :colSpan="colSpan - 1" class="table-dropdown">
|
9
|
+
<component-item
|
13
10
|
v-for="(item, index) in tableItems"
|
14
11
|
:key="index"
|
15
12
|
ref="dropdownItem"
|
13
|
+
:isNested="isNested"
|
16
14
|
:class="{
|
17
15
|
'table-dropdown-item': item.type !== 'input'
|
18
16
|
}"
|
19
|
-
:is-nested="isNested"
|
20
17
|
>
|
21
|
-
<
|
22
|
-
<
|
18
|
+
<nested-container :isNested="isNested">
|
19
|
+
<nested-icon
|
23
20
|
v-if="
|
24
21
|
isNested &&
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
(item.type === 'input' ||
|
23
|
+
item.type === 'no-template' ||
|
24
|
+
item.type === 'template')
|
28
25
|
"
|
29
26
|
/>
|
30
|
-
<
|
27
|
+
<template-button
|
28
|
+
@click.stop="onTemplateClick(item.row)"
|
31
29
|
v-if="
|
32
30
|
item.type &&
|
33
|
-
|
34
|
-
|
31
|
+
item.type === 'template' &&
|
32
|
+
(item.value === '' || item.value === '-')
|
35
33
|
"
|
36
34
|
:key="index + '_button'"
|
37
|
-
|
35
|
+
>{{ $gettext('Use template...') }}</template-button
|
38
36
|
>
|
39
|
-
|
40
|
-
</TemplateButton>
|
41
|
-
<TemplateLink
|
37
|
+
<template-link
|
42
38
|
v-else-if="
|
43
39
|
item.type && item.type === 'template' && item.value !== ''
|
44
40
|
"
|
45
41
|
@click.stop="onSelectedTemplateClick(item.row)"
|
46
42
|
>
|
47
43
|
<!-- <img :src="fileIcon" alt="icon" width="12" height="16" /> -->
|
48
|
-
<
|
49
|
-
:color="theme.colors.brightBlue"
|
44
|
+
<icon
|
50
45
|
name="template_icon_not_clickable"
|
46
|
+
:color="theme.colors.brightBlue"
|
51
47
|
size="14px"
|
52
48
|
/>
|
53
49
|
<div>{{ item.value }}</div>
|
54
|
-
</
|
55
|
-
<
|
50
|
+
</template-link>
|
51
|
+
<no-template v-if="item.type && item.type === 'no-template'">
|
56
52
|
{{ $gettext('No main component template') }}
|
57
|
-
</
|
58
|
-
<
|
53
|
+
</no-template>
|
54
|
+
<input-container
|
59
55
|
v-if="item.type === 'input'"
|
60
56
|
@click.stop="onInputClick()"
|
61
57
|
>
|
62
|
-
<
|
58
|
+
<text-container
|
63
59
|
v-if="customInputDisabled"
|
64
60
|
class="input-placeholder"
|
65
61
|
>
|
66
62
|
<span> {{ item.value }}</span>
|
67
|
-
</
|
68
|
-
<
|
63
|
+
</text-container>
|
64
|
+
<input-text
|
69
65
|
v-else
|
70
66
|
class="inputField"
|
71
|
-
:disabled="customInputDisabled"
|
72
|
-
:min-width="item.value.length + 'ch'"
|
73
|
-
:no-border="true"
|
74
67
|
:value="item.value"
|
68
|
+
:noBorder="true"
|
69
|
+
:minWidth="item.value.length + 'ch'"
|
70
|
+
:disabled="customInputDisabled"
|
75
71
|
@input-change="onCustomInputChange($event)"
|
76
72
|
/>
|
77
|
-
</
|
78
|
-
<
|
73
|
+
</input-container>
|
74
|
+
<text-container
|
79
75
|
v-else-if="
|
80
76
|
item.type !== 'input' &&
|
81
|
-
|
82
|
-
|
77
|
+
item.type !== 'no-template' &&
|
78
|
+
item.type !== 'template'
|
83
79
|
"
|
84
80
|
>
|
85
81
|
<span> {{ item.value }}</span>
|
86
|
-
</
|
87
|
-
</
|
88
|
-
</
|
89
|
-
<
|
90
|
-
|
91
|
-
|
92
|
-
>
|
93
|
-
<ArrowWrapper :show-archived="showArchived">
|
94
|
-
<EtPopover
|
82
|
+
</text-container>
|
83
|
+
</nested-container>
|
84
|
+
</component-item>
|
85
|
+
<arrow-container class="arrow-container" :isDisabled="disabled">
|
86
|
+
<arrow-wrapper :showArchived="showArchived">
|
87
|
+
<et-popover
|
95
88
|
v-if="showArchived"
|
96
89
|
button-class="error"
|
97
90
|
:text="
|
98
91
|
$gettext(`Component has been archived and shouldn't be used`)
|
99
92
|
"
|
100
|
-
|
101
|
-
|
102
|
-
<
|
93
|
+
triggerType="hover"
|
94
|
+
></et-popover>
|
95
|
+
<arrow-down
|
96
|
+
@click.stop="toggleOpen"
|
103
97
|
v-if="!isOpen"
|
104
98
|
class="arrow-dropdown"
|
105
|
-
@click.stop="toggleOpen"
|
106
99
|
/>
|
107
|
-
<
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
v-if="isOpen"
|
114
|
-
ref="optionsContainer"
|
115
|
-
>
|
116
|
-
<OptionsWrapper @click.prevent.stop>
|
117
|
-
<SearchContainer @click.prevent.stop>
|
118
|
-
<SearchInput
|
119
|
-
ref="searchInput"
|
120
|
-
:placeholder="$gettext('Keyword') + '...'"
|
100
|
+
<arrow-up @click.stop="toggleOpen" v-else />
|
101
|
+
</arrow-wrapper>
|
102
|
+
<options-container v-if="isOpen" ref="optionsContainer">
|
103
|
+
<options-wrapper @click.prevent.stop>
|
104
|
+
<search-container @click.prevent.stop>
|
105
|
+
<search-input
|
121
106
|
:value="inputText"
|
107
|
+
:placeholder="$gettext('Keyword') + '...'"
|
122
108
|
@click.prevent.stop
|
123
109
|
@on-change="onSearch($event)"
|
110
|
+
ref="searchInput"
|
124
111
|
/>
|
125
|
-
</
|
126
|
-
<
|
127
|
-
<
|
112
|
+
</search-container>
|
113
|
+
<spinner v-if="optionsLoading" />
|
114
|
+
<empty-text v-else-if="!optionsLoading && !optionItems.length">
|
128
115
|
{{ emptyText ? emptyText : $gettext('No components found.') }}
|
129
|
-
</
|
130
|
-
<
|
131
|
-
v-for="(item, index) in optionItems"
|
116
|
+
</empty-text>
|
117
|
+
<options-item
|
132
118
|
v-else
|
133
|
-
:
|
134
|
-
:col-span="colSpan - 1"
|
135
|
-
:tabindex="0"
|
119
|
+
:colSpan="colSpan - 1"
|
136
120
|
:width="dynamicGridWidth"
|
121
|
+
v-for="(item, index) in optionItems"
|
122
|
+
:key="index"
|
137
123
|
@click="onItemClick(item)"
|
124
|
+
:tabindex="0"
|
138
125
|
@keyup.enter="onItemClick(item)"
|
139
126
|
>
|
140
|
-
<template
|
141
|
-
v-for="(option, idx) in optionsDisplay"
|
142
|
-
:key="idx"
|
143
|
-
>
|
127
|
+
<template v-for="(option, idx) in optionsDisplay" :key="idx">
|
144
128
|
<span v-if="option !== 'template'">
|
145
129
|
{{ !!item[option] ? item[option] : '-' }}
|
146
130
|
</span>
|
147
|
-
<
|
148
|
-
v-else-if="option === 'template' && item.has_template"
|
131
|
+
<template-button
|
149
132
|
@click.stop="onTemplateClick(item)"
|
133
|
+
v-else-if="option === 'template' && item.has_template"
|
134
|
+
>{{ $gettext('Use template...') }}</template-button
|
150
135
|
>
|
151
|
-
|
152
|
-
</TemplateButton>
|
153
|
-
<NoTemplate
|
136
|
+
<no-template
|
154
137
|
v-else-if="option === 'template' && !item.has_template"
|
155
138
|
>
|
156
139
|
{{ $gettext('No main component template') }}
|
157
|
-
</
|
140
|
+
</no-template>
|
158
141
|
</template>
|
159
|
-
</
|
160
|
-
</
|
161
|
-
<
|
142
|
+
</options-item>
|
143
|
+
</options-wrapper>
|
144
|
+
<custom-container
|
162
145
|
v-if="inputText.length && allowFreeInputs"
|
163
146
|
@click="onCustomNameClick()"
|
164
147
|
>
|
165
|
-
<
|
166
|
-
<
|
167
|
-
({{ $gettext('custom_component') }})
|
168
|
-
|
169
|
-
</
|
170
|
-
</
|
171
|
-
</
|
172
|
-
</
|
173
|
-
</
|
148
|
+
<custom-name>{{ getCustomName }}</custom-name>
|
149
|
+
<custom-subtext
|
150
|
+
>({{ $gettext('custom_component') }})</custom-subtext
|
151
|
+
>
|
152
|
+
</custom-container>
|
153
|
+
</options-container>
|
154
|
+
</arrow-container>
|
155
|
+
</component-container>
|
156
|
+
</dropdown-row>
|
174
157
|
</template>
|
175
158
|
|
176
159
|
<script>
|
@@ -193,18 +176,18 @@
|
|
193
176
|
// :optionsDisplay="['display_name', 'company_item_number']" // Array. what should be displayed
|
194
177
|
// :disabled="true"
|
195
178
|
// />
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
179
|
+
import styled from 'vue3-styled-components'
|
180
|
+
import Spinner from '../spinner'
|
181
|
+
import SearchInput from '../inputs/searchInput'
|
182
|
+
import InputText from '../inputs/inputText'
|
183
|
+
import CollapseArrowIcon from '../../assets/icons/collapse_arrow_icon.svg'
|
184
|
+
import SubpositionMarkerIcon from '../../assets/icons/subposition_marker.svg'
|
185
|
+
import fileIconPng from '../../assets/icons/file_icon.png'
|
186
|
+
import Icon from '../icon'
|
187
|
+
import theme from '@/assets/theme.js'
|
188
|
+
|
189
|
+
const rowAttrs = { disabled: Boolean, isOpen: Boolean }
|
190
|
+
const DropdownRow = styled('div', rowAttrs)`
|
208
191
|
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
209
192
|
display: contents;
|
210
193
|
|
@@ -218,8 +201,8 @@
|
|
218
201
|
}
|
219
202
|
`
|
220
203
|
|
221
|
-
|
222
|
-
|
204
|
+
const ItemAttrs = { isNested: Boolean }
|
205
|
+
const ComponentItem = styled('td', ItemAttrs)`
|
223
206
|
padding-left: ${(props) => (props.isNested ? '14px !important' : '0')};
|
224
207
|
overflow: hidden;
|
225
208
|
text-overflow: ellipsis;
|
@@ -243,8 +226,8 @@
|
|
243
226
|
}
|
244
227
|
`
|
245
228
|
|
246
|
-
|
247
|
-
|
229
|
+
const containerAttrs = { colSpan: Number, width: String }
|
230
|
+
const ComponentContainer = styled('div', containerAttrs)`
|
248
231
|
display: contents;
|
249
232
|
align-items: center;
|
250
233
|
background-color: ${(props) => props.theme.colors.white};
|
@@ -252,19 +235,19 @@
|
|
252
235
|
padding: 5px 4px;
|
253
236
|
`
|
254
237
|
|
255
|
-
|
238
|
+
const ArrowDown = styled(CollapseArrowIcon)`
|
256
239
|
width: 8px;
|
257
240
|
transition: transform 150ms ease;
|
258
241
|
`
|
259
242
|
|
260
|
-
|
243
|
+
const ArrowUp = styled.img`
|
261
244
|
width: 8px;
|
262
245
|
transform: rotate(180deg);
|
263
246
|
transition: transform 150ms ease;
|
264
247
|
`
|
265
248
|
|
266
|
-
|
267
|
-
|
249
|
+
const ArrowAttrs = { isDisabled: Boolean }
|
250
|
+
const ArrowContainer = styled('td', ArrowAttrs)`
|
268
251
|
border-bottom: 1px solid ${(props) => props.theme.colors.grey4};
|
269
252
|
background-clip: content-box;
|
270
253
|
padding: 8px 0 7px 0 !important;
|
@@ -284,18 +267,18 @@
|
|
284
267
|
}
|
285
268
|
`
|
286
269
|
|
287
|
-
|
288
|
-
|
270
|
+
const arrowAttrs = { showArchived: Boolean }
|
271
|
+
const ArrowWrapper = styled('div', arrowAttrs)`
|
289
272
|
display: grid;
|
290
273
|
grid-template-columns: ${(props) =>
|
291
|
-
|
274
|
+
props.showArchived ? 'auto auto' : 'auto'};
|
292
275
|
align-items: center;
|
293
276
|
justify-items: center;
|
294
277
|
height: 100%;
|
295
278
|
`
|
296
279
|
|
297
|
-
|
298
|
-
|
280
|
+
const optionsAttrs = { top: Number, left: Number }
|
281
|
+
const OptionsContainer = styled('div', optionsAttrs)`
|
299
282
|
position: absolute;
|
300
283
|
margin-top: 10px;
|
301
284
|
display: grid;
|
@@ -311,7 +294,7 @@
|
|
311
294
|
border-radius: 4px;
|
312
295
|
`
|
313
296
|
|
314
|
-
|
297
|
+
const EmptyText = styled.div`
|
315
298
|
align-self: center;
|
316
299
|
justify-self: center;
|
317
300
|
height: 100px;
|
@@ -319,7 +302,7 @@
|
|
319
302
|
align-content: center;
|
320
303
|
`
|
321
304
|
|
322
|
-
|
305
|
+
const OptionsWrapper = styled.div`
|
323
306
|
display: grid;
|
324
307
|
position: relative;
|
325
308
|
padding: 12px;
|
@@ -330,7 +313,7 @@
|
|
330
313
|
min-width: 400px; // kind of an arbitrary number until we know all use cases
|
331
314
|
`
|
332
315
|
|
333
|
-
|
316
|
+
const OptionsItem = styled('div', containerAttrs)`
|
334
317
|
display: grid;
|
335
318
|
grid-template-columns: ${(props) => props.width};
|
336
319
|
grid-gap: 30px;
|
@@ -348,7 +331,7 @@
|
|
348
331
|
}
|
349
332
|
`
|
350
333
|
|
351
|
-
|
334
|
+
const SearchContainer = styled.div`
|
352
335
|
position: sticky;
|
353
336
|
top: 0;
|
354
337
|
padding-top: 6px;
|
@@ -356,7 +339,7 @@
|
|
356
339
|
height: 40px;
|
357
340
|
`
|
358
341
|
|
359
|
-
|
342
|
+
const TemplateButton = styled.div`
|
360
343
|
cursor: pointer;
|
361
344
|
background-color: #263238;
|
362
345
|
color: ${(props) => props.theme.colors.white};
|
@@ -367,7 +350,7 @@
|
|
367
350
|
margin-left: 15px;
|
368
351
|
`
|
369
352
|
|
370
|
-
|
353
|
+
const NoTemplate = styled.div`
|
371
354
|
color: ${(props) => props.theme.colors.gray1};
|
372
355
|
font-style: italic;
|
373
356
|
overflow: hidden;
|
@@ -375,7 +358,7 @@
|
|
375
358
|
padding-left: 15px;
|
376
359
|
`
|
377
360
|
|
378
|
-
|
361
|
+
const TemplateLink = styled.div`
|
379
362
|
color: ${(props) => props.theme.colors.brightBlue};
|
380
363
|
cursor: pointer;
|
381
364
|
display: grid;
|
@@ -384,13 +367,13 @@
|
|
384
367
|
padding-left: 15px;
|
385
368
|
`
|
386
369
|
|
387
|
-
|
370
|
+
const InputContainer = styled.div`
|
388
371
|
.inputField input {
|
389
372
|
border-radius: 4px 0 0 4px;
|
390
373
|
}
|
391
374
|
`
|
392
375
|
|
393
|
-
|
376
|
+
const CustomContainer = styled.div`
|
394
377
|
display: grid;
|
395
378
|
grid-template-columns: auto 1fr;
|
396
379
|
padding: 10px 22px;
|
@@ -402,254 +385,254 @@
|
|
402
385
|
}
|
403
386
|
`
|
404
387
|
|
405
|
-
|
388
|
+
const CustomName = styled.div`
|
406
389
|
justify-self: flex-start;
|
407
390
|
`
|
408
391
|
|
409
|
-
|
392
|
+
const CustomSubtext = styled.div`
|
410
393
|
justify-self: flex-end;
|
411
394
|
color: ${(props) => props.theme.colors.grey3};
|
412
395
|
`
|
413
396
|
|
414
|
-
|
397
|
+
const TextContainer = styled.div`
|
415
398
|
height: 100%;
|
416
399
|
display: grid;
|
417
400
|
align-items: center;
|
418
401
|
`
|
419
402
|
|
420
|
-
|
403
|
+
const NestedIcon = styled(SubpositionMarkerIcon)`
|
421
404
|
height: 10px;
|
422
405
|
width: 6px;
|
423
406
|
`
|
424
407
|
|
425
|
-
|
426
|
-
|
408
|
+
const NestedAttrs = { isNested: Boolean }
|
409
|
+
const NestedContainer = styled('div', NestedAttrs)`
|
427
410
|
display: grid;
|
428
411
|
grid-gap: 5px;
|
429
412
|
grid-template-columns: ${(props) => (props.isNested ? 'auto 1fr' : '1fr')};
|
430
413
|
align-items: center;
|
431
414
|
`
|
432
415
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
416
|
+
export default {
|
417
|
+
name: 'table-dropdown',
|
418
|
+
components: {
|
419
|
+
DropdownRow,
|
420
|
+
ComponentItem,
|
421
|
+
ComponentContainer,
|
422
|
+
ArrowDown,
|
423
|
+
ArrowUp,
|
424
|
+
OptionsContainer,
|
425
|
+
Spinner,
|
426
|
+
EmptyText,
|
427
|
+
SearchInput,
|
428
|
+
ArrowWrapper,
|
429
|
+
OptionsWrapper,
|
430
|
+
OptionsItem,
|
431
|
+
SearchContainer,
|
432
|
+
TemplateButton,
|
433
|
+
NoTemplate,
|
434
|
+
TemplateLink,
|
435
|
+
InputText,
|
436
|
+
InputContainer,
|
437
|
+
CustomContainer,
|
438
|
+
CustomName,
|
439
|
+
CustomSubtext,
|
440
|
+
ArrowContainer,
|
441
|
+
TextContainer,
|
442
|
+
NestedIcon,
|
443
|
+
NestedContainer,
|
444
|
+
Icon
|
445
|
+
},
|
446
|
+
props: {
|
447
|
+
colSpan: {
|
448
|
+
required: false,
|
449
|
+
default: 1
|
450
|
+
},
|
451
|
+
customInputDisabled: {
|
452
|
+
// whether the input field should be disabled
|
453
|
+
required: false,
|
454
|
+
default: true
|
455
|
+
},
|
456
|
+
allowFreeInputs: {
|
457
|
+
// whether we allow the user to select a custom input
|
458
|
+
required: false,
|
459
|
+
default: false
|
460
|
+
},
|
461
|
+
tableItems: {
|
462
|
+
required: true
|
463
|
+
},
|
464
|
+
showArchived: {
|
465
|
+
required: false,
|
466
|
+
default: false
|
467
|
+
},
|
468
|
+
isOpen: {
|
469
|
+
required: true,
|
470
|
+
default: false
|
471
|
+
},
|
472
|
+
optionsLoading: {
|
473
|
+
required: false,
|
474
|
+
default: false
|
475
|
+
},
|
476
|
+
emptyText: {
|
477
|
+
required: false,
|
478
|
+
default: null
|
479
|
+
},
|
480
|
+
optionItems: {
|
481
|
+
required: true
|
482
|
+
},
|
483
|
+
optionsDisplay: {
|
484
|
+
required: true,
|
485
|
+
default: [] // should be like ['display_name', 'company_item_number', 'description']
|
486
|
+
},
|
487
|
+
disabled: {
|
488
|
+
required: false,
|
489
|
+
default: false
|
490
|
+
},
|
491
|
+
isNested: {
|
492
|
+
required: false,
|
493
|
+
default: false
|
494
|
+
}
|
495
|
+
},
|
496
|
+
data() {
|
497
|
+
return {
|
498
|
+
inputText: '',
|
499
|
+
wasClicked: false, // prevents custom-name from being triggered on the <input-text />
|
500
|
+
dynamicWidth: [], // for numbers
|
501
|
+
dynamicGridWidth: [], // for grid values
|
502
|
+
fileIcon: fileIconPng
|
503
|
+
}
|
504
|
+
},
|
505
|
+
methods: {
|
506
|
+
toggleOpen(event) {
|
507
|
+
if (
|
508
|
+
this.disabled ||
|
509
|
+
(event &&
|
510
|
+
!(event.target === this.$el) &&
|
511
|
+
!this.$el.contains(event.target))
|
512
|
+
) {
|
513
|
+
return
|
514
|
+
}
|
515
|
+
this.wasClicked = false
|
516
|
+
if (!this.isOpen) {
|
517
|
+
document.addEventListener('click', this.clickOutside)
|
518
|
+
this.$emit('dropdown-search', '')
|
519
|
+
this.$nextTick(() => {
|
520
|
+
this.scrollToItem()
|
521
|
+
})
|
522
|
+
this.$emit('toggle-dropdown-open', { close: false })
|
523
|
+
this.$nextTick(() => {
|
524
|
+
this.$refs.searchInput.$el.children[0].children[1].focus()
|
525
|
+
})
|
526
|
+
} else {
|
527
|
+
document.removeEventListener('click', this.clickOutside)
|
528
|
+
this.$emit('toggle-dropdown-open', { close: true })
|
529
|
+
this.inputText = ''
|
530
|
+
}
|
462
531
|
},
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
default: 1
|
467
|
-
},
|
468
|
-
customInputDisabled: {
|
469
|
-
// whether the input field should be disabled
|
470
|
-
required: false,
|
471
|
-
default: true
|
472
|
-
},
|
473
|
-
allowFreeInputs: {
|
474
|
-
// whether we allow the user to select a custom input
|
475
|
-
required: false,
|
476
|
-
default: false
|
477
|
-
},
|
478
|
-
tableItems: {
|
479
|
-
required: true
|
480
|
-
},
|
481
|
-
showArchived: {
|
482
|
-
required: false,
|
483
|
-
default: false
|
484
|
-
},
|
485
|
-
isOpen: {
|
486
|
-
required: true,
|
487
|
-
default: false
|
488
|
-
},
|
489
|
-
optionsLoading: {
|
490
|
-
required: false,
|
491
|
-
default: false
|
492
|
-
},
|
493
|
-
emptyText: {
|
494
|
-
required: false,
|
495
|
-
default: null
|
496
|
-
},
|
497
|
-
optionItems: {
|
498
|
-
required: true
|
499
|
-
},
|
500
|
-
optionsDisplay: {
|
501
|
-
required: true,
|
502
|
-
default: [] // should be like ['display_name', 'company_item_number', 'description']
|
503
|
-
},
|
504
|
-
disabled: {
|
505
|
-
required: false,
|
506
|
-
default: false
|
507
|
-
},
|
508
|
-
isNested: {
|
509
|
-
required: false,
|
510
|
-
default: false
|
532
|
+
onInputClick() {
|
533
|
+
if (!this.isOpen) {
|
534
|
+
this.toggleOpen()
|
511
535
|
}
|
512
536
|
},
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
fileIcon: fileIconPng
|
537
|
+
scrollToItem() {
|
538
|
+
if (this.$refs.optionsContainer) {
|
539
|
+
this.$refs.optionsContainer.$el.scrollIntoView({
|
540
|
+
behavior: 'smooth',
|
541
|
+
block: 'center'
|
542
|
+
})
|
520
543
|
}
|
521
544
|
},
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
545
|
+
onTemplateClick(item) {
|
546
|
+
this.$emit('on-template-click', item)
|
547
|
+
},
|
548
|
+
onSelectedTemplateClick(item) {
|
549
|
+
this.$emit('on-selected-template-click', item)
|
550
|
+
},
|
551
|
+
onItemClick(item) {
|
552
|
+
this.wasClicked = true
|
553
|
+
this.$emit('item-selected', item)
|
554
|
+
},
|
555
|
+
onSearch(value) {
|
556
|
+
this.inputText = value
|
557
|
+
this.$emit('dropdown-search', value)
|
558
|
+
},
|
559
|
+
clickOutside(event) {
|
560
|
+
if (event.target === this.$el || this.$el.contains(event.target)) {
|
561
|
+
return
|
528
562
|
}
|
563
|
+
this.inputText = ''
|
564
|
+
// 'close: true' is needed in case a box is open and another box is clicked on
|
565
|
+
// so this one will close properly
|
566
|
+
document.removeEventListener('click', this.clickOutside)
|
567
|
+
this.$emit('toggle-dropdown-open', { close: true })
|
529
568
|
},
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
this.scrollToItem()
|
540
|
-
})
|
541
|
-
}
|
542
|
-
},
|
543
|
-
optionItems: {
|
544
|
-
immediate: true,
|
545
|
-
handler(val) {
|
546
|
-
if (val && val.length) {
|
547
|
-
this.setDropdownWidth(val)
|
548
|
-
}
|
549
|
-
}
|
569
|
+
onCustomNameClick() {
|
570
|
+
this.wasClicked = true
|
571
|
+
this.$emit('on-custom-input-name', this.inputText)
|
572
|
+
this.$emit('toggle-dropdown-open', { close: true })
|
573
|
+
this.inputText = ''
|
574
|
+
},
|
575
|
+
onCustomInputChange(event) {
|
576
|
+
if (this.wasClicked) {
|
577
|
+
return
|
550
578
|
}
|
579
|
+
this.$emit('custom-input-change', event)
|
551
580
|
},
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
this.$nextTick(() => {
|
571
|
-
this.$refs.searchInput.$el.children[0].children[1].focus()
|
572
|
-
})
|
573
|
-
} else {
|
574
|
-
document.removeEventListener('click', this.clickOutside)
|
575
|
-
this.$emit('toggle-dropdown-open', { close: true })
|
576
|
-
this.inputText = ''
|
577
|
-
}
|
578
|
-
},
|
579
|
-
onInputClick() {
|
580
|
-
if (!this.isOpen) {
|
581
|
-
this.toggleOpen()
|
582
|
-
}
|
583
|
-
},
|
584
|
-
scrollToItem() {
|
585
|
-
if (this.$refs.optionsContainer) {
|
586
|
-
this.$refs.optionsContainer.$el.scrollIntoView({
|
587
|
-
behavior: 'smooth',
|
588
|
-
block: 'center'
|
589
|
-
})
|
590
|
-
}
|
591
|
-
},
|
592
|
-
onTemplateClick(item) {
|
593
|
-
this.$emit('on-template-click', item)
|
594
|
-
},
|
595
|
-
onSelectedTemplateClick(item) {
|
596
|
-
this.$emit('on-selected-template-click', item)
|
597
|
-
},
|
598
|
-
onItemClick(item) {
|
599
|
-
this.wasClicked = true
|
600
|
-
this.$emit('item-selected', item)
|
601
|
-
},
|
602
|
-
onSearch(value) {
|
603
|
-
this.inputText = value
|
604
|
-
this.$emit('dropdown-search', value)
|
605
|
-
},
|
606
|
-
clickOutside(event) {
|
607
|
-
if (event.target === this.$el || this.$el.contains(event.target)) {
|
608
|
-
return
|
609
|
-
}
|
610
|
-
this.inputText = ''
|
611
|
-
// 'close: true' is needed in case a box is open and another box is clicked on
|
612
|
-
// so this one will close properly
|
613
|
-
document.removeEventListener('click', this.clickOutside)
|
614
|
-
this.$emit('toggle-dropdown-open', { close: true })
|
615
|
-
},
|
616
|
-
onCustomNameClick() {
|
617
|
-
this.wasClicked = true
|
618
|
-
this.$emit('on-custom-input-name', this.inputText)
|
619
|
-
this.$emit('toggle-dropdown-open', { close: true })
|
620
|
-
this.inputText = ''
|
621
|
-
},
|
622
|
-
onCustomInputChange(event) {
|
623
|
-
if (this.wasClicked) {
|
624
|
-
return
|
625
|
-
}
|
626
|
-
this.$emit('custom-input-change', event)
|
627
|
-
},
|
628
|
-
setDropdownWidth(options) {
|
629
|
-
this.dynamicWidth = []
|
630
|
-
|
631
|
-
options.forEach((item) => {
|
632
|
-
this.optionsDisplay.forEach((header, index) => {
|
633
|
-
let value =
|
634
|
-
header === 'template'
|
635
|
-
? this.$gettext('No main component template')
|
636
|
-
: item[header]
|
637
|
-
value = value ? value : ''
|
638
|
-
|
639
|
-
// Update dynamicWidth with the maximum value
|
640
|
-
if (
|
641
|
-
!this.dynamicWidth[index] ||
|
642
|
-
value.length > this.dynamicWidth[index]
|
643
|
-
) {
|
644
|
-
this.dynamicWidth[index] = value.length
|
645
|
-
}
|
646
|
-
})
|
581
|
+
setDropdownWidth(options) {
|
582
|
+
this.dynamicWidth = []
|
583
|
+
|
584
|
+
options.forEach((item) => {
|
585
|
+
this.optionsDisplay.forEach((header, index) => {
|
586
|
+
let value =
|
587
|
+
header === 'template'
|
588
|
+
? this.$gettext('No main component template')
|
589
|
+
: item[header]
|
590
|
+
value = value ? value : ''
|
591
|
+
|
592
|
+
// Update dynamicWidth with the maximum value
|
593
|
+
if (
|
594
|
+
!this.dynamicWidth[index] ||
|
595
|
+
value.length > this.dynamicWidth[index]
|
596
|
+
) {
|
597
|
+
this.dynamicWidth[index] = value.length
|
598
|
+
}
|
647
599
|
})
|
600
|
+
})
|
648
601
|
|
649
|
-
|
650
|
-
|
651
|
-
|
602
|
+
this.dynamicGridWidth = this.dynamicWidth
|
603
|
+
.map((width) => width + 'ch')
|
604
|
+
.join(' ')
|
605
|
+
}
|
606
|
+
},
|
607
|
+
computed: {
|
608
|
+
getCustomName() {
|
609
|
+
return this.inputText
|
610
|
+
},
|
611
|
+
theme() {
|
612
|
+
return theme
|
613
|
+
}
|
614
|
+
},
|
615
|
+
watch: {
|
616
|
+
isOpen(newVal) {
|
617
|
+
if (newVal) {
|
618
|
+
document.addEventListener('click', this.clickOutside)
|
619
|
+
this.$emit('dropdown-search', '')
|
620
|
+
this.$nextTick(() => {
|
621
|
+
this.$refs.searchInput.$el.children[0].children[0].focus()
|
622
|
+
})
|
623
|
+
this.$nextTick(() => {
|
624
|
+
this.scrollToItem()
|
625
|
+
})
|
626
|
+
}
|
627
|
+
},
|
628
|
+
optionItems: {
|
629
|
+
immediate: true,
|
630
|
+
handler(val) {
|
631
|
+
if (val && val.length) {
|
632
|
+
this.setDropdownWidth(val)
|
633
|
+
}
|
652
634
|
}
|
653
635
|
}
|
654
636
|
}
|
637
|
+
}
|
655
638
|
</script>
|