mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* revert: undo unnecessary frontend changes fromf6a7d302fRevert all frontend changes introduced in "fix: bug in public view with hidden group by" (f6a7d302f). The backend changes from that commit are kept as they are the actual fix for the public view bug. The reverted frontend changes caused a regression where group bys would flicker (disappear and reappear) when changing the group by order, because activeGroupBys was being cleared at the start of every refresh. * fix: public view crash when group by is added or removed Add ViewType.forceViewRefresh() method that handles updating the view, fields, and (for grid views) activeGroupBys atomically during a force_view_refresh realtime event. This prevents components from accessing fields that have been removed or haven't been added yet. Also fix LinkRowFieldType.isEqual crashing with null/undefined values when rows have no linked items. * fix: inconsistency in counting hidden fields in grid view * fix issue deleting/restoring group bys
157 lines
4.2 KiB
Vue
157 lines
4.2 KiB
Vue
<template>
|
|
<Modal ref="modal" :tiny="true" @show="hideError()">
|
|
<h2 class="box__title">
|
|
{{ $t('duplicateFieldContext.duplicate') }}
|
|
</h2>
|
|
<Error :error="error"></Error>
|
|
<form @submit.prevent="duplicateField()">
|
|
<div class="control margin-bottom-1">
|
|
<div class="control__elements">
|
|
<Checkbox v-model="duplicateData" :disabled="formFieldTypeIsReadOnly">
|
|
{{
|
|
$t(
|
|
formFieldTypeIsReadOnly
|
|
? 'duplicateFieldContext.readOnlyField'
|
|
: 'duplicateFieldContext.cloneData'
|
|
)
|
|
}}
|
|
</Checkbox>
|
|
</div>
|
|
</div>
|
|
<div class="actions actions--right">
|
|
<Button
|
|
ref="submitButton"
|
|
type="primary"
|
|
:loading="loading"
|
|
:disabled="loading"
|
|
>
|
|
{{ $t('action.duplicate') }}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</Modal>
|
|
</template>
|
|
|
|
<script>
|
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
import { createNewUndoRedoActionGroupId } from '@baserow/modules/database/utils/action'
|
|
import FieldService from '@baserow/modules/database/services/field'
|
|
import jobProgress from '@baserow/modules/core/mixins/jobProgress'
|
|
import error from '@baserow/modules/core/mixins/error'
|
|
import modal from '@baserow/modules/core/mixins/modal'
|
|
|
|
export default {
|
|
name: 'DuplicateFieldModal',
|
|
mixins: [modal, error, jobProgress],
|
|
props: {
|
|
table: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
fromField: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
allFieldsInTable: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
},
|
|
emits: ['field-created', 'move-field'],
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
duplicateData: true,
|
|
actionGroupId: null,
|
|
}
|
|
},
|
|
computed: {
|
|
existingFieldName() {
|
|
return this.allFieldsInTable.map((field) => field.name)
|
|
},
|
|
formFieldTypeIsReadOnly() {
|
|
const fieldType = this.$registry.get('field', this.fromField.type)
|
|
return fieldType.isReadOnlyField(this.fromField)
|
|
},
|
|
},
|
|
methods: {
|
|
onDuplicationEnd() {
|
|
this.loading = false
|
|
this.actionGroupId = null
|
|
},
|
|
showError(title, message) {
|
|
this.$store.dispatch('toast/error', { title, message }, { root: true })
|
|
},
|
|
|
|
async onJobFailed() {
|
|
this.onDuplicationEnd()
|
|
this.showError(
|
|
this.$t('clientHandler.notCompletedTitle'),
|
|
this.$t('clientHandler.notCompletedDescription')
|
|
)
|
|
},
|
|
|
|
async onJobPollingError(error) {
|
|
this.onDuplicationEnd()
|
|
notifyIf(error, 'table')
|
|
},
|
|
async onJobDone() {
|
|
const newFieldId = this.job.duplicated_field.id
|
|
try {
|
|
const { data: newField } = await FieldService(this.$client).get(
|
|
newFieldId
|
|
)
|
|
this.onFieldDuplicated(newField)
|
|
} catch (error) {
|
|
this.onDuplicationEnd()
|
|
notifyIf(error, 'table')
|
|
}
|
|
},
|
|
onFieldDuplicated(newField) {
|
|
try {
|
|
const callback = async () => {
|
|
await this.$store.dispatch('field/forceCreate', {
|
|
table: this.table,
|
|
values: newField,
|
|
relatedFields: newField.related_fields,
|
|
})
|
|
this.hide()
|
|
// GridViewHead will update the order of the fields
|
|
this.$emit('move-field', {
|
|
newField,
|
|
position: 'right',
|
|
fromField: this.fromField,
|
|
undoRedoActionGroupId: this.actionGroupId,
|
|
visible: true,
|
|
})
|
|
this.onDuplicationEnd()
|
|
}
|
|
this.$emit('field-created', { callback, newField, fetchNeeded: true })
|
|
} catch (error) {
|
|
this.onDuplicationEnd()
|
|
this.handleError(error)
|
|
}
|
|
},
|
|
async duplicateField() {
|
|
if (this.loading || this.disabled) {
|
|
return
|
|
}
|
|
this.loading = true
|
|
this.hideError()
|
|
this.actionGroupId = createNewUndoRedoActionGroupId()
|
|
try {
|
|
const { data: job } = await FieldService(this.$client).asyncDuplicate(
|
|
this.fromField.id,
|
|
this.duplicateData,
|
|
this.actionGroupId
|
|
)
|
|
this.startJobPoller(job)
|
|
} catch (error) {
|
|
this.onDuplicationEnd()
|
|
notifyIf(error, 'table')
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|