Web: resize the Tasks table after loading the job blocklist

Emit a 'reshuffled' event to let the job view resize the tasks table.
This commit is contained in:
Sybren A. Stüvel 2022-08-01 18:44:50 +02:00
parent 9d65f6f4de
commit 023d392560

View File

@ -26,10 +26,12 @@
import { apiClient } from '@/stores/api-query-count'; import { apiClient } from '@/stores/api-query-count';
import { JobsApi } from '@/manager-api'; import { JobsApi } from '@/manager-api';
import LinkWorker from '@/components/LinkWorker.vue'; import LinkWorker from '@/components/LinkWorker.vue';
import { watch, onMounted, inject, ref } from 'vue' import { watch, onMounted, inject, ref, nextTick } from 'vue'
// jobID should be the job UUID string. // jobID should be the job UUID string.
const props = defineProps(['jobID']); const props = defineProps(['jobID']);
const emit = defineEmits(['reshuffled'])
const jobsApi = new JobsApi(apiClient); const jobsApi = new JobsApi(apiClient);
const isVisible = inject("isVisible"); const isVisible = inject("isVisible");
const isFetching = ref(false); const isFetching = ref(false);
@ -44,9 +46,7 @@ function refreshBlocklist() {
isFetching.value = true; isFetching.value = true;
jobsApi.fetchJobBlocklist(props.jobID) jobsApi.fetchJobBlocklist(props.jobID)
.then((newBlocklist) => { .then((newBlocklist) => {
console.log(`received blocklist for job ${props.jobID}`, newBlocklist);
blocklist.value = newBlocklist; blocklist.value = newBlocklist;
// TODO: remit 'reshuffled' & handle in parent.
}) })
.catch((error) => { .catch((error) => {
errorMsg.value = error.message; errorMsg.value = error.message;
@ -57,6 +57,9 @@ function refreshBlocklist() {
} }
watch(() => props.jobID, refreshBlocklist); watch(() => props.jobID, refreshBlocklist);
watch(blocklist, () => {
nextTick(() => { emit("reshuffled") })
})
watch(isVisible, refreshBlocklist); watch(isVisible, refreshBlocklist);
onMounted(refreshBlocklist); onMounted(refreshBlocklist);
</script> </script>