Skip to content

Commit

Permalink
Merge branch '6921-entitydata-common-props-label' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
konzz committed Jun 21, 2024
2 parents 54ec3b7 + 7e207db commit 70f0714
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
13 changes: 12 additions & 1 deletion app/react/Markdown/components/EntityData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ const rootProperties = ['title', 'creationDate', 'editDate'];
const getPropertyData = ({ formattedEntity, propertyName, newNameGeneration }: Options) =>
formattedEntity.metadata.find((p: any) => p.name === safeName(propertyName, newNameGeneration));

const getPropertyName = (propertyName: string, _template: IImmutable<ClientTemplateSchema>) => {
const template = ensure<IImmutable<ClientTemplateSchema>>(_template);
return (
template
.get('commonProperties')
?.find(p => p?.get('label') === propertyName)
?.get('name') || propertyName
);
};

const extractRootProperty = ({ formattedEntity, propertyName }: Options) =>
formattedEntity[propertyName];

Expand Down Expand Up @@ -107,7 +117,8 @@ const EntityData = ({
let output = <></>;

try {
const propertyName = getProperty(propValueOf, propLabelOf);
const attributeValue = getProperty(propValueOf, propLabelOf);
const propertyName = getPropertyName(attributeValue, template);
const renderMethod = getMethod(propValueOf, propertyName);
output = <>{renderMethod({ formattedEntity, propertyName, newNameGeneration, template })}</>;
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/helpers/entityViewPageFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ${textWithDynamicValues}
<h4 className="descriptores-title"><Value path="entity.metadata.descriptores.label" /></h4>
<p className="descriptores-content"><Value path="entity.metadata.descriptores.value.0.value" /></p>
<h4 className="EntityData-label"><EntityData label-of="title" /></h4>
<p className="EntityData-title"><EntityData value-of="title" /></p>
<p className="EntityData-title"><EntityData value-of="Custom Title" /></p>
<p id="entity-datasets-value"><p>`;

export const script = `var currentEntitySharedId = window.store.getState().page.datasets.getIn(['entity', 'sharedId']);
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/pages/pages.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ describe('Pages', () => {
cy.get('.slider').click();
cy.contains('Select...');
cy.get('select.form-control').select('My entity view page');
cy.get('.property-edit').eq(0).click();
cy.clearAndType('input[name="template.data.commonProperties[0].label"]', 'Custom Title');
cy.contains('Save').click();
cy.contains('Saved successfully.');
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.171.0-rc3",
"version": "1.171.1",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit 70f0714

Please sign in to comment.