Fix redirect on save as copy and resolve wrong titles on all records
This commit is contained in:
@@ -21,8 +21,7 @@
|
||||
@click.prevent="$emit('back')"
|
||||
>
|
||||
<font-awesome-icon
|
||||
|
||||
:icon="['fas', showRecordModal && !inEditing ? 'times' : 'chevron-left']"
|
||||
:icon="['fas', showRecordModal ? 'times' : 'chevron-left']"
|
||||
class="back-icon"
|
||||
/>
|
||||
{{ backLabel }}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
v-bind="$props"
|
||||
:scrollable-body="false"
|
||||
v-on="$listeners"
|
||||
@refreshBlock="refresh(false, false)"
|
||||
@refreshBlock="refresh(true, false)"
|
||||
>
|
||||
<template
|
||||
v-if="isFederated"
|
||||
@@ -1535,13 +1535,12 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
refresh (resetPagination = false, checkSelected = false) {
|
||||
async refresh (resetPagination = false, checkSelected = false) {
|
||||
// Prevent refresh if records are selected or inline editing
|
||||
if (checkSelected && (this.selected.length || this.inlineEdit.recordIDs.length)) return
|
||||
|
||||
this.$nextTick(() => {
|
||||
return this.pullRecords(resetPagination)
|
||||
})
|
||||
await this.$nextTick()
|
||||
return this.pullRecords(resetPagination)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1566,9 +1565,6 @@ export default {
|
||||
const query = queryToFilter(this.query, this.drillDownFilter || this.prefilter, this.fields.map(({ moduleField }) => moduleField), this.recordListFilter)
|
||||
|
||||
const { moduleID, namespaceID } = this.recordListModule
|
||||
if (this.filter.pageCursor) {
|
||||
this.filter.sort = ''
|
||||
}
|
||||
|
||||
let paginationOptions = {}
|
||||
if (resetPagination) {
|
||||
@@ -1578,6 +1574,8 @@ export default {
|
||||
incPageNavigation: fullPageNavigation,
|
||||
incTotal: showTotalCount,
|
||||
}
|
||||
} else if (this.filter.pageCursor) {
|
||||
this.filter.sort = ''
|
||||
}
|
||||
|
||||
// Filter's out deleted records when filter.deleted is 2, and undeleted records when filter.deleted is 0
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
:page="page"
|
||||
:module="module"
|
||||
:record-i-d="recordID"
|
||||
:values="values"
|
||||
show-record-modal
|
||||
@handle-record-redirect="loadRecord"
|
||||
/>
|
||||
@@ -69,6 +70,7 @@ export default {
|
||||
recordID: undefined,
|
||||
module: undefined,
|
||||
page: undefined,
|
||||
values: undefined,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -116,7 +118,8 @@ export default {
|
||||
clearRecordIDs: 'ui/clearRecordIDs',
|
||||
}),
|
||||
|
||||
loadRecord ({ recordID, recordPageID }) {
|
||||
loadRecord ({ recordID, recordPageID, values }) {
|
||||
this.values = values
|
||||
this.loadModal({ recordID, recordPageID })
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -73,6 +73,7 @@ export default {
|
||||
this.processingSubmit = true
|
||||
this.processing = true
|
||||
|
||||
let record
|
||||
const isNew = this.record.recordID === NoID
|
||||
const queue = []
|
||||
|
||||
@@ -142,8 +143,8 @@ export default {
|
||||
|
||||
throw err
|
||||
})
|
||||
.then(record => {
|
||||
this.record = new compose.Record(this.module, record)
|
||||
.then(r => {
|
||||
record = new compose.Record(this.module, r)
|
||||
})
|
||||
.then(() => this.dispatchUiEvent('afterFormSubmit', this.record, { $records: records }))
|
||||
.then(() => this.updatePrompts())
|
||||
@@ -151,8 +152,20 @@ export default {
|
||||
if (this.record.valueErrors.set) {
|
||||
this.toastWarning(this.$t('notification:record.validationWarnings'))
|
||||
} else {
|
||||
this.inCreating = false
|
||||
if (isNew) {
|
||||
this.inCreating = false
|
||||
this.inEditing = false
|
||||
} else {
|
||||
this.record = record
|
||||
}
|
||||
|
||||
if (this.showRecordModal) {
|
||||
this.$emit('handle-record-redirect', { recordID: record.recordID, recordPageID: this.page.pageID })
|
||||
} else {
|
||||
this.$router.push({ name: route, params: { ...this.$route.params, recordID: record.recordID } })
|
||||
}
|
||||
}
|
||||
|
||||
this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`))
|
||||
})
|
||||
.catch(this.toastErrorHandler(this.$t(`notification:record.${isNew ? 'create' : 'update'}Failed`)))
|
||||
@@ -170,6 +183,7 @@ export default {
|
||||
this.processingSubmit = true
|
||||
this.processing = true
|
||||
|
||||
let record
|
||||
const isNew = this.record.recordID === NoID
|
||||
|
||||
return this
|
||||
@@ -192,15 +206,22 @@ export default {
|
||||
|
||||
throw err
|
||||
})
|
||||
.then(record => {
|
||||
this.record = new compose.Record(this.module, record)
|
||||
.then(r => {
|
||||
record = new compose.Record(this.module, r)
|
||||
})
|
||||
.then(() => this.dispatchUiEvent('beforeFormSubmit', this.record))
|
||||
.then(() => this.dispatchUiEvent('afterFormSubmit', record))
|
||||
.then(() => this.updatePrompts())
|
||||
.then(() => {
|
||||
if (this.record.valueErrors.set) {
|
||||
this.toastWarning(this.$t('notification:record.validationWarnings'))
|
||||
} else {
|
||||
if (isNew) {
|
||||
this.inCreating = false
|
||||
this.inEditing = false
|
||||
} else {
|
||||
this.record = record
|
||||
}
|
||||
|
||||
this.$router.push({ name: route, params: { ...this.$route.params, recordID: this.record.recordID } })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script>
|
||||
import ViewRecord from './View'
|
||||
import { compose } from '@cortezaproject/corteza-js'
|
||||
|
||||
export default {
|
||||
i18nOptions: {
|
||||
@@ -11,30 +10,11 @@ export default {
|
||||
|
||||
extends: ViewRecord,
|
||||
|
||||
props: {
|
||||
// If component was called (via router) with some pre-seed values
|
||||
values: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
inEditing: true,
|
||||
inCreating: true,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
title () {
|
||||
const { name, handle } = this.module
|
||||
return this.$t('allRecords.create.title', { name: name || handle, interpolation: { escapeValue: false } })
|
||||
},
|
||||
},
|
||||
|
||||
created () {
|
||||
this.record = new compose.Record(this.module, { values: this.values })
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -13,20 +13,8 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
inEditing: true,
|
||||
inCreating: false,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
title () {
|
||||
const { name, handle } = this.module
|
||||
return this.$t('allRecords.edit.title', { name: name || handle, interpolation: { escapeValue: false } })
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleBack () {
|
||||
this.$router.push({ name: 'admin.modules.record.view' })
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -102,7 +102,6 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import RecordToolbar from 'corteza-webapp-compose/src/components/Common/RecordToolbar'
|
||||
import users from 'corteza-webapp-compose/src/mixins/users'
|
||||
import record from 'corteza-webapp-compose/src/mixins/record'
|
||||
import { compose } from '@cortezaproject/corteza-js'
|
||||
import RecordBase from 'corteza-webapp-compose/src/components/PageBlocks/RecordBase'
|
||||
@@ -124,12 +123,21 @@ export default {
|
||||
mixins: [
|
||||
// The record mixin contains all of the logic for creating/editing/deleting the record
|
||||
record,
|
||||
users,
|
||||
],
|
||||
|
||||
props: {
|
||||
// If component was called (via router) with some pre-seed values
|
||||
values: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
inEditing: false,
|
||||
inCreating: false,
|
||||
|
||||
blocks: [],
|
||||
|
||||
@@ -148,7 +156,9 @@ export default {
|
||||
|
||||
title () {
|
||||
const { name, handle } = this.module
|
||||
return this.$t('allRecords.view.title', { name: name || handle, interpolation: { escapeValue: false } })
|
||||
const titlePrefix = this.inCreating ? 'create' : this.inEditing ? 'edit' : 'view'
|
||||
|
||||
return this.$t(`allRecords.${titlePrefix}.title`, { name: name || handle, interpolation: { escapeValue: false } })
|
||||
},
|
||||
|
||||
module () {
|
||||
@@ -219,6 +229,7 @@ export default {
|
||||
|
||||
created () {
|
||||
this.createBlocks()
|
||||
this.record = new compose.Record(this.module, { values: this.values })
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -1,46 +1,15 @@
|
||||
<script>
|
||||
import ViewRecord from './View'
|
||||
import { compose } from '@cortezaproject/corteza-js'
|
||||
|
||||
export default {
|
||||
name: 'CreateRecord',
|
||||
|
||||
extends: ViewRecord,
|
||||
|
||||
props: {
|
||||
// When creating from related record blocks
|
||||
refRecord: {
|
||||
type: compose.Record,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
|
||||
// If component was called (via router) with some pre-seed values
|
||||
values: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
inEditing: true,
|
||||
inCreating: true,
|
||||
}
|
||||
},
|
||||
|
||||
created () {
|
||||
this.record = new compose.Record(this.module, { values: this.values })
|
||||
|
||||
if (this.refRecord) {
|
||||
// Record create form called from a related records block,
|
||||
// we'll try to find an appropriate field and cross-link this new record to ref
|
||||
const recRefField = this.module.fields.find(f => f.kind === 'Record' && f.options.moduleID === this.refRecord.moduleID)
|
||||
if (recRefField) {
|
||||
this.record.values[recRefField.name] = this.refRecord.recordID
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -157,6 +157,20 @@ export default {
|
||||
default: '',
|
||||
},
|
||||
|
||||
// When creating from related record blocks
|
||||
refRecord: {
|
||||
type: compose.Record,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
|
||||
// If component was called (via router) with some pre-seed values
|
||||
values: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({}),
|
||||
},
|
||||
|
||||
// Open record in a modal
|
||||
showRecordModal: {
|
||||
type: Boolean,
|
||||
@@ -343,7 +357,16 @@ export default {
|
||||
this.handleBack()
|
||||
})
|
||||
} else {
|
||||
this.record = new compose.Record(module, {})
|
||||
this.record = new compose.Record(module, { values: this.values })
|
||||
}
|
||||
|
||||
if (this.refRecord) {
|
||||
// Record create form called from a related records block,
|
||||
// we'll try to find an appropriate field and cross-link this new record to ref
|
||||
const recRefField = this.module.fields.find(f => f.kind === 'Record' && f.options.moduleID === this.refRecord.moduleID)
|
||||
if (recRefField) {
|
||||
this.record.values[recRefField.name] = this.refRecord.recordID
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -352,7 +375,12 @@ export default {
|
||||
/**
|
||||
* Not the best way since we can not always know where we
|
||||
* came from (and "where" is back).
|
||||
*/
|
||||
*/
|
||||
if (this.showRecordModal) {
|
||||
this.$bvModal.hide('record-modal')
|
||||
return
|
||||
}
|
||||
|
||||
const previousPage = await this.popPreviousPages()
|
||||
const extraPop = !this.inCreating
|
||||
this.$router.push(previousPage || { name: 'pages', params: { slug: this.namespace.slug || this.namespace.namespaceID } })
|
||||
@@ -382,8 +410,7 @@ export default {
|
||||
|
||||
this.inEditing = true
|
||||
this.inCreating = true
|
||||
this.record = new compose.Record(this.module, { values: this.record.values })
|
||||
this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID })
|
||||
this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID, values: this.record.values })
|
||||
},
|
||||
|
||||
handleEdit () {
|
||||
|
||||
Reference in New Issue
Block a user