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(
|
||||
column.name,
|
||||
{
|
||||
if (!fromRelationshipField) {
|
||||
await datasource.actions.addSchemaMutation(column.name, {
|
||||
visible,
|
||||
readonly,
|
||||
},
|
||||
fromRelationshipField?.name
|
||||
)
|
||||
})
|
||||
} else {
|
||||
await datasource.actions.addSubSchemaMutation(
|
||||
column.name,
|
||||
fromRelationshipField.name,
|
||||
{
|
||||
visible,
|
||||
readonly,
|
||||
}
|
||||
)
|
||||
}
|
||||
try {
|
||||
await datasource.actions.saveSchemaMutations()
|
||||
} catch (e) {
|
||||
|
|
|
@ -168,34 +168,38 @@ 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,
|
||||
schemaMutations.update($schemaMutations => {
|
||||
return {
|
||||
...$schemaMutations,
|
||||
[field]: {
|
||||
...$schemaMutations[field],
|
||||
...mutation,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 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]: {
|
||||
...$schemaMutations[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