mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-05-13 21:01:43 +00:00
Create a "Create/Update row" local baserow service, part 2
This commit is contained in:
parent
b916443203
commit
724803f440
56 changed files with 2511 additions and 209 deletions
web-frontend/modules/integrations/localBaserow/components/services
|
@ -0,0 +1,61 @@
|
|||
<template>
|
||||
<div>
|
||||
<FieldMapping
|
||||
v-for="field in fields"
|
||||
:key="field.id"
|
||||
:field="field"
|
||||
:value="getFieldMappingValue(field.id)"
|
||||
@change="updateFieldMapping($event, field.id)"
|
||||
></FieldMapping>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FieldMapping from '@baserow/modules/integrations/localBaserow/components/services/FieldMapping'
|
||||
|
||||
export default {
|
||||
name: 'FieldMappingForm',
|
||||
components: { FieldMapping },
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
fields: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getFieldMappingValue(fieldId) {
|
||||
const mapping = this.value.find(
|
||||
(fieldMapping) => fieldMapping.field_id === fieldId
|
||||
)
|
||||
return mapping?.value || ''
|
||||
},
|
||||
updateFieldMapping(newValue, fieldId) {
|
||||
const event = { field_id: fieldId, value: newValue }
|
||||
const existingMapping = this.value.some(
|
||||
({ field_id: existingId }) => existingId === fieldId
|
||||
)
|
||||
if (existingMapping) {
|
||||
const newMapping = this.value.map((fieldMapping) => {
|
||||
if (fieldMapping.field_id === fieldId) {
|
||||
return { ...fieldMapping, ...event }
|
||||
}
|
||||
return fieldMapping
|
||||
})
|
||||
this.$emit('input', newMapping)
|
||||
} else {
|
||||
// It already exists
|
||||
const newMapping = [...this.value]
|
||||
newMapping.push({
|
||||
field_id: fieldId,
|
||||
...event,
|
||||
})
|
||||
this.$emit('input', newMapping)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue