Skip to content

Commit b3f49c6

Browse files
author
henrychoy
committed
fix: correct column alignment
1 parent dbf1e1d commit b3f49c6

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

src/frontend/src/components/TableComponent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
@keydown="keydown"
2121
:rows-per-page-options="props.showAll ? [0] : [5,10,15,20,25,50,0]"
2222
:hideBottom="props.hideBottom && rows.length > 0"
23+
:loading="loading"
2324
>
2425
<template v-slot:header="props">
2526
<q-tr :props="props">

src/frontend/src/dialogs/ImportPluginTasksDialog.vue

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<q-dialog v-model="showDialog">
2+
<q-dialog v-model="showDialog" @show="onDialogShow">
33
<q-card style="display: inline-block; width: auto; max-width: 800px;">
44
<q-card-section class="bg-primary text-white text-h6">
55
Import Plugin Tasks
@@ -29,6 +29,7 @@
2929
v-model:selected="selectedTasks"
3030
selection="multiple"
3131
row-key="name"
32+
:loading="loading"
3233
>
3334
<template #body-cell-name="props">
3435
<div style="font-size: 18px;">
@@ -117,7 +118,10 @@
117118
label="No params listed"
118119
/>
119120
</div>
120-
<div class="column items-end" style="width: 142px; padding-left: 0; padding-right: 0;">
121+
<div
122+
class="column items-end"
123+
:style="{width: outputParamsWidth ? outputParamsWidth + 'px' : '172px',}"
124+
>
121125
<q-chip
122126
v-for="(param, i) in dupliateTasksWithDifferentParams[row.name].outputParams"
123127
:key="i"
@@ -164,7 +168,7 @@
164168
</template>
165169

166170
<script setup>
167-
import { ref, watch, computed } from 'vue'
171+
import { ref, watch, computed, nextTick } from 'vue'
168172
import * as api from '@/services/dataApi'
169173
import TableComponent from '@/components/TableComponent.vue'
170174
import * as notify from '../notify'
@@ -176,6 +180,10 @@ const showDialog = defineModel()
176180
177181
const existingTasksCopy = ref([])
178182
183+
const tableRef = ref()
184+
const outputParamsWidth = ref(0)
185+
const loading = ref(true)
186+
179187
watch(() => showDialog.value, (newVal) => {
180188
if(newVal) {
181189
tasks.value = []
@@ -186,6 +194,30 @@ watch(() => showDialog.value, (newVal) => {
186194
}
187195
})
188196
197+
function getColumnWidthPxByLabel(label) {
198+
const tableEl = (tableRef.value && tableRef.value.$el) || null
199+
if (!tableEl) return 0
200+
const spans = tableEl.querySelectorAll('.header-label')
201+
for (let i = 0; i < spans.length; i++) {
202+
const s = spans[i]
203+
if ((s.textContent || '').trim() === label) {
204+
const th = s.closest('th')
205+
if (th && th.getClientRects().length > 0 && th.offsetParent !== null) {
206+
// minus 8 to account for the left padding in the table headers
207+
return th.getBoundingClientRect().width - 8
208+
}
209+
}
210+
}
211+
return 0
212+
}
213+
214+
function onDialogShow() {
215+
// Let QDialog/QTable finish layout in the next frame
216+
requestAnimationFrame(() => {
217+
outputParamsWidth.value = getColumnWidthPxByLabel("Output Parameters")
218+
})
219+
}
220+
189221
const tasks = ref([])
190222
const selectedTasks = ref([])
191223
const errorMessage = ref('')
@@ -231,6 +263,7 @@ async function suggestPluginTasks() {
231263
selectedTasks.value = tasks.value.filter(
232264
task => !Object.keys(dupliateIdenticalTasks.value).includes(task.name)
233265
)
266+
loading.value = false
234267
} catch(err) {
235268
console.warn(err)
236269
notify.error(err.response.data.message)
@@ -325,4 +358,4 @@ function deepEqual(obj1, obj2, ignoreKeys = []) {
325358
}
326359
327360
328-
</script>
361+
</script>

0 commit comments

Comments
 (0)