mirror of
https://github.com/strapi/strapi.git
synced 2025-08-23 08:09:10 +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',
|
name: 'password',
|
||||||
size: 6,
|
size: 6,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'provider',
|
|
||||||
size: 6,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
metadatas: {
|
attributes: {
|
||||||
resetPasswordToken: {
|
resetPasswordToken: {
|
||||||
edit: {
|
hidden: true,
|
||||||
visible: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -20,11 +20,33 @@ const NON_LISTABLES = [
|
|||||||
'dynamiczone',
|
'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) => {
|
const isListable = (schema, name) => {
|
||||||
if (!_.has(schema.attributes, name)) {
|
if (!_.has(schema.attributes, name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHidden(schema, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const attribute = schema.attributes[name];
|
const attribute = schema.attributes[name];
|
||||||
if (NON_LISTABLES.includes(attribute.type)) {
|
if (NON_LISTABLES.includes(attribute.type)) {
|
||||||
return false;
|
return false;
|
||||||
@ -57,6 +79,10 @@ const isVisible = (schema, name) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHidden(schema, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isTimestamp(schema, name) || name === 'id') {
|
if (isTimestamp(schema, name) || name === 'id') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -86,6 +112,10 @@ const hasRelationAttribute = (schema, name) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHidden(schema, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isVisible(schema, name)) {
|
if (!isVisible(schema, name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -98,6 +128,10 @@ const hasEditableAttribute = (schema, name) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHidden(schema, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isVisible(schema, name)) {
|
if (!isVisible(schema, name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
metadatas: {
|
attributes: {
|
||||||
resetPasswordToken: {
|
resetPasswordToken: {
|
||||||
edit: {
|
hidden: true,
|
||||||
visible: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
provider: {
|
provider: {
|
||||||
edit: {
|
hidden: true,
|
||||||
visible: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
role: {
|
|
||||||
edit: {
|
|
||||||
mainField: 'name',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user