mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
chore: apply suggested changes
Co-authored-by: phunguyenmurcul <51897872+phunguyenmurcul@users.noreply.github.com>
This commit is contained in:
parent
e6e3ab455c
commit
f9306e3e8d
@ -157,13 +157,14 @@ const generateAPI = ({ singularName, kind = 'collectionType', pluralName, displa
|
|||||||
const editContentType = async (uid, { contentType, components = [] }) => {
|
const editContentType = async (uid, { contentType, components = [] }) => {
|
||||||
const builder = createBuilder();
|
const builder = createBuilder();
|
||||||
|
|
||||||
const previousKind = builder.contentTypes.get(uid).schema.kind;
|
const previousSchema = builder.contentTypes.get(uid).schema;
|
||||||
|
const previousKind = previousSchema.kind;
|
||||||
const newKind = contentType.kind || previousKind;
|
const newKind = contentType.kind || previousKind;
|
||||||
|
|
||||||
// Restore non-visible attributes from previous schema
|
// Restore non-visible attributes from previous schema
|
||||||
const previousAttributes = builder.contentTypes.get(uid).schema.attributes;
|
const previousAttributes = previousSchema.attributes;
|
||||||
const prevNonVisibleAttributes = contentTypesUtils
|
const prevNonVisibleAttributes = contentTypesUtils
|
||||||
.getNonVisibleAttributes(builder.contentTypes.get(uid).schema)
|
.getNonVisibleAttributes(previousSchema)
|
||||||
.reduce((acc, key) => {
|
.reduce((acc, key) => {
|
||||||
if (key in previousAttributes) {
|
if (key in previousAttributes) {
|
||||||
acc[key] = previousAttributes[key];
|
acc[key] = previousAttributes[key];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user