mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: fix calendar users loading for multiselect
This commit is contained in:
parent
f2d79919f0
commit
07f086dd61
@ -4,29 +4,23 @@
|
|||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
name="field"
|
name="field"
|
||||||
id="calendarUserSelector"
|
id="calendarUserSelector"
|
||||||
v-model="values"
|
v-model="value"
|
||||||
track-by="id"
|
track-by="id"
|
||||||
label="value"
|
label="value"
|
||||||
:custom-label="transName"
|
:custom-label="transName"
|
||||||
:placeholder="$t('select_user')"
|
:placeholder="$t('select_user')"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:close-on-select="false"
|
:close-on-select="false"
|
||||||
:allow-empty="true"
|
:allow-empty="true"
|
||||||
:options="users">
|
:model-value="value"
|
||||||
<template slot="selection" slot-scope="{ values, search, isOpen }">
|
@update:model-value="updateUsers"
|
||||||
<span class="multiselect__single" v-if="values.length && !isOpen">{{ values.length }} options selected</span>
|
:options="options">
|
||||||
</template>
|
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
<div>
|
</div>
|
||||||
<ul>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { getUniqueUserCalendarRanges } from './js/api'
|
import { fetchCalendarRanges } from './js/api'
|
||||||
import VueMultiselect from 'vue-multiselect';
|
import VueMultiselect from 'vue-multiselect';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -34,30 +28,57 @@ export default {
|
|||||||
components: { VueMultiselect },
|
components: { VueMultiselect },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
errorMsg: {},
|
errorMsg: [],
|
||||||
userCalendarRanges: [],
|
value: [],
|
||||||
values: [],
|
options: []
|
||||||
// selectedValues: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
users() {
|
|
||||||
return this.userCalendarRanges;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
this.userCalendarRanges = getUniqueUserCalendarRanges();
|
this.getUniqueUserCalendarRanges()
|
||||||
|
},
|
||||||
|
getUniqueUserCalendarRanges() {
|
||||||
|
fetchCalendarRanges().then(calendarRanges => new Promise((resolve, reject) => {
|
||||||
|
let users = [];
|
||||||
|
calendarRanges.results.forEach(i => {
|
||||||
|
if (!(users.some(j => i.user.id === j.id))){
|
||||||
|
users.push({
|
||||||
|
id: i.user.id,
|
||||||
|
username: i.user.username
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.options = users;
|
||||||
|
resolve()
|
||||||
|
}))
|
||||||
|
.catch((error) => {
|
||||||
|
this.errorMsg.push(error.message);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
transName(value) {
|
transName(value) {
|
||||||
return `${value.username}`;
|
return `${value.username}`;
|
||||||
},
|
},
|
||||||
// selectUser(value) {
|
updateUsers(value) {
|
||||||
// this.selectedValues.push(value);
|
console.log(value)
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
<style lang="scss">
|
||||||
|
span.multiselect__tag {
|
||||||
|
background: var(--bs-chill-orange);
|
||||||
|
}
|
||||||
|
span.multiselect__option--highlight {
|
||||||
|
&::after {
|
||||||
|
background: var(--bs-chill-green);
|
||||||
|
}
|
||||||
|
&.multiselect__option--selected::after {
|
||||||
|
background: var(--bs-chill-red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -12,14 +12,6 @@ const fetchCalendarRanges = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUniqueUserCalendarRanges = () => { //TODO build the array with fetchCalendarRanges
|
|
||||||
return [
|
|
||||||
{userId: 1, username: 'blop'},
|
|
||||||
{userId: 2, username: 'blup'}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
fetchCalendarRanges,
|
fetchCalendarRanges
|
||||||
getUniqueUserCalendarRanges
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user