Merge pull request #4738 from strapi/fix/ctm-edit-visible

Fix ctm hidden fields
This commit is contained in:
Alexandre BODIN 2019-12-17 12:45:04 +01:00 committed by GitHub
commit 6ea37525e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 20 deletions

View File

@ -16,10 +16,6 @@ module.exports = {
name: 'password',
size: 6,
},
{
name: 'provider',
size: 6,
},
],
[
{

View File

@ -1,9 +1,7 @@
module.exports = {
metadatas: {
attributes: {
resetPasswordToken: {
edit: {
visible: false,
},
hidden: true,
},
},
};

View File

@ -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;
}

View File

@ -1,19 +1,10 @@
module.exports = {
metadatas: {
attributes: {
resetPasswordToken: {
edit: {
visible: false,
},
hidden: true,
},
provider: {
edit: {
visible: false,
},
},
role: {
edit: {
mainField: 'name',
},
hidden: true,
},
},
};