Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added grid preview for field collections #663

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion public/js/pimcore/object/tags/fieldcollections.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,34 @@ pimcore.object.tags.fieldcollections = Class.create(pimcore.object.tags.abstract
return {text: t(field.label), width: 150, sortable: false, dataIndex: field.key,
renderer: function (key, value, metaData, record) {
this.applyPermissionStyle(key, value, metaData, record);
if(typeof record.data[key] === 'string') {
return record.data[key];
}

let preview = '';

const fieldCollectionItems = record.data[key];

let previousFieldCollectionItemType = null;
for (let fieldCollectionItem of fieldCollectionItems) {
kingjia90 marked this conversation as resolved.
Show resolved Hide resolved

return t("not_supported");
if(previousFieldCollectionItemType !== fieldCollectionItem.type) {
preview += `<h3 style="margin-top: 0">${t(fieldCollectionItem.type)}</h3>`;
previousFieldCollectionItemType = fieldCollectionItem.type;
}

preview += `<div style="margin-bottom: 10px; border-bottom: 1px solid #e9e9e9; overflow: auto; white-space: normal">`;
for (let fieldKey in fieldCollectionItem.data) {
if (!fieldCollectionItem.data.hasOwnProperty(fieldKey)) {
continue;
}

preview += `<div style=""><b>${t(fieldCollectionItem.data[fieldKey].title)}:</b></div>`;
preview += `<div style="margin-bottom: 5px">${fieldCollectionItem.data[fieldKey].value ? fieldCollectionItem.data[fieldKey].value : '-'}</div>`;
}
preview += `</div>`;
}
return preview;
}.bind(this, field.key)};
},

Expand Down
2 changes: 1 addition & 1 deletion src/Service/GridData/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private static function getValueForObject(Concrete $object, string $key, string
$fieldDefinition = $brickClass->getFieldDefinition($brickKey, $context);
}

if ($fieldDefinition->isEmpty($value)) {
if ($fieldDefinition->isEmpty($value) && $fieldDefinition->supportsInheritance()) {
$parent = Service::hasInheritableParentObject($object);
if (!empty($parent)) {
return self::getValueForObject($parent, $key, $brickType, $brickKey, $fieldDefinition, $context, $brickDescriptor);
Expand Down
Loading