Split between addSchemaMutation and addSubSchemaMutation
This commit is contained in:
parent
6301b9de4c
commit
1bf0f933f0
|
@ -145,14 +145,21 @@
|
|||
const visible = permission !== FieldPermissions.HIDDEN
|
||||
const readonly = permission === FieldPermissions.READONLY
|
||||
|
||||
await datasource.actions.addSchemaMutation(
|
||||
if (!fromRelationshipField) {
|
||||
await datasource.actions.addSchemaMutation(column.name, {
|
||||
visible,
|
||||
readonly,
|
||||
})
|
||||
} else {
|
||||
await datasource.actions.addSubSchemaMutation(
|
||||
column.name,
|
||||
fromRelationshipField.name,
|
||||
{
|
||||
visible,
|
||||
readonly,
|
||||
},
|
||||
fromRelationshipField?.name
|
||||
}
|
||||
)
|
||||
}
|
||||
try {
|
||||
await datasource.actions.saveSchemaMutations()
|
||||
} catch (e) {
|
||||
|
|
|
@ -168,24 +168,10 @@ export const createActions = context => {
|
|||
}
|
||||
|
||||
// Adds a schema mutation for a single field
|
||||
const addSchemaMutation = (field, mutation, fromNestedField) => {
|
||||
const addSchemaMutation = (field, mutation) => {
|
||||
if (!field || !mutation) {
|
||||
return
|
||||
}
|
||||
if (fromNestedField) {
|
||||
subSchemaMutations.update($subSchemaMutations => {
|
||||
return {
|
||||
...$subSchemaMutations,
|
||||
[fromNestedField]: {
|
||||
...$subSchemaMutations[fromNestedField],
|
||||
[field]: {
|
||||
...($subSchemaMutations[fromNestedField] || {})[field],
|
||||
...mutation,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
} else {
|
||||
schemaMutations.update($schemaMutations => {
|
||||
return {
|
||||
...$schemaMutations,
|
||||
|
@ -196,6 +182,24 @@ export const createActions = context => {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Adds a nested schema mutation for a single field
|
||||
const addSubSchemaMutation = (field, fromField, mutation) => {
|
||||
if (!field || !fromField || !mutation) {
|
||||
return
|
||||
}
|
||||
subSchemaMutations.update($subSchemaMutations => {
|
||||
return {
|
||||
...$subSchemaMutations,
|
||||
[fromField]: {
|
||||
...$subSchemaMutations[fromField],
|
||||
[field]: {
|
||||
...($subSchemaMutations[fromField] || {})[field],
|
||||
...mutation,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Adds schema mutations for multiple fields at once
|
||||
|
@ -304,6 +308,7 @@ export const createActions = context => {
|
|||
canUseColumn,
|
||||
changePrimaryDisplay,
|
||||
addSchemaMutation,
|
||||
addSubSchemaMutation,
|
||||
addSchemaMutations,
|
||||
saveSchemaMutations,
|
||||
resetSchemaMutations,
|
||||
|
|
Loading…
Reference in New Issue