mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add uniq key property, allow multiple entity in suggestions
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="count">
|
||||
|
||||
<span>
|
||||
<a v-if="suggestedCounter > 2" @click="selectAll">
|
||||
{{ $t('action.check_all')}}
|
||||
@@ -42,11 +41,9 @@
|
||||
{{ $t('action.reset')}}
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<span v-if="selectedCounter > 0">
|
||||
{{ $tc('add_persons.selected_counter', selectedCounter) }}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -57,7 +54,7 @@
|
||||
|
||||
<person-suggestion
|
||||
v-for="item in this.selectedAndSuggested.slice().reverse()"
|
||||
v-bind:key="item.id"
|
||||
v-bind:key="itemKey(item)"
|
||||
v-bind:item="item"
|
||||
v-bind:search="search"
|
||||
@updateSelected="updateSelected">
|
||||
@@ -83,7 +80,7 @@
|
||||
<script>
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
||||
import PersonSuggestion from 'ChillPersonAssets/vuejs/_components/PersonSuggestion';
|
||||
import { searchPersons } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
||||
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
|
||||
|
||||
export default {
|
||||
name: 'AddPersons',
|
||||
@@ -143,7 +140,7 @@ export default {
|
||||
...this.suggested.slice().reverse(),
|
||||
...this.selected.slice().reverse(),
|
||||
])];
|
||||
return uniqBy(union, k => k.id);
|
||||
return uniqBy(union, k => k.key);
|
||||
},
|
||||
options() {
|
||||
return this.options;
|
||||
@@ -157,10 +154,9 @@ export default {
|
||||
})
|
||||
},
|
||||
setQuery(query) {
|
||||
//console.log('options 1', this.options);
|
||||
this.search.query = query;
|
||||
if (query.length >= 3) {
|
||||
searchPersons({ query, options: this.options })
|
||||
searchPersons_2({ query, options: this.options })
|
||||
.then(suggested => new Promise((resolve, reject) => {
|
||||
this.loadSuggestions(suggested.results);
|
||||
resolve();
|
||||
@@ -171,6 +167,9 @@ export default {
|
||||
},
|
||||
loadSuggestions(suggested) {
|
||||
this.search.suggested = suggested;
|
||||
this.search.suggested.forEach(function(item) {
|
||||
item.key = this.itemKey(item);
|
||||
}, this);
|
||||
},
|
||||
updateSelected(value) {
|
||||
this.search.selected = value;
|
||||
@@ -190,6 +189,10 @@ export default {
|
||||
this.search.suggested.forEach(function(item) {
|
||||
this.search.selected.push(item);
|
||||
}, this);
|
||||
},
|
||||
itemKey(item) {
|
||||
let type = item.result.type;
|
||||
return type + item.result[type + '_id'];
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user