@fishawack/lab-velocity 2.0.0-beta.36 → 2.0.0-beta.38
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.
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
:remote-method="endpoint ? handleSearch : undefined"
|
|
21
21
|
:loading="initialLoading"
|
|
22
22
|
:empty-values="[null, undefined]"
|
|
23
|
+
:value-key="effectiveValueKey"
|
|
23
24
|
@change="handleInput"
|
|
24
25
|
@clear="$emit('clear')"
|
|
25
26
|
@blur="$emit('blur')"
|
|
@@ -27,30 +28,22 @@
|
|
|
27
28
|
>
|
|
28
29
|
<template #default>
|
|
29
30
|
<slot name="default">
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</template>
|
|
39
|
-
<template v-else>
|
|
40
|
-
<el-option
|
|
41
|
-
v-for="option in currentOptions"
|
|
42
|
-
:key="option.value"
|
|
43
|
-
:label="option.label"
|
|
44
|
-
:disabled="option.disabled"
|
|
45
|
-
:value="option"
|
|
46
|
-
>
|
|
47
|
-
</el-option>
|
|
48
|
-
</template>
|
|
31
|
+
<el-option
|
|
32
|
+
v-for="option in currentOptions"
|
|
33
|
+
:key="option[effectiveValueKey]"
|
|
34
|
+
:label="option[labelKey]"
|
|
35
|
+
:disabled="option.disabled"
|
|
36
|
+
:value="option"
|
|
37
|
+
>
|
|
38
|
+
</el-option>
|
|
49
39
|
</slot>
|
|
50
40
|
</template>
|
|
51
41
|
<template v-if="endpoint" #loading>
|
|
52
42
|
<div class="el-select-dropdown__loading">Loading...</div>
|
|
53
43
|
</template>
|
|
44
|
+
<template #label="{ value }">
|
|
45
|
+
{{ value[labelKey] }}
|
|
46
|
+
</template>
|
|
54
47
|
</el-select>
|
|
55
48
|
</XInput>
|
|
56
49
|
</template>
|
|
@@ -117,7 +110,7 @@ export default {
|
|
|
117
110
|
},
|
|
118
111
|
valueKey: {
|
|
119
112
|
type: String,
|
|
120
|
-
default:
|
|
113
|
+
default: null,
|
|
121
114
|
},
|
|
122
115
|
searchParam: {
|
|
123
116
|
type: String,
|
|
@@ -155,6 +148,14 @@ export default {
|
|
|
155
148
|
}
|
|
156
149
|
return this.options;
|
|
157
150
|
},
|
|
151
|
+
effectiveValueKey() {
|
|
152
|
+
// If valueKey was explicitly provided, use it
|
|
153
|
+
if (this.valueKey !== null) {
|
|
154
|
+
return this.valueKey;
|
|
155
|
+
}
|
|
156
|
+
// Otherwise, use "id" for endpoints, "value" for static options
|
|
157
|
+
return this.endpoint ? "id" : "value";
|
|
158
|
+
},
|
|
158
159
|
},
|
|
159
160
|
|
|
160
161
|
mounted() {
|
|
@@ -215,35 +216,28 @@ export default {
|
|
|
215
216
|
},
|
|
216
217
|
|
|
217
218
|
methods: {
|
|
218
|
-
castValue(value) {
|
|
219
|
-
if (
|
|
220
|
-
!_.isNull(value) &&
|
|
221
|
-
typeof value === "string" &&
|
|
222
|
-
value !== "" &&
|
|
223
|
-
!isNaN(Number(value))
|
|
224
|
-
) {
|
|
225
|
-
return parseInt(value);
|
|
226
|
-
}
|
|
227
|
-
return value;
|
|
228
|
-
},
|
|
229
|
-
|
|
230
219
|
async handleVisibleChange(visible) {
|
|
231
220
|
// Load data when dropdown is opened for the first time
|
|
232
221
|
if (visible && this.endpoint && !this.initialLoadDone) {
|
|
233
|
-
await this.
|
|
234
|
-
this.initialLoadDone = true;
|
|
222
|
+
await this.handleSearch("");
|
|
235
223
|
}
|
|
236
224
|
},
|
|
237
225
|
|
|
238
226
|
async handleSearch(query) {
|
|
239
227
|
if (!this.endpoint) return;
|
|
240
|
-
if (query === this.lastSearchQuery) return;
|
|
241
228
|
|
|
242
|
-
|
|
243
|
-
this.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
229
|
+
// For initial load, allow empty query even if it matches lastSearchQuery
|
|
230
|
+
if (!this.initialLoadDone || query !== this.lastSearchQuery) {
|
|
231
|
+
this.searchQuery = query;
|
|
232
|
+
this.lastSearchQuery = query;
|
|
233
|
+
this.currentPage = 1;
|
|
234
|
+
this.asyncOptions = [];
|
|
235
|
+
await this.fetchOptions(1, query);
|
|
236
|
+
|
|
237
|
+
if (!this.initialLoadDone) {
|
|
238
|
+
this.initialLoadDone = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
247
241
|
},
|
|
248
242
|
|
|
249
243
|
handleEndReached(direction) {
|
|
@@ -280,18 +274,11 @@ export default {
|
|
|
280
274
|
const data = response.data.data || [];
|
|
281
275
|
const meta = response.data.meta;
|
|
282
276
|
|
|
283
|
-
// Transform API data to option format
|
|
284
|
-
const newOptions = data.map((item) => ({
|
|
285
|
-
label: item[this.labelKey],
|
|
286
|
-
value: item[this.valueKey],
|
|
287
|
-
disabled: item.disabled || false,
|
|
288
|
-
}));
|
|
289
|
-
|
|
290
277
|
// If it's the first page, replace options, otherwise append
|
|
291
278
|
if (page === 1) {
|
|
292
|
-
this.asyncOptions =
|
|
279
|
+
this.asyncOptions = data;
|
|
293
280
|
} else {
|
|
294
|
-
this.asyncOptions = [...this.asyncOptions, ...
|
|
281
|
+
this.asyncOptions = [...this.asyncOptions, ...data];
|
|
295
282
|
}
|
|
296
283
|
|
|
297
284
|
this.currentPage = page;
|
|
@@ -63,10 +63,24 @@ export function adminRoutes(node, overrides = {}) {
|
|
|
63
63
|
[
|
|
64
64
|
...resourceRoutes(
|
|
65
65
|
node,
|
|
66
|
-
...merge(teamResource, [
|
|
66
|
+
...merge(teamResource, [
|
|
67
|
+
undefined,
|
|
68
|
+
merge(overrideCompanyResource, {
|
|
69
|
+
routeName: "companies.teams",
|
|
70
|
+
}),
|
|
71
|
+
]),
|
|
67
72
|
),
|
|
68
73
|
],
|
|
69
74
|
),
|
|
75
|
+
...resourceRoutes(
|
|
76
|
+
node,
|
|
77
|
+
...merge(teamResource, [
|
|
78
|
+
undefined,
|
|
79
|
+
merge(overrideCompanyResource, {
|
|
80
|
+
routeName: "teams",
|
|
81
|
+
}),
|
|
82
|
+
]),
|
|
83
|
+
),
|
|
70
84
|
];
|
|
71
85
|
}
|
|
72
86
|
|
|
@@ -15,6 +15,7 @@ import VelRoleLegend from "../../../../components/layout/RoleLegend.vue";
|
|
|
15
15
|
import VelTableSorter from "../../../../components/layout/TableSorter.vue";
|
|
16
16
|
import VelButton from "../../../../components/basic/Button.vue";
|
|
17
17
|
import VelCheckbox from "../../../../components/form/Checkbox.vue";
|
|
18
|
+
import VelSelect from "../../../../components/form/Select.vue";
|
|
18
19
|
|
|
19
20
|
export default [
|
|
20
21
|
"teams",
|
|
@@ -48,12 +49,33 @@ export default [
|
|
|
48
49
|
{
|
|
49
50
|
key: "company_id",
|
|
50
51
|
label: "Company",
|
|
51
|
-
|
|
52
|
+
endpoint: "api/companies",
|
|
53
|
+
labelKey: "name",
|
|
54
|
+
filterable: true,
|
|
55
|
+
searchParam: "name",
|
|
56
|
+
condition: {
|
|
57
|
+
form: {
|
|
58
|
+
write: ({ $route, model }) =>
|
|
59
|
+
!$route.params.companiesId && !model?.company,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
initial: ({ model, $route }) =>
|
|
63
|
+
model?.company ||
|
|
64
|
+
($route.params.companiesId && {
|
|
65
|
+
id: $route.params.companiesId,
|
|
66
|
+
}),
|
|
67
|
+
preparation: ({ form }) => form.company_id?.id,
|
|
52
68
|
render: {
|
|
53
69
|
read: ({ model }) => h("span", model.company.name),
|
|
70
|
+
write: () => h(VelSelect),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "user_count",
|
|
75
|
+
label: "Users",
|
|
76
|
+
condition: {
|
|
77
|
+
form: false,
|
|
54
78
|
},
|
|
55
|
-
initial: ({ $route, model }) =>
|
|
56
|
-
model?.company_id || $route.params.companiesId || null,
|
|
57
79
|
},
|
|
58
80
|
{
|
|
59
81
|
key: "roles",
|