Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "bug",
"message": "Fix field mapping when importing CSV",
"issue_origin": "github",
"issue_number": 3259,
"domain": "database",
"bullet_points": [],
"created_at": "2026-01-07"
}
18 changes: 15 additions & 3 deletions web-frontend/modules/database/components/table/ImportFileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<SimpleGrid
class="import-modal__preview"
:rows="previewImportData"
:fields="fields"
:fields="sortedFields"
/>
</Tab>
<Tab :title="$t('importFileModal.filePreview')">
Expand Down Expand Up @@ -245,6 +245,18 @@ export default {
}
},
computed: {
sortedFields() {
// The sort needs to follow the same sort logic as
// RowHandler.import_rows(...) in the backend
return [...this.fields].sort((a, b) => {
const aPrimary = !!a.primary
const bPrimary = !!b.primary
if (aPrimary !== bPrimary) return aPrimary ? -1 : 1
const orderDiff = (a.order ?? 0) - (b.order ?? 0)
if (orderDiff !== 0) return orderDiff
return a.id - b.id
})
},
isTableCreated() {
if (!this.job?.table_id) {
return false
Expand Down Expand Up @@ -281,7 +293,7 @@ export default {
* All writable fields.
*/
writableFields() {
return this.fields.filter((field) =>
return this.sortedFields.filter((field) =>
this.fieldTypes[field.type].canWriteFieldValues(field)
)
},
Expand Down Expand Up @@ -353,7 +365,7 @@ export default {
},
availableUpsertFields() {
const selected = Object.values(this.mapping)
return this.fields.filter((field) => {
return this.sortedFields.filter((field) => {
return (
selected.includes(field.id) && this.fieldTypes[field.type].canUpsert()
)
Expand Down
1 change: 0 additions & 1 deletion web-frontend/modules/database/store/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export const actions = {
const fieldType = $registry.get('field', data.type)
data = populateField(data, $registry)

commit('UPDATE_ITEM', { id: field.id, values: data })
commit('UPDATE_ITEM', { id: field.id, values: data })

// The view might need to do some cleanup regarding the filters and sortings if the
Expand Down
Loading