|
| 1 | +<!-- |
| 2 | + - @copyright Copyright (c) 2023 Maksim Sukharev <antreesy.web@gmail.com> |
| 3 | + - |
| 4 | + - @author Grigorii Shartsev <me@shgk.me> |
| 5 | + - |
| 6 | + - @license AGPL-3.0-or-later |
| 7 | + - |
| 8 | + - This program is free software: you can redistribute it and/or modify |
| 9 | + - it under the terms of the GNU Affero General Public License as |
| 10 | + - published by the Free Software Foundation, either version 3 of the |
| 11 | + - License, or (at your option) any later version. |
| 12 | + - |
| 13 | + - This program is distributed in the hope that it will be useful, |
| 14 | + - but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + - GNU Affero General Public License for more details. |
| 17 | + - |
| 18 | + - You should have received a copy of the GNU Affero General Public License |
| 19 | + - along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + --> |
| 21 | + |
| 22 | +<template> |
| 23 | + <RecycleScroller ref="scroller" |
| 24 | + list-tag="ul" |
| 25 | + item-tag="li" |
| 26 | + :items="participants" |
| 27 | + :item-size="PARTICIPANT_ITEM_SIZE" |
| 28 | + key-field="attendeeId"> |
| 29 | + <template #default="{ item }"> |
| 30 | + <Participant :participant="item" tag="div" /> |
| 31 | + </template> |
| 32 | + <template v-if="loading" #after> |
| 33 | + <LoadingPlaceholder type="participants" :count="dummyParticipants" /> |
| 34 | + </template> |
| 35 | + </RecycleScroller> |
| 36 | +</template> |
| 37 | + |
| 38 | +<script> |
| 39 | +import { RecycleScroller } from 'vue-virtual-scroller' |
| 40 | +
|
| 41 | +import LoadingPlaceholder from '../../../LoadingPlaceholder.vue' |
| 42 | +import Participant from './Participant/Participant.vue' |
| 43 | +
|
| 44 | +import 'vue-virtual-scroller/dist/vue-virtual-scroller.css' |
| 45 | +
|
| 46 | +const PARTICIPANT_ITEM_SIZE = 64 |
| 47 | +
|
| 48 | +export default { |
| 49 | + name: 'ParticipantsListVirtual', |
| 50 | +
|
| 51 | + components: { |
| 52 | + LoadingPlaceholder, |
| 53 | + Participant, |
| 54 | + RecycleScroller, |
| 55 | + }, |
| 56 | +
|
| 57 | + props: { |
| 58 | + participants: { |
| 59 | + type: Array, |
| 60 | + required: true, |
| 61 | + }, |
| 62 | +
|
| 63 | + loading: { |
| 64 | + type: Boolean, |
| 65 | + default: false, |
| 66 | + }, |
| 67 | + }, |
| 68 | +
|
| 69 | + setup() { |
| 70 | + return { |
| 71 | + PARTICIPANT_ITEM_SIZE, |
| 72 | + } |
| 73 | + }, |
| 74 | +
|
| 75 | + computed: { |
| 76 | + dummyParticipants() { |
| 77 | + const dummies = 6 - this.participants.length |
| 78 | + return dummies > 0 ? dummies : 0 |
| 79 | + }, |
| 80 | + }, |
| 81 | +} |
| 82 | +</script> |
0 commit comments