|
1 | 1 | <template>
|
2 |
| - <div> |
3 |
| - <template v-for="value in values"> |
4 |
| - <span class="uk-label uk-label-muted">{{ label(value) }}</span> |
5 |
| - <br v-if="!isLastValue(value)" /> |
6 |
| - </template> |
7 |
| - </div> |
| 2 | + <div> |
| 3 | + <template v-for="value in values"> |
| 4 | + <span class="uk-label uk-label-muted">{{ label(value) }}</span> |
| 5 | + <br v-if="!isLastValue(value)" /> |
| 6 | + </template> |
| 7 | + </div> |
8 | 8 | </template>
|
9 | 9 | <script>
|
10 |
| - import _abstract from "./_abstract"; |
11 |
| - export default { |
12 |
| - extends: _abstract, |
13 |
| - methods: { |
14 |
| - label(value) { |
15 |
| -
|
16 |
| - if(!value) { |
17 |
| - return null; |
18 |
| - } |
19 |
| -
|
20 |
| - let enumType = this.$unite.getRawType(this.field.returnType); |
21 |
| -
|
22 |
| - if(!enumType) { |
23 |
| - return null; |
24 |
| - } |
25 |
| -
|
26 |
| - let labels = enumType.enumValues.filter((val) => { |
27 |
| - return val.name === value; |
28 |
| - }).map((val) => { |
29 |
| - return val.description || val.name; |
30 |
| - }); |
31 |
| -
|
32 |
| - return labels.length > 0 ? labels[0] : value; |
33 |
| - } |
34 |
| - } |
35 |
| - } |
| 10 | + import _abstract from "./_abstract"; |
| 11 | + import SelectInput from "../../Views/Filter/Input/SelectInput"; |
| 12 | +
|
| 13 | + export default { |
| 14 | + extends: _abstract, |
| 15 | +
|
| 16 | + // static filter method |
| 17 | + filter(field, view, unite) { |
| 18 | +
|
| 19 | + let enumType = unite.getRawType(field.returnType); |
| 20 | +
|
| 21 | + if(!enumType) { |
| 22 | + return false; |
| 23 | + } |
| 24 | +
|
| 25 | + return { |
| 26 | + searchable: false, |
| 27 | + id: field.id, |
| 28 | + label: field.name.slice(0, 1).toUpperCase() + field.name.slice(1), |
| 29 | + input: SelectInput, |
| 30 | + operators: ['EQ', 'NEQ'], |
| 31 | + inputProps: { |
| 32 | + options: enumType.enumValues.map((value) => { |
| 33 | + return {label: value.description, value: value.name} |
| 34 | + }) |
| 35 | + }, |
| 36 | + }; |
| 37 | + }, |
| 38 | +
|
| 39 | + methods: { |
| 40 | + label(value) { |
| 41 | +
|
| 42 | + if(!value) { |
| 43 | + return null; |
| 44 | + } |
| 45 | +
|
| 46 | + let enumType = this.$unite.getRawType(this.field.returnType); |
| 47 | +
|
| 48 | + if(!enumType) { |
| 49 | + return null; |
| 50 | + } |
| 51 | +
|
| 52 | + let labels = enumType.enumValues.filter((val) => { |
| 53 | + return val.name === value; |
| 54 | + }).map((val) => { |
| 55 | + return val.description || val.name; |
| 56 | + }); |
| 57 | +
|
| 58 | + return labels.length > 0 ? labels[0] : value; |
| 59 | + } |
| 60 | + } |
| 61 | + } |
36 | 62 | </script>
|
0 commit comments