|
1 | 1 | <template> |
2 | 2 | <div> |
3 | 3 | <div class="input-group"> |
4 | | - <button |
5 | | - type="button" |
6 | | - class="btn btn-outline-secondary dropdown-toggle" |
7 | | - :disabled="disabled" |
8 | | - data-bs-toggle="dropdown" |
9 | | - aria-haspopup="true" |
10 | | - aria-expanded="false" |
11 | | - > |
12 | | - <span v-if="v.startLabel.value"> |
13 | | - {{ t(`main.entity.attributes.${v.startLabel.value}`) }} |
14 | | - </span> |
15 | | - <span v-else> |
16 | | - <!-- TODO: Check if this else is required --> |
17 | | - </span> |
18 | | - </button> |
19 | | - <ul class="dropdown-menu"> |
20 | | - <a |
21 | | - v-for="(label, i) in timeLabels" |
22 | | - :key="i" |
23 | | - class="dropdown-item" |
24 | | - href="#" |
25 | | - @click.prevent="setLabel('startLabel', label)" |
26 | | - > |
27 | | - {{ t(`main.entity.attributes.${label}`) }} |
28 | | - </a> |
29 | | - </ul> |
| 4 | + <common-era-dropdown |
| 5 | + :model-value="v.startLabel.value" |
| 6 | + :format="epochFormat" |
| 7 | + @update:modelValue="(value) => setLabel('startLabel', value)" |
| 8 | + /> |
30 | 9 | <input |
31 | 10 | v-model.number="v.start.value" |
32 | 11 | type="number" |
|
50 | 29 | aria-label="" |
51 | 30 | @input="v.end.handleInput" |
52 | 31 | > |
53 | | - <button |
54 | | - type="button" |
55 | | - class="btn btn-outline-secondary dropdown-toggle" |
56 | | - :disabled="disabled" |
57 | | - data-bs-toggle="dropdown" |
58 | | - aria-haspopup="true" |
59 | | - aria-expanded="false" |
60 | | - > |
61 | | - <span v-if="v.endLabel.value"> |
62 | | - {{ t(`main.entity.attributes.${v.endLabel.value}`) }} |
63 | | - </span> |
64 | | - <span v-else> |
65 | | - <!-- TODO: Check if this else is required --> |
66 | | - </span> |
67 | | - </button> |
68 | | - <ul |
69 | | - uib-dropdown-menu |
70 | | - class="dropdown-menu" |
71 | | - > |
72 | | - <a |
73 | | - v-for="(label, i) in timeLabels" |
74 | | - :key="i" |
75 | | - class="dropdown-item" |
76 | | - href="#" |
77 | | - @click.prevent="setLabel('endLabel', label)" |
78 | | - > |
79 | | - {{ t(`main.entity.attributes.${label}`) }} |
80 | | - </a> |
81 | | - </ul> |
| 32 | + <common-era-dropdown |
| 33 | + :model-value="v.endLabel.value" |
| 34 | + :format="epochFormat" |
| 35 | + @update:modelValue="(value) => setLabel('endLabel', value)" |
| 36 | + /> |
82 | 37 | </div> |
83 | 38 | <multiselect |
84 | 39 | v-if="state.hasEpochList" |
|
126 | 81 | translateConcept, |
127 | 82 | multiselectResetClasslist, |
128 | 83 | } from '@/helpers/helpers.js'; |
| 84 | + import CommonEraDropdown from './epoch/CommonEraDropdown.vue'; |
129 | 85 |
|
130 | 86 | export default { |
| 87 | + components: { |
| 88 | + CommonEraDropdown, |
| 89 | + }, |
131 | 90 | props: { |
132 | 91 | name: { |
133 | 92 | type: String, |
|
151 | 110 | disabled: { |
152 | 111 | type: Boolean, |
153 | 112 | }, |
| 113 | + metadata: { |
| 114 | + type: Object, |
| 115 | + required: false, |
| 116 | + default: _ => new Object(), |
| 117 | + }, |
154 | 118 | }, |
155 | 119 | emits: ['change'], |
156 | 120 | setup(props, context) { |
|
200 | 164 | }); |
201 | 165 | }; |
202 | 166 | const setLabel = (field, value) => { |
| 167 | + console.log("setLabel:", field, value); |
203 | 168 | v[field].handleChange(value); |
204 | 169 | }; |
205 | 170 | const handleEpochChange = option => { |
206 | 171 | v.epoch.handleChange(option); |
207 | 172 | }; |
208 | 173 |
|
209 | 174 | // DATA |
210 | | - const timeLabels = ['BC', 'AD']; |
| 175 | +
|
| 176 | +
|
211 | 177 | const { |
212 | 178 | handleInput: his, |
213 | 179 | value: vs, |
|
328 | 294 | } |
329 | 295 | }); |
330 | 296 |
|
| 297 | + const epochFormat = computed(_ => { |
| 298 | + // Default to 'bcad' as it was used before. |
| 299 | + return props.metadata?.epoch_format ?? 'bcad'; |
| 300 | + }); |
| 301 | +
|
331 | 302 | // RETURN |
332 | 303 | return { |
333 | 304 | t, |
334 | 305 | // HELPERS |
| 306 | + epochFormat, |
335 | 307 | translateConcept, |
336 | 308 | multiselectResetClasslist, |
337 | 309 | // LOCAL |
338 | 310 | resetFieldState, |
339 | 311 | undirtyField, |
340 | 312 | setLabel, |
341 | | - timeLabels, |
342 | 313 | handleEpochChange, |
343 | 314 | // STATE |
344 | 315 | state, |
|
0 commit comments