Skip to content

Commit ab77d48

Browse files
authored
Fixes for grid and other views (baserow#4575)
1 parent 8947f0f commit ab77d48

File tree

31 files changed

+273
-145
lines changed

31 files changed

+273
-145
lines changed

enterprise/web-frontend/modules/baserow_enterprise/pages/admin/authProviders.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<script setup>
4242
import { ref, computed, nextTick } from 'vue'
4343
import { useStore } from 'vuex'
44-
import { useNuxtApp, definePageMeta, useI18n } from '#imports'
44+
import { useNuxtApp, definePageMeta, useI18n, useHead } from '#imports'
4545
import CreateAuthProviderContext from '@baserow_enterprise/components/admin/contexts/CreateAuthProviderContext.vue'
4646
import CreateAuthProviderModal from '@baserow_enterprise/components/admin/modals/CreateAuthProviderModal.vue'
4747
@@ -56,6 +56,8 @@ const store = useStore()
5656
const { $registry } = useNuxtApp()
5757
const { t: $t } = useI18n()
5858
59+
useHead({ title: $t('authProviders.title') })
60+
5961
// Template refs
6062
const createContextLink = ref(null)
6163
const createContext = ref(null)

enterprise/web-frontend/modules/baserow_enterprise/pages/auditLog.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import {
106106
createError,
107107
definePageMeta,
108108
useI18n,
109+
useHead,
109110
} from '#imports'
110111
import _ from 'lodash'
111112
import moment from '@baserow/modules/core/moment'
@@ -138,6 +139,8 @@ const router = useRouter()
138139
const { $client, $hasFeature, $hasPermission } = useNuxtApp()
139140
const { t: $t } = useI18n()
140141
142+
useHead({ title: $t('auditLog.adminTitle') })
143+
141144
// Helper function
142145
function initFilters(wsId = null) {
143146
const f = {}

premium/web-frontend/modules/baserow_premium/components/field/FieldAISubForm.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898

9999
<component
100100
:is="outputType.getFormComponent()"
101+
v-if="hasChildFormComponent"
102+
:key="values.ai_output_type"
101103
ref="childForm"
102104
v-bind="$props"
103105
/>
@@ -221,6 +223,9 @@ export default {
221223
this.defaultValues.ai_output_type !== this.values.ai_output_type
222224
)
223225
},
226+
hasChildFormComponent() {
227+
return this.outputType && this.outputType.getFormComponent() !== null
228+
},
224229
},
225230
watch: {
226231
'values.ai_prompt.mode': {

premium/web-frontend/modules/baserow_premium/components/row/RowEditFieldAI.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<component
44
:is="outputRowEditFieldComponent"
55
ref="field"
6-
v-bind="$attrs"
6+
v-bind="$props"
77
:read-only="generating || readOnly"
88
></component>
99
<div v-if="!readOnly" class="margin-top-2">

premium/web-frontend/modules/baserow_premium/components/views/calendar/CalendarMonthDay.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
>
5252
{{
5353
$t('calendarMonthDay.hiddenRowsCount', {
54+
count: hiddenRowsCount,
5455
hiddenRowsCount,
5556
})
5657
}}
@@ -151,16 +152,20 @@ export default {
151152
},
152153
mounted() {
153154
this.updateVisibleRowsCount()
154-
window.addEventListener('resize', this.updateVisibleRowsCount)
155+
this.$el.resizeListener = this.updateVisibleRowsCount.bind(this)
156+
window.addEventListener('resize', this.$el.resizeListener)
155157
},
156158
beforeUnmount() {
157-
window.removeEventListener('resize', this.updateVisibleRowsCount)
159+
window.removeEventListener('resize', this.$el.resizeListener)
158160
},
159161
methods: {
160162
getClientHeight() {
161-
return this.$refs.calendarMonthDay.clientHeight
163+
return this.$refs.calendarMonthDay.clientHeight || 0
162164
},
163165
updateVisibleRowsCount() {
166+
if (!this.$refs.calendarMonthDay) {
167+
return
168+
}
164169
const itemHeight = 28
165170
this.width = this.$refs.calendarMonthDay.clientWidth
166171
this.height = this.getClientHeight()

premium/web-frontend/modules/baserow_premium/components/views/calendar/CalendarMonthDayExpanded.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
:fields="fields"
3434
:store-prefix="storePrefix"
3535
:class="{ last: index == rows.length - 1 }"
36-
:parent-width="contextWidth"
3736
:decorations-by-place="decorationsByPlace"
3837
@edit-row="$emit('edit-row', $event)"
3938
@row-context="$emit('row-context', $event)"
@@ -139,9 +138,6 @@ export default {
139138
maxContextHeight() {
140139
return this.parentHeight * 2 - 10
141140
},
142-
contextWidth() {
143-
return this.$refs.context.$el.clientWidth
144-
},
145141
innerHeight() {
146142
return this.contextHeight - 48
147143
},

premium/web-frontend/modules/baserow_premium/components/views/calendar/CalendarViewHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default {
181181
},
182182
methods: {
183183
showChooseDateFieldModal() {
184-
if (this.canChooseDateField) {
184+
if (this.canChooseDateField && this.$refs.selectDateFieldModal) {
185185
this.$refs.selectDateFieldModal.show()
186186
}
187187
},

premium/web-frontend/modules/baserow_premium/components/views/kanban/KanbanViewStack.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
enabled: () => draggingRow !== null,
66
speed: 3,
77
padding: 24,
8-
scrollElement: () => $refs.scroll.$el,
8+
scrollElement: () => $refs.scroll?.$el,
99
}"
1010
class="kanban-view__stack-wrapper"
1111
@mouseleave.stop="wrapperMouseLeave"
@@ -302,7 +302,9 @@ export default {
302302
},
303303
},
304304
mounted() {
305-
this.updateBuffer()
305+
this.$nextTick(() => {
306+
this.updateBuffer()
307+
})
306308
307309
this.$el.resizeEvent = () => {
308310
this.updateBuffer()
@@ -312,11 +314,19 @@ export default {
312314
}
313315
314316
window.addEventListener('resize', this.$el.resizeEvent)
315-
this.$refs.scroll.$el.addEventListener('scroll', this.$el.scrollEvent)
317+
this.$nextTick(() => {
318+
const scrollEl = this.$refs.scroll?.$el
319+
if (scrollEl) {
320+
this.$el.scrollElement = scrollEl
321+
scrollEl.addEventListener('scroll', this.$el.scrollEvent)
322+
}
323+
})
316324
},
317325
beforeUnmount() {
318326
window.removeEventListener('resize', this.$el.resizeEvent)
319-
this.$refs.scroll.$el.removeEventListener('scroll', this.$el.scrollEvent)
327+
if (this.$el.scrollElement) {
328+
this.$el.scrollElement.removeEventListener('scroll', this.$el.scrollEvent)
329+
}
320330
},
321331
methods: {
322332
/**
@@ -514,9 +524,10 @@ export default {
514524
},
515525
updateBuffer() {
516526
const scroll = this.$refs.scroll
527+
if (!scroll) return
517528
const cardHeight = this.cardHeight
518529
const containerHeight = scroll.clientHeight()
519-
const scrollTop = scroll.$el.scrollTop
530+
const scrollTop = scroll.$el?.scrollTop || 0
520531
const min = Math.ceil(containerHeight / cardHeight) + 2
521532
const rows = this.stack.results.slice(
522533
Math.floor(scrollTop / cardHeight),

premium/web-frontend/modules/baserow_premium/components/views/timeline/TimelineContainer.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ export default {
337337
rowCount() {
338338
return this.rows.length
339339
},
340-
containerHeight() {
341-
return this.rowsCount * this.rowHeight
342-
},
343340
scrollAreaElement() {
344341
return this.$refs.gridBody
345342
},
@@ -409,6 +406,9 @@ export default {
409406
},
410407
'view.timescale'() {
411408
// Update the timescale as soon as it changes in the store.
409+
if (!this.firstVisibleDate) {
410+
return // Grid not initialized yet
411+
}
412412
let currDate = this.firstVisibleDate
413413
.clone()
414414
.add(Math.floor(this.visibleColumnCount / 2), this.unit)
@@ -538,6 +538,9 @@ export default {
538538
*/
539539
updateGridDimensions() {
540540
const el = this.scrollAreaElement
541+
if (!el) {
542+
return
543+
}
541544
this.gridWidth = el.clientWidth
542545
this.gridHeight = el.clientHeight
543546
this.columnWidth = Math.max(
@@ -552,6 +555,9 @@ export default {
552555
*/
553556
getVisibleColumnsRange() {
554557
const el = this.scrollAreaElement
558+
if (!el) {
559+
return { startIndex: 0, endIndex: 0 }
560+
}
555561
const startIndex = Math.floor(el.scrollLeft / this.columnWidth)
556562
const endIndex = startIndex + this.visibleColumnCount + 1
557563
return { startIndex, endIndex }
@@ -570,6 +576,9 @@ export default {
570576
*/
571577
onResizeUpdateGrid() {
572578
const el = this.scrollAreaElement
579+
if (!el) {
580+
return
581+
}
573582
const prevPos = el.scrollLeft / el.scrollWidth
574583
575584
this.updateGridDimensions()
@@ -634,12 +643,15 @@ export default {
634643
*/
635644
getVisibleRowsRange() {
636645
const el = this.scrollAreaElement
646+
if (!el) {
647+
return { startIndex: 0, endIndex: 0 }
648+
}
637649
const elHeight = el.clientHeight
638650
const minRowsToRender = Math.ceil(elHeight / this.rowHeight) + 1
639651
let startIndex = Math.floor(el.scrollTop / this.rowHeight)
640652
let endIndex = startIndex + minRowsToRender
641-
if (endIndex > this.rowsCount) {
642-
endIndex = this.rowsCount
653+
if (endIndex > this.rowCount) {
654+
endIndex = this.rowCount
643655
startIndex = Math.max(0, endIndex - minRowsToRender)
644656
}
645657
return { startIndex, endIndex }

premium/web-frontend/modules/baserow_premium/components/views/timeline/TimelineGrid.vue

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -438,28 +438,32 @@ export default {
438438
* This method is called when a row is resized or moved.
439439
*/
440440
updateRow(row, { startOffset, endOffset }) {
441-
const startField = this.startDateField
442-
const newStartDate = this.getRowDateValue(row, startField).clone()
441+
let start = null
442+
let end = null
443443
444-
if (startOffset !== 0) {
444+
if (startOffset !== 0 && !this.startDateFieldReadOnly) {
445+
const startField = this.startDateField
446+
const newStartDate = this.getRowDateValue(row, startField).clone()
445447
const numberOfUnits = Math.round(startOffset / this.stepPx)
446448
newStartDate.add(numberOfUnits, this.step)
449+
start = this.$registry
450+
.get('field', startField.type)
451+
.formatValue(startField, newStartDate)
447452
}
448-
const start = this.$registry
449-
.get('field', startField.type)
450-
.formatValue(startField, newStartDate)
451453
452-
const endField = this.endDateField
453-
const newEndDate = this.getRowDateValue(row, endField).clone()
454-
if (endOffset !== 0) {
454+
if (endOffset !== 0 && !this.endDateFieldReadOnly) {
455+
const endField = this.endDateField
456+
const newEndDate = this.getRowDateValue(row, endField).clone()
455457
const numberOfUnits = Math.round(endOffset / this.stepPx)
456458
newEndDate.add(numberOfUnits, this.step)
459+
end = this.$registry
460+
.get('field', endField.type)
461+
.formatValue(endField, newEndDate)
457462
}
458-
const end = this.$registry
459-
.get('field', endField.type)
460-
.formatValue(endField, newEndDate)
461463
462-
this.$emit('update-row', { row, start, end })
464+
if (start !== null || end !== null) {
465+
this.$emit('update-row', { row, start, end })
466+
}
463467
},
464468
/*
465469
* Returns the background color for the given row.

0 commit comments

Comments
 (0)