Adding validation so that a linked column and a primary display column cannot be renamed.
This commit is contained in:
parent
725e4e9944
commit
ee10e6a165
|
@ -34,7 +34,11 @@ exports.save = async function(ctx) {
|
||||||
|
|
||||||
// rename record fields when table column is renamed
|
// rename record fields when table column is renamed
|
||||||
const { _rename } = modelToSave
|
const { _rename } = modelToSave
|
||||||
if (_rename) {
|
if (_rename && modelToSave.schema[_rename.updated].type === "link") {
|
||||||
|
throw "Cannot rename a linked field."
|
||||||
|
} else if (_rename && modelToSave.primaryDisplay === _rename.old) {
|
||||||
|
throw "Cannot rename the primary display field."
|
||||||
|
} else if (_rename) {
|
||||||
const records = await db.query(`database/all_${modelToSave._id}`, {
|
const records = await db.query(`database/all_${modelToSave._id}`, {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue