|
70 | 70 | :rows="tableRows"
|
71 | 71 | :dataLoading="dataLoading"
|
72 | 72 | :emptyMessage="getEmptyMessageForItems(facilityUsers)"
|
| 73 | + :style="{ minHeight: tableMinHeight + 'px' }" |
73 | 74 | sortable
|
74 | 75 | disableBuiltinSorting
|
75 | 76 | @changeSort="changeSortHandler"
|
|
189 | 190 | import store from 'kolibri/store';
|
190 | 191 | import cloneDeep from 'lodash/cloneDeep';
|
191 | 192 | import useNow from 'kolibri/composables/useNow';
|
192 |
| - import { toRefs, ref, computed, onBeforeUnmount, getCurrentInstance } from 'vue'; |
| 193 | + import { toRefs, ref, computed, onBeforeUnmount, onBeforeUpdate, getCurrentInstance } from 'vue'; |
193 | 194 | import { useRoute, useRouter } from 'vue-router/composables';
|
194 | 195 | import pickBy from 'lodash/pickBy';
|
195 | 196 | import debounce from 'lodash/debounce';
|
|
206 | 207 | import PaginatedListContainerWithBackend from 'kolibri-common/components/PaginatedListContainerWithBackend';
|
207 | 208 | import useUser from 'kolibri/composables/useUser';
|
208 | 209 | import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
|
| 210 | + import useKResponsiveElement from 'kolibri-design-system/lib/composables/useKResponsiveElement'; |
209 | 211 | import { themeTokens } from 'kolibri-design-system/lib/styles/theme';
|
210 | 212 |
|
211 | 213 | import { Modals } from '../../../constants';
|
|
245 | 247 | const modalShown = ref(null);
|
246 | 248 | const userToChange = ref(null);
|
247 | 249 | const filterTextboxRef = ref(null);
|
| 250 | + const tableMinHeight = ref(200); |
| 251 | + const { elementHeight } = useKResponsiveElement(); |
248 | 252 |
|
249 | 253 | const { selectAllLabel$ } = enhancedQuizManagementStrings;
|
250 | 254 | const {
|
|
611 | 615 | }
|
612 | 616 | };
|
613 | 617 |
|
| 618 | + const getTableHeight = () => { |
| 619 | + if (elementHeight.value && facilityUsers.value) { |
| 620 | + // Set min-height to elementHeight if there are enough users to scroll the table |
| 621 | + if (facilityUsers.value.length > 10) { |
| 622 | + tableMinHeight.value = elementHeight.value - 100; // minus 100 to prevent inner scrollbar from appearing |
| 623 | + } else { |
| 624 | + tableMinHeight.value = 200; |
| 625 | + } |
| 626 | + } |
| 627 | + }; |
| 628 | +
|
| 629 | + onBeforeUpdate(() => { |
| 630 | + getTableHeight(); |
| 631 | + }); |
| 632 | +
|
614 | 633 | onBeforeUnmount(() => {
|
615 | 634 | const { query } = route;
|
616 | 635 | if (query.ordering || query.order || query.page) {
|
|
647 | 666 | userToChangeSet,
|
648 | 667 | filterTextboxRef,
|
649 | 668 | stickyColumns,
|
| 669 | + tableMinHeight, |
650 | 670 |
|
651 | 671 | // Methods
|
652 | 672 | handleSelectAllToggle,
|
|
770 | 790 | min-height: 0;
|
771 | 791 | }
|
772 | 792 |
|
| 793 | + // Vertically center KCircularLoader within the table |
| 794 | + /deep/ .k-table-wrapper > p { |
| 795 | + position: absolute; |
| 796 | + top: 50%; |
| 797 | + left: 50%; |
| 798 | + margin: 0; |
| 799 | + transform: translate(-50%, -50%); |
| 800 | + } |
| 801 | +
|
773 | 802 | </style>
|
0 commit comments