|
3 | 3 | <multiselect v-if=" inputType=== 'select' && this.constraints['http://schema.org/itemListElement']" |
4 | 4 | v-model="selected" :options="this.options" :searchable="false" |
5 | 5 | :show-labels="false" |
6 | | - placeholder="Pick a value" @input="checkNotOtherAndSendData"> |
| 6 | + placeholder="Pick a value"> |
| 7 | + </multiselect> |
| 8 | + <multiselect v-else-if="multipleAllowed" v-model="selected" id="ajax" |
| 9 | + placeholder="Type to search" |
| 10 | + :options="this.options" :multiple="true" |
| 11 | + :searchable="true" |
| 12 | + :internal-search="true" :clear-on-select="false" |
| 13 | + :close-on-select="true" :options-limit="300" |
| 14 | + :limit="5" :limit-text="limitText" :max-height="600" |
| 15 | + :show-no-results="false" :hide-selected="true"> |
7 | 16 | </multiselect> |
8 | 17 | <multiselect v-else v-model="selected" id="ajax" |
9 | 18 | placeholder="Type to search" |
10 | | - :options="this.options" :multiple="multipleAllowed" |
| 19 | + :options="this.options" |
11 | 20 | :searchable="true" |
12 | 21 | :internal-search="true" :clear-on-select="false" |
13 | 22 | :close-on-select="true" :options-limit="300" |
14 | 23 | :limit="5" :limit-text="limitText" :max-height="600" |
15 | | - :show-no-results="false" :hide-selected="true" |
16 | | - @input="checkNotOtherAndSendData"> |
| 24 | + :show-no-results="false" :hide-selected="false"> |
17 | 25 | <span slot="noResult">{{ $t('select-invalid-query')}}</span> |
18 | 26 | </multiselect> |
19 | 27 | <div v-if="checkOther" id="ifOther" style="display: block;"> |
20 | | - <br><b-form-input v-model="otherInput" placeholder="Please describe" @change="sendData"> |
21 | | - </b-form-input> |
| 28 | + <br> |
| 29 | + <b-form-input v-model="otherInput" placeholder="Please describe"> |
| 30 | + </b-form-input> |
22 | 31 | </div> |
| 32 | + <br> |
| 33 | + <b-form v-if="this.selected" @submit="checkAndSendData"> |
| 34 | + <b-btn type="submit">{{ $t('submit-button')}}</b-btn> |
| 35 | + </b-form> |
23 | 36 | </div> |
24 | | - |
25 | 37 | </template> |
26 | 38 |
|
27 | 39 | <script> |
@@ -57,14 +69,19 @@ export default { |
57 | 69 |
|
58 | 70 | }, |
59 | 71 | methods: { |
60 | | - checkNotOtherAndSendData(val) { |
61 | | - if (val !== 'Other') { |
62 | | - this.$emit('valueChanged', val); |
| 72 | + checkAndSendData() { |
| 73 | + if (this.selected) { |
| 74 | + if (this.selected.includes('Other')) { |
| 75 | + if (this.multipleAllowed) { |
| 76 | + this.$emit('valueChanged', [...this.selected.slice(0, -1), this.otherInput]); |
| 77 | + } else { |
| 78 | + this.$emit('valueChanged', this.otherInput); |
| 79 | + } |
| 80 | + } else { |
| 81 | + this.$emit('valueChanged', this.selected); |
| 82 | + } |
63 | 83 | } |
64 | 84 | }, |
65 | | - sendData(val) { |
66 | | - this.$emit('valueChanged', [this.selected, val]); |
67 | | - }, |
68 | 85 | limitText(count) { |
69 | 86 | return `and ${count} other countries`; |
70 | 87 | }, |
@@ -97,12 +114,13 @@ export default { |
97 | 114 | multipleAllowed() { |
98 | 115 | if (this.constraints['http://schema.repronim.org/multipleChoice']) { |
99 | 116 | // console.log(94, this.constraints[this.reprotermsUrl+'multipleChoice']); |
100 | | - return true; |
101 | | - } return false; |
| 117 | + return this.constraints['http://schema.repronim.org/multipleChoice'][0]['@value']; |
| 118 | + } |
| 119 | + return false; |
102 | 120 | }, |
103 | 121 | checkOther() { |
104 | | - if (this.selected === 'Other') { |
105 | | - return true; |
| 122 | + if (this.selected) { |
| 123 | + return this.selected.includes('Other'); |
106 | 124 | } |
107 | 125 | return false; |
108 | 126 | }, |
|
0 commit comments