@gitlab/ui 37.10.0 → 38.1.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/CHANGELOG.md +30 -0
- package/README.md +1 -1
- package/dist/components/base/breadcrumb/breadcrumb.js +10 -5
- package/dist/components/base/{filtered_search/examples/filtered_search.single_unique.example.js → breadcrumb/breadcrumb_item.js} +32 -28
- package/dist/components/base/filtered_search/filtered_search.documentation.js +2 -66
- package/dist/components/base/filtered_search/filtered_search.js +38 -11
- package/dist/components/base/filtered_search/filtered_search_suggestion.documentation.js +2 -8
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +4 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.documentation.js +2 -7
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +4 -0
- package/dist/components/base/filtered_search/filtered_search_term.documentation.js +2 -44
- package/dist/components/base/filtered_search/filtered_search_term.js +37 -0
- package/dist/components/base/filtered_search/filtered_search_token.documentation.js +2 -31
- package/dist/components/base/filtered_search/filtered_search_token.js +49 -0
- package/dist/components/base/filtered_search/filtered_search_token_segment.documentation.js +2 -46
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +48 -0
- package/dist/components/base/form/form_radio/form_radio.js +1 -1
- package/dist/components/charts/series_label/series_label.js +6 -1
- package/dist/components/utilities/truncate/truncate.js +2 -2
- package/documentation/documented_stories.js +6 -0
- package/package.json +9 -7
- package/src/components/base/breadcrumb/breadcrumb.spec.js +24 -10
- package/src/components/base/breadcrumb/breadcrumb.vue +11 -6
- package/src/components/base/breadcrumb/breadcrumb_item.spec.js +45 -0
- package/src/components/base/breadcrumb/breadcrumb_item.vue +43 -0
- package/src/components/base/filtered_search/filtered_search.documentation.js +0 -76
- package/src/components/base/filtered_search/filtered_search.md +3 -4
- package/src/components/base/filtered_search/filtered_search.stories.js +248 -13
- package/src/components/base/filtered_search/filtered_search.vue +47 -10
- package/src/components/base/filtered_search/filtered_search_suggestion.documentation.js +0 -6
- package/src/components/base/filtered_search/filtered_search_suggestion.md +1 -7
- package/src/components/base/filtered_search/filtered_search_suggestion.stories.js +26 -18
- package/src/components/base/filtered_search/filtered_search_suggestion.vue +5 -0
- package/src/components/base/filtered_search/filtered_search_suggestion_list.documentation.js +0 -5
- package/src/components/base/filtered_search/filtered_search_suggestion_list.md +1 -7
- package/src/components/base/filtered_search/filtered_search_suggestion_list.stories.js +33 -25
- package/src/components/base/filtered_search/filtered_search_suggestion_list.vue +5 -0
- package/src/components/base/filtered_search/filtered_search_term.documentation.js +0 -41
- package/src/components/base/filtered_search/filtered_search_term.md +0 -2
- package/src/components/base/filtered_search/filtered_search_term.stories.js +33 -26
- package/src/components/base/filtered_search/filtered_search_term.vue +54 -0
- package/src/components/base/filtered_search/filtered_search_token.documentation.js +0 -26
- package/src/components/base/filtered_search/filtered_search_token.md +1 -3
- package/src/components/base/filtered_search/filtered_search_token.stories.js +136 -132
- package/src/components/base/filtered_search/filtered_search_token.vue +63 -0
- package/src/components/base/filtered_search/filtered_search_token_segment.documentation.js +0 -43
- package/src/components/base/filtered_search/filtered_search_token_segment.md +0 -2
- package/src/components/base/filtered_search/filtered_search_token_segment.stories.js +86 -79
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +42 -0
- package/src/components/base/form/form_radio/form_radio.spec.js +21 -8
- package/src/components/base/form/form_radio/form_radio.vue +0 -1
- package/src/components/charts/series_label/series_label.stories.js +6 -3
- package/src/components/charts/series_label/series_label.vue +3 -0
- package/src/components/utilities/truncate/truncate.spec.js +14 -49
- package/src/components/utilities/truncate/truncate.stories.js +1 -59
- package/src/components/utilities/truncate/truncate.vue +3 -21
- package/dist/components/base/filtered_search/examples/filtered_search.default.example.js +0 -422
- package/dist/components/base/filtered_search/examples/filtered_search.friendly.example.js +0 -423
- package/dist/components/base/filtered_search/examples/filtered_search.history.example.js +0 -91
- package/dist/components/base/filtered_search/examples/filtered_search.multi_select.example.js +0 -196
- package/dist/components/base/filtered_search/examples/index.js +0 -32
- package/src/components/base/filtered_search/examples/filtered_search.default.example.vue +0 -298
- package/src/components/base/filtered_search/examples/filtered_search.friendly.example.vue +0 -300
- package/src/components/base/filtered_search/examples/filtered_search.history.example.vue +0 -50
- package/src/components/base/filtered_search/examples/filtered_search.multi_select.example.vue +0 -132
- package/src/components/base/filtered_search/examples/filtered_search.single_unique.example.vue +0 -31
- package/src/components/base/filtered_search/examples/index.js +0 -38
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import FilteredSearchDefaultExample from './filtered_search.default.example';
|
|
2
|
-
import FilteredSearchFriendlyExample from './filtered_search.friendly.example';
|
|
3
|
-
import FilteredSearchHistoryExample from './filtered_search.history.example';
|
|
4
|
-
import FilteredSearchMultiSelectExample from './filtered_search.multi_select.example';
|
|
5
|
-
import FilteredSearchSingleUniqueExample from './filtered_search.single_unique.example';
|
|
6
|
-
|
|
7
|
-
var index = [{
|
|
8
|
-
name: 'Filtered search',
|
|
9
|
-
items: [{
|
|
10
|
-
id: 'filtered-search',
|
|
11
|
-
name: 'default',
|
|
12
|
-
component: FilteredSearchDefaultExample
|
|
13
|
-
}, {
|
|
14
|
-
id: 'filtered-search-single-unique',
|
|
15
|
-
name: 'single-unique',
|
|
16
|
-
component: FilteredSearchSingleUniqueExample
|
|
17
|
-
}, {
|
|
18
|
-
id: 'filtered-search-history',
|
|
19
|
-
name: 'with-history',
|
|
20
|
-
component: FilteredSearchHistoryExample
|
|
21
|
-
}, {
|
|
22
|
-
id: 'filtered-search-friendly-text',
|
|
23
|
-
name: 'with-friendly-text',
|
|
24
|
-
component: FilteredSearchFriendlyExample
|
|
25
|
-
}, {
|
|
26
|
-
id: 'filtered-search-multi-select',
|
|
27
|
-
name: 'with-multi-select',
|
|
28
|
-
component: FilteredSearchMultiSelectExample
|
|
29
|
-
}]
|
|
30
|
-
}];
|
|
31
|
-
|
|
32
|
-
export default index;
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const fakeUsers = [
|
|
3
|
-
{ id: 1, name: 'User Alpha', username: 'alpha' },
|
|
4
|
-
{ id: 2, name: 'User Beta', username: 'beta' },
|
|
5
|
-
{ id: 3, name: 'User Gamma', username: 'gamma' },
|
|
6
|
-
{ id: 4, name: 'User Delta', username: 'delta' },
|
|
7
|
-
{ id: 5, name: 'User Epsilon', username: 'epsilon' },
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
const fakeMilestones = [
|
|
11
|
-
{ id: 1, title: '12.7', name: '%12.7' },
|
|
12
|
-
{ id: 2, title: '12.8', name: '%12.8' },
|
|
13
|
-
{ id: 3, title: '12.9', name: '%12.9' },
|
|
14
|
-
{ id: 4, title: '12.10', name: '%12.10' },
|
|
15
|
-
{ id: 5, title: 'Backlog', name: 'Backlog' },
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const fakeLabels = [
|
|
19
|
-
{ id: 1, title: 'Bug', color: '#D9534F', text_color: '#FFFFFF' },
|
|
20
|
-
{ id: 2, title: 'Enhancement', color: '#F0AD4E', text_color: '#FFFFFF' },
|
|
21
|
-
{ id: 3, title: 'Backlog', color: '#cccccc', text_color: '#333333' },
|
|
22
|
-
{ id: 4, title: 'Feature', color: '#A8D695', text_color: '#333333' },
|
|
23
|
-
{ id: 5, title: 'Documentation', color: '#5CB85C', text_color: '#FFFFFF' },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const UserToken = {
|
|
27
|
-
props: ['value', 'active'],
|
|
28
|
-
inheritAttrs: false,
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
loadingView: false,
|
|
32
|
-
loadingSuggestions: false,
|
|
33
|
-
users: [],
|
|
34
|
-
activeUser: null,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
loadView() {
|
|
39
|
-
this.loadingView = true;
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
this.loadingView = false;
|
|
42
|
-
this.activeUser = fakeUsers.find((u) => u.username === this.value.data);
|
|
43
|
-
}, 1000);
|
|
44
|
-
},
|
|
45
|
-
loadSuggestions() {
|
|
46
|
-
this.loadingSuggestions = true;
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
this.loadingSuggestions = false;
|
|
49
|
-
this.users = fakeUsers;
|
|
50
|
-
}, 2000);
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
watch: {
|
|
54
|
-
// eslint-disable-next-line func-names
|
|
55
|
-
'value.data': function () {
|
|
56
|
-
if (this.active) {
|
|
57
|
-
this.loadSuggestions();
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
active: {
|
|
61
|
-
immediate: true,
|
|
62
|
-
handler(newValue) {
|
|
63
|
-
if (!newValue) {
|
|
64
|
-
this.loadView();
|
|
65
|
-
} else {
|
|
66
|
-
this.loadSuggestions();
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
template: `
|
|
72
|
-
<gl-filtered-search-token
|
|
73
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
74
|
-
v-on="$listeners"
|
|
75
|
-
>
|
|
76
|
-
<template #view="{ inputValue }">
|
|
77
|
-
<gl-loading-icon size="sm" v-if="loadingView" class="gl-mr-2" />
|
|
78
|
-
<gl-avatar :size="16" :entity-name="inputValue" shape="circle" class="gl-mr-2" v-else />
|
|
79
|
-
{{ activeUser ? activeUser.name : inputValue }}
|
|
80
|
-
</template>
|
|
81
|
-
<template #suggestions>
|
|
82
|
-
<template v-if="loadingSuggestions">
|
|
83
|
-
<gl-loading-icon />
|
|
84
|
-
</template>
|
|
85
|
-
<template v-else>
|
|
86
|
-
<gl-filtered-search-suggestion :key="user.id" v-for="user in users" :value="user.username">
|
|
87
|
-
<div class="gl-display-flex">
|
|
88
|
-
<gl-avatar :size="32" :entity-name="user.username" />
|
|
89
|
-
<div>
|
|
90
|
-
<p class="gl-m-0">{{ user.name }}</p>
|
|
91
|
-
<p class="gl-m-0">@{{ user.username }}</p>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</gl-filtered-search-suggestion>
|
|
95
|
-
</template>
|
|
96
|
-
</template>
|
|
97
|
-
</gl-filtered-search-token>
|
|
98
|
-
`,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const MilestoneToken = {
|
|
102
|
-
props: ['value', 'active'],
|
|
103
|
-
inheritAttrs: false,
|
|
104
|
-
data() {
|
|
105
|
-
return {
|
|
106
|
-
loadingView: false,
|
|
107
|
-
loadingSuggestions: false,
|
|
108
|
-
milestones: [],
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
methods: {
|
|
112
|
-
loadSuggestions() {
|
|
113
|
-
this.loadingSuggestions = true;
|
|
114
|
-
setTimeout(() => {
|
|
115
|
-
this.loadingSuggestions = false;
|
|
116
|
-
this.milestones = fakeMilestones;
|
|
117
|
-
}, 2000);
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
watch: {
|
|
121
|
-
// eslint-disable-next-line func-names
|
|
122
|
-
'value.data': function () {
|
|
123
|
-
if (this.active) {
|
|
124
|
-
this.loadSuggestions();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
active: {
|
|
128
|
-
immediate: true,
|
|
129
|
-
handler(newValue) {
|
|
130
|
-
if (newValue) {
|
|
131
|
-
this.loadSuggestions();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
template: `
|
|
137
|
-
<gl-filtered-search-token
|
|
138
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
139
|
-
v-on="$listeners"
|
|
140
|
-
>
|
|
141
|
-
<template #suggestions>
|
|
142
|
-
<gl-filtered-search-suggestion value="None">None</gl-filtered-search-suggestion>
|
|
143
|
-
<gl-filtered-search-suggestion value="Any">Any</gl-filtered-search-suggestion>
|
|
144
|
-
<gl-filtered-search-suggestion value="Upcoming">Upcoming</gl-filtered-search-suggestion>
|
|
145
|
-
<gl-filtered-search-suggestion value="Started">Started</gl-filtered-search-suggestion>
|
|
146
|
-
<gl-dropdown-divider v-if="loadingSuggestions || milestones.length" />
|
|
147
|
-
<template v-if="loadingSuggestions">
|
|
148
|
-
<gl-loading-icon />
|
|
149
|
-
</template>
|
|
150
|
-
<template v-else>
|
|
151
|
-
<gl-filtered-search-suggestion :key="milestone.id" v-for="milestone in milestones" :value="milestone.name">
|
|
152
|
-
{{ milestone.title }}
|
|
153
|
-
</gl-filtered-search-suggestion>
|
|
154
|
-
</template>
|
|
155
|
-
</template>
|
|
156
|
-
</gl-filtered-search-token>
|
|
157
|
-
`,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const LabelToken = {
|
|
161
|
-
props: ['value', 'active'],
|
|
162
|
-
inheritAttrs: false,
|
|
163
|
-
data() {
|
|
164
|
-
return {
|
|
165
|
-
loadingView: false,
|
|
166
|
-
loadingSuggestions: false,
|
|
167
|
-
labels: [],
|
|
168
|
-
activeLabel: null,
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
computed: {
|
|
172
|
-
currentValue() {
|
|
173
|
-
return this.value.data.toLowerCase();
|
|
174
|
-
},
|
|
175
|
-
containerStyle() {
|
|
176
|
-
if (this.activeLabel) {
|
|
177
|
-
const { color, text_color } = this.activeLabel;
|
|
178
|
-
|
|
179
|
-
return { backgroundColor: color, color: text_color };
|
|
180
|
-
}
|
|
181
|
-
return {};
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
methods: {
|
|
185
|
-
loadView() {
|
|
186
|
-
this.loadingView = true;
|
|
187
|
-
setTimeout(() => {
|
|
188
|
-
this.loadingView = false;
|
|
189
|
-
this.activeLabel = fakeLabels.find((l) => l.title === this.value.data);
|
|
190
|
-
}, 100);
|
|
191
|
-
},
|
|
192
|
-
loadSuggestions() {
|
|
193
|
-
this.loadingSuggestions = true;
|
|
194
|
-
setTimeout(() => {
|
|
195
|
-
this.loadingSuggestions = false;
|
|
196
|
-
this.labels = fakeLabels;
|
|
197
|
-
}, 2000);
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
watch: {
|
|
201
|
-
// eslint-disable-next-line func-names
|
|
202
|
-
'value.data': function () {
|
|
203
|
-
if (this.active) {
|
|
204
|
-
this.loadSuggestions();
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
active: {
|
|
208
|
-
immediate: true,
|
|
209
|
-
handler(newValue) {
|
|
210
|
-
if (!newValue) {
|
|
211
|
-
this.loadView();
|
|
212
|
-
} else {
|
|
213
|
-
this.loadSuggestions();
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
template: `
|
|
219
|
-
<gl-filtered-search-token
|
|
220
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
221
|
-
v-on="$listeners"
|
|
222
|
-
>
|
|
223
|
-
<template #view-token="{ inputValue, cssClasses, listeners }">
|
|
224
|
-
<gl-token variant="search-value" :class="cssClasses" :style="containerStyle" v-on="listeners">
|
|
225
|
-
{{ activeLabel ? activeLabel.title : inputValue }}
|
|
226
|
-
</gl-token>
|
|
227
|
-
</template>
|
|
228
|
-
<template #suggestions>
|
|
229
|
-
<gl-filtered-search-suggestion value="None">None</gl-filtered-search-suggestion>
|
|
230
|
-
<gl-filtered-search-suggestion value="Any">Any</gl-filtered-search-suggestion>
|
|
231
|
-
<gl-dropdown-divider v-if="loadingSuggestions || labels.length" />
|
|
232
|
-
<template v-if="loadingSuggestions">
|
|
233
|
-
<gl-loading-icon />
|
|
234
|
-
</template>
|
|
235
|
-
<template v-else>
|
|
236
|
-
<gl-filtered-search-suggestion :key="label.id" v-for="label in labels" :value="label.title">
|
|
237
|
-
<div class="d-flex">
|
|
238
|
-
<span
|
|
239
|
-
:style="{ backgroundColor: label.color, height: '16px', width: '16px' }"
|
|
240
|
-
class="d-inline-block mr-2"
|
|
241
|
-
></span>
|
|
242
|
-
{{ label.title }}
|
|
243
|
-
</div>
|
|
244
|
-
</gl-filtered-search-suggestion>
|
|
245
|
-
</template>
|
|
246
|
-
</template>
|
|
247
|
-
</gl-filtered-search-token>
|
|
248
|
-
`,
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const tokens = [
|
|
252
|
-
{
|
|
253
|
-
type: 'author',
|
|
254
|
-
icon: 'pencil',
|
|
255
|
-
title: 'Author',
|
|
256
|
-
dataType: 'user',
|
|
257
|
-
unique: true,
|
|
258
|
-
token: UserToken,
|
|
259
|
-
},
|
|
260
|
-
{ type: 'user', icon: 'user', title: 'Assignee', dataType: 'user', token: UserToken },
|
|
261
|
-
{ type: 'milestone', icon: 'clock', title: 'Milestone', unique: true, token: MilestoneToken },
|
|
262
|
-
{ type: 'label', icon: 'labels', title: 'Label', token: LabelToken },
|
|
263
|
-
{
|
|
264
|
-
type: 'weight',
|
|
265
|
-
icon: 'weight',
|
|
266
|
-
title: 'Weight',
|
|
267
|
-
unique: true,
|
|
268
|
-
token: 'gl-filtered-search-token',
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
type: 'confidential',
|
|
272
|
-
icon: 'eye-slash',
|
|
273
|
-
title: 'Confidential',
|
|
274
|
-
unique: true,
|
|
275
|
-
token: 'gl-filtered-search-token',
|
|
276
|
-
options: [
|
|
277
|
-
{ icon: 'eye-slash', value: true, title: 'Yes' },
|
|
278
|
-
{ icon: 'eye', value: false, title: 'No' },
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
|
-
];
|
|
282
|
-
|
|
283
|
-
export default {
|
|
284
|
-
data() {
|
|
285
|
-
return {
|
|
286
|
-
tokens,
|
|
287
|
-
value: [
|
|
288
|
-
{ type: 'author', value: { data: 'beta', operator: '=' } },
|
|
289
|
-
{ type: 'label', value: { data: 'Bug', operator: '=' } },
|
|
290
|
-
'raw text',
|
|
291
|
-
],
|
|
292
|
-
};
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
</script>
|
|
296
|
-
<template>
|
|
297
|
-
<gl-filtered-search v-model="value" :available-tokens="tokens" />
|
|
298
|
-
</template>
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const fakeUsers = [
|
|
3
|
-
{ id: 1, name: 'User Alpha', username: 'alpha' },
|
|
4
|
-
{ id: 2, name: 'User Beta', username: 'beta' },
|
|
5
|
-
{ id: 3, name: 'User Gamma', username: 'gamma' },
|
|
6
|
-
{ id: 4, name: 'User Delta', username: 'delta' },
|
|
7
|
-
{ id: 5, name: 'User Epsilon', username: 'epsilon' },
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
const fakeMilestones = [
|
|
11
|
-
{ id: 1, title: '12.7', name: '%12.7' },
|
|
12
|
-
{ id: 2, title: '12.8', name: '%12.8' },
|
|
13
|
-
{ id: 3, title: '12.9', name: '%12.9' },
|
|
14
|
-
{ id: 4, title: '12.10', name: '%12.10' },
|
|
15
|
-
{ id: 5, title: 'Backlog', name: 'Backlog' },
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const fakeLabels = [
|
|
19
|
-
{ id: 1, title: 'Bug', color: '#D9534F', text_color: '#FFFFFF' },
|
|
20
|
-
{ id: 2, title: 'Enhancement', color: '#F0AD4E', text_color: '#FFFFFF' },
|
|
21
|
-
{ id: 3, title: 'Backlog', color: '#cccccc', text_color: '#333333' },
|
|
22
|
-
{ id: 4, title: 'Feature', color: '#A8D695', text_color: '#333333' },
|
|
23
|
-
{ id: 5, title: 'Documentation', color: '#5CB85C', text_color: '#FFFFFF' },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const UserToken = {
|
|
27
|
-
props: ['value', 'active'],
|
|
28
|
-
inheritAttrs: false,
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
loadingView: false,
|
|
32
|
-
loadingSuggestions: false,
|
|
33
|
-
users: [],
|
|
34
|
-
activeUser: null,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
loadView() {
|
|
39
|
-
this.loadingView = true;
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
this.loadingView = false;
|
|
42
|
-
this.activeUser = fakeUsers.find((u) => u.username === this.value.data);
|
|
43
|
-
}, 1000);
|
|
44
|
-
},
|
|
45
|
-
loadSuggestions() {
|
|
46
|
-
this.loadingSuggestions = true;
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
this.loadingSuggestions = false;
|
|
49
|
-
this.users = fakeUsers;
|
|
50
|
-
}, 2000);
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
watch: {
|
|
54
|
-
// eslint-disable-next-line func-names
|
|
55
|
-
'value.data': function () {
|
|
56
|
-
if (this.active) {
|
|
57
|
-
this.loadSuggestions();
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
active: {
|
|
61
|
-
immediate: true,
|
|
62
|
-
handler(newValue) {
|
|
63
|
-
if (!newValue) {
|
|
64
|
-
this.loadView();
|
|
65
|
-
} else {
|
|
66
|
-
this.loadSuggestions();
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
template: `
|
|
72
|
-
<gl-filtered-search-token
|
|
73
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
74
|
-
v-on="$listeners"
|
|
75
|
-
>
|
|
76
|
-
<template #view="{ inputValue }">
|
|
77
|
-
<gl-loading-icon size="sm" v-if="loadingView" />
|
|
78
|
-
<gl-avatar :size="16" :entity-name="inputValue" shape="circle" v-else />
|
|
79
|
-
{{ activeUser ? activeUser.name : inputValue }}
|
|
80
|
-
</template>
|
|
81
|
-
<template #suggestions>
|
|
82
|
-
<template v-if="loadingSuggestions">
|
|
83
|
-
<gl-loading-icon />
|
|
84
|
-
</template>
|
|
85
|
-
<template v-else>
|
|
86
|
-
<gl-filtered-search-suggestion :key="user.id" v-for="user in users" :value="user.username">
|
|
87
|
-
<div class="gl-display-flex">
|
|
88
|
-
<gl-avatar :size="32" :entity-name="user.username" />
|
|
89
|
-
<div>
|
|
90
|
-
<p class="gl-m-0">{{ user.name }}</p>
|
|
91
|
-
<p class="gl-m-0">@{{ user.username }}</p>
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</gl-filtered-search-suggestion>
|
|
95
|
-
</template>
|
|
96
|
-
</template>
|
|
97
|
-
</gl-filtered-search-token>
|
|
98
|
-
`,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const MilestoneToken = {
|
|
102
|
-
props: ['value', 'active'],
|
|
103
|
-
inheritAttrs: false,
|
|
104
|
-
data() {
|
|
105
|
-
return {
|
|
106
|
-
loadingView: false,
|
|
107
|
-
loadingSuggestions: false,
|
|
108
|
-
milestones: [],
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
methods: {
|
|
112
|
-
loadSuggestions() {
|
|
113
|
-
this.loadingSuggestions = true;
|
|
114
|
-
setTimeout(() => {
|
|
115
|
-
this.loadingSuggestions = false;
|
|
116
|
-
this.milestones = fakeMilestones;
|
|
117
|
-
}, 2000);
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
watch: {
|
|
121
|
-
// eslint-disable-next-line func-names
|
|
122
|
-
'value.data': function () {
|
|
123
|
-
if (this.active) {
|
|
124
|
-
this.loadSuggestions();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
active: {
|
|
128
|
-
immediate: true,
|
|
129
|
-
handler(newValue) {
|
|
130
|
-
if (newValue) {
|
|
131
|
-
this.loadSuggestions();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
template: `
|
|
137
|
-
<gl-filtered-search-token
|
|
138
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
139
|
-
v-on="$listeners"
|
|
140
|
-
>
|
|
141
|
-
<template #suggestions>
|
|
142
|
-
<gl-filtered-search-suggestion value="None">None</gl-filtered-search-suggestion>
|
|
143
|
-
<gl-filtered-search-suggestion value="Any">Any</gl-filtered-search-suggestion>
|
|
144
|
-
<gl-filtered-search-suggestion value="Upcoming">Upcoming</gl-filtered-search-suggestion>
|
|
145
|
-
<gl-filtered-search-suggestion value="Started">Started</gl-filtered-search-suggestion>
|
|
146
|
-
<gl-dropdown-divider v-if="loadingSuggestions || milestones.length" />
|
|
147
|
-
<template v-if="loadingSuggestions">
|
|
148
|
-
<gl-loading-icon />
|
|
149
|
-
</template>
|
|
150
|
-
<template v-else>
|
|
151
|
-
<gl-filtered-search-suggestion :key="milestone.id" v-for="milestone in milestones"
|
|
152
|
-
:value="milestone.name">
|
|
153
|
-
{{ milestone.title }}
|
|
154
|
-
</gl-filtered-search-suggestion>
|
|
155
|
-
</template>
|
|
156
|
-
</template>
|
|
157
|
-
</gl-filtered-search-token>
|
|
158
|
-
`,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const LabelToken = {
|
|
162
|
-
props: ['value', 'active'],
|
|
163
|
-
inheritAttrs: false,
|
|
164
|
-
data() {
|
|
165
|
-
return {
|
|
166
|
-
loadingView: false,
|
|
167
|
-
loadingSuggestions: false,
|
|
168
|
-
labels: [],
|
|
169
|
-
activeLabel: null,
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
computed: {
|
|
173
|
-
currentValue() {
|
|
174
|
-
return this.value.data.toLowerCase();
|
|
175
|
-
},
|
|
176
|
-
containerStyle() {
|
|
177
|
-
if (this.activeLabel) {
|
|
178
|
-
const { color, text_color } = this.activeLabel;
|
|
179
|
-
|
|
180
|
-
return { backgroundColor: color, color: text_color };
|
|
181
|
-
}
|
|
182
|
-
return {};
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
methods: {
|
|
186
|
-
loadView() {
|
|
187
|
-
this.loadingView = true;
|
|
188
|
-
setTimeout(() => {
|
|
189
|
-
this.loadingView = false;
|
|
190
|
-
this.activeLabel = fakeLabels.find((l) => l.title === this.value.data);
|
|
191
|
-
}, 100);
|
|
192
|
-
},
|
|
193
|
-
loadSuggestions() {
|
|
194
|
-
this.loadingSuggestions = true;
|
|
195
|
-
setTimeout(() => {
|
|
196
|
-
this.loadingSuggestions = false;
|
|
197
|
-
this.labels = fakeLabels;
|
|
198
|
-
}, 2000);
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
watch: {
|
|
202
|
-
// eslint-disable-next-line func-names
|
|
203
|
-
'value.data': function () {
|
|
204
|
-
if (this.active) {
|
|
205
|
-
this.loadSuggestions();
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
active: {
|
|
209
|
-
immediate: true,
|
|
210
|
-
handler(newValue) {
|
|
211
|
-
if (!newValue) {
|
|
212
|
-
this.loadView();
|
|
213
|
-
} else {
|
|
214
|
-
this.loadSuggestions();
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
template: `
|
|
220
|
-
<gl-filtered-search-token
|
|
221
|
-
v-bind="{ ...this.$props, ...this.$attrs }"
|
|
222
|
-
v-on="$listeners"
|
|
223
|
-
>
|
|
224
|
-
<template #view-token="{ inputValue, cssClasses, listeners }">
|
|
225
|
-
<gl-token variant="search-value" :class="cssClasses" :style="containerStyle" v-on="listeners">
|
|
226
|
-
{{ activeLabel ? activeLabel.title : inputValue }}
|
|
227
|
-
</gl-token>
|
|
228
|
-
</template>
|
|
229
|
-
<template #suggestions>
|
|
230
|
-
<gl-filtered-search-suggestion value="None">None</gl-filtered-search-suggestion>
|
|
231
|
-
<gl-filtered-search-suggestion value="Any">Any</gl-filtered-search-suggestion>
|
|
232
|
-
<gl-dropdown-divider v-if="loadingSuggestions || labels.length" />
|
|
233
|
-
<template v-if="loadingSuggestions">
|
|
234
|
-
<gl-loading-icon />
|
|
235
|
-
</template>
|
|
236
|
-
<template v-else>
|
|
237
|
-
<gl-filtered-search-suggestion :key="label.id" v-for="label in labels" :value="label.title">
|
|
238
|
-
<div class="d-flex">
|
|
239
|
-
<span
|
|
240
|
-
:style="{ backgroundColor: label.color, height: '16px', width: '16px' }"
|
|
241
|
-
class="d-inline-block mr-2"
|
|
242
|
-
></span>
|
|
243
|
-
{{ label.title }}
|
|
244
|
-
</div>
|
|
245
|
-
</gl-filtered-search-suggestion>
|
|
246
|
-
</template>
|
|
247
|
-
</template>
|
|
248
|
-
</gl-filtered-search-token>
|
|
249
|
-
`,
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const tokens = [
|
|
253
|
-
{
|
|
254
|
-
type: 'author',
|
|
255
|
-
icon: 'pencil',
|
|
256
|
-
title: 'Author',
|
|
257
|
-
dataType: 'user',
|
|
258
|
-
unique: true,
|
|
259
|
-
token: UserToken,
|
|
260
|
-
},
|
|
261
|
-
{ type: 'user', icon: 'user', title: 'Assignee', dataType: 'user', token: UserToken },
|
|
262
|
-
{ type: 'milestone', icon: 'clock', title: 'Milestone', unique: true, token: MilestoneToken },
|
|
263
|
-
{ type: 'label', icon: 'labels', title: 'Label', token: LabelToken },
|
|
264
|
-
{
|
|
265
|
-
type: 'weight',
|
|
266
|
-
icon: 'weight',
|
|
267
|
-
title: 'Weight',
|
|
268
|
-
unique: true,
|
|
269
|
-
token: 'gl-filtered-search-token',
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
type: 'confidential',
|
|
273
|
-
icon: 'eye-slash',
|
|
274
|
-
title: 'Confidential',
|
|
275
|
-
unique: true,
|
|
276
|
-
token: 'gl-filtered-search-token',
|
|
277
|
-
options: [
|
|
278
|
-
{ icon: 'eye-slash', value: 'Yes', title: 'Yes' },
|
|
279
|
-
{ icon: 'eye', value: 'No', title: 'No' },
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
];
|
|
283
|
-
|
|
284
|
-
export default {
|
|
285
|
-
data() {
|
|
286
|
-
return {
|
|
287
|
-
tokens,
|
|
288
|
-
value: [
|
|
289
|
-
{ type: 'author', value: { data: 'beta', operator: '=' } },
|
|
290
|
-
{ type: 'label', value: { data: 'Bug', operator: '=' } },
|
|
291
|
-
'raw text',
|
|
292
|
-
],
|
|
293
|
-
};
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
</script>
|
|
297
|
-
|
|
298
|
-
<template>
|
|
299
|
-
<gl-filtered-search v-model="value" :available-tokens="tokens" :show-friendly-text="true" />
|
|
300
|
-
</template>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
const testTokens = [
|
|
3
|
-
{
|
|
4
|
-
type: 'demotoken',
|
|
5
|
-
title: 'Unique',
|
|
6
|
-
icon: 'document',
|
|
7
|
-
token: 'gl-filtered-search-token',
|
|
8
|
-
operators: [{ value: '=', description: 'is', default: 'true' }],
|
|
9
|
-
options: [
|
|
10
|
-
{ icon: 'heart', title: 'heart', value: 1 },
|
|
11
|
-
{ icon: 'hook', title: 'hook', value: 2 },
|
|
12
|
-
],
|
|
13
|
-
unique: true,
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
data() {
|
|
19
|
-
return {
|
|
20
|
-
tokens: testTokens,
|
|
21
|
-
value: [],
|
|
22
|
-
historyItems: [
|
|
23
|
-
[{ type: 'demotoken', value: { operator: '=', data: 1 } }, 'item 1'],
|
|
24
|
-
['item 2', { type: 'demotoken', value: { operator: '=', data: 2 } }],
|
|
25
|
-
],
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
methods: {
|
|
29
|
-
isString(val) {
|
|
30
|
-
return typeof val === 'string';
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
</script>
|
|
35
|
-
<template>
|
|
36
|
-
<div>
|
|
37
|
-
{{ value }}
|
|
38
|
-
<gl-filtered-search v-model="value" :available-tokens="tokens" :history-items="historyItems">
|
|
39
|
-
<template #history-item="{ historyItem }">
|
|
40
|
-
<template v-for="(token, idx) in historyItem">
|
|
41
|
-
<span v-if="isString(token)" :key="idx" class="gl-px-1">{{ token }}</span>
|
|
42
|
-
<span v-else :key="idx" class="gl-px-1">
|
|
43
|
-
<strong>{{ token.type }}</strong> {{ token.value.operator }}
|
|
44
|
-
<strong>{{ token.value.data }}</strong>
|
|
45
|
-
</span>
|
|
46
|
-
</template>
|
|
47
|
-
</template>
|
|
48
|
-
</gl-filtered-search>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|