mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 13:45:25 +00:00
Merge pull request #4738 from strapi/fix/ctm-edit-visible
Fix ctm hidden fields
This commit is contained in:
commit
6ea37525e9
@ -16,10 +16,6 @@ module.exports = {
|
||||
name: 'password',
|
||||
size: 6,
|
||||
},
|
||||
{
|
||||
name: 'provider',
|
||||
size: 6,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
module.exports = {
|
||||
metadatas: {
|
||||
attributes: {
|
||||
resetPasswordToken: {
|
||||
edit: {
|
||||
visible: false,
|
||||
},
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -20,11 +20,33 @@ const NON_LISTABLES = [
|
||||
'dynamiczone',
|
||||
];
|
||||
|
||||
// hidden fields are fields that are configured to be hidden from list, and edit views
|
||||
const isHidden = (schema, name) => {
|
||||
if (!_.has(schema.attributes, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isHidden = _.get(
|
||||
schema,
|
||||
['config', 'attributes', name, 'hidden'],
|
||||
false
|
||||
);
|
||||
if (isHidden === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const isListable = (schema, name) => {
|
||||
if (!_.has(schema.attributes, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isHidden(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const attribute = schema.attributes[name];
|
||||
if (NON_LISTABLES.includes(attribute.type)) {
|
||||
return false;
|
||||
@ -57,6 +79,10 @@ const isVisible = (schema, name) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isHidden(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isTimestamp(schema, name) || name === 'id') {
|
||||
return false;
|
||||
}
|
||||
@ -86,6 +112,10 @@ const hasRelationAttribute = (schema, name) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isHidden(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isVisible(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
@ -98,6 +128,10 @@ const hasEditableAttribute = (schema, name) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isHidden(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isVisible(schema, name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,19 +1,10 @@
|
||||
module.exports = {
|
||||
metadatas: {
|
||||
attributes: {
|
||||
resetPasswordToken: {
|
||||
edit: {
|
||||
visible: false,
|
||||
},
|
||||
hidden: true,
|
||||
},
|
||||
provider: {
|
||||
edit: {
|
||||
visible: false,
|
||||
},
|
||||
},
|
||||
role: {
|
||||
edit: {
|
||||
mainField: 'name',
|
||||
},
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user