-
Notifications
You must be signed in to change notification settings - Fork 56
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
EZP-29999: As an editor, I want to see custom icons for content types #805
EZP-29999: As an editor, I want to see custom icons for content types #805
Conversation
07cd74a
to
6651a4a
Compare
* Example configuration: | ||
* | ||
* ```yaml | ||
* ezpublish: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change it to ezplatform
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
}, {}); | ||
|
||
/** | ||
* Returns href to content type icon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns an URL to a content type icon
* @param {String} contentTypeIdentifier | ||
* @returns {String|null} href to icon | ||
*/ | ||
const getContentTypeIcon = (contentTypeIdentifier) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getContentTypeIconUrl
contentTypesDataMap = createContentTypeDataMap(); | ||
} | ||
|
||
const iconHref = contentTypesDataMap[contentTypeIdentifier].thumbnail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iconUrl
@@ -160,7 +160,7 @@ | |||
&-label { | |||
margin: 0; | |||
display: block; | |||
padding-left: 1.5rem; | |||
padding-left: 2.5rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert to pixels and use calculateRem
function
@@ -8,17 +8,29 @@ | |||
.ez-extra-actions--create { | |||
.ez-instant-filter { | |||
&__group-name { | |||
padding-left: .5rem; | |||
padding-left: 0.5rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFunctions(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function getFunctions
confuses me. What does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains code from: #804 as it depends on it.
Please comment PHP parts in #804.
Corresponding line: https://github.com/ezsystems/ezplatform-admin-ui/pull/804/files#diff-a7ba97e75601073fc38f8daa145f316dR31
BTW It's Adam's part - ping @adamwojs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it seems to be inherited from Twig_Extension
and it "Returns a list of functions to add to the existing list." (https://twig.symfony.com/doc/2.x/advanced.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way you are defining custom Twig functions provided by extension. As you me notice this class implement interface from the 3rd party library so "naming" is not subject to discussion.
98f8197
to
600496c
Compare
Branch was rebased onto master and is ready for review. |
top: 0; | ||
left: calculateRem(20px); | ||
width: calculateRem(16px); | ||
height: calculateRem(16px); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use ez-icon--small
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defined it here in order to overwrite selector: .ez-context-menu .ez-sticky-container .ez-icon
.
@@ -17,7 +17,7 @@ | |||
{% block page_title_admin %} | |||
{% include '@ezdesign/parts/page_title.html.twig' with { | |||
title: 'content_type.view.edit.title'|trans({ '%name%': content_type.name })|desc('Editing Content Type: %name%'), | |||
iconName: 'content-type' | |||
contentType: content_type.identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not contentType
. Variables in twig are with _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was already iconName
in/views/parts/page_title.html.twig
, this is why I opted for contentType
to make it consistent within template file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case consistent is not a good way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, changed. :)
@@ -5,6 +5,10 @@ | |||
<svg class="ez-icon ez-icon-{{ iconName }}"> | |||
<use xlink:href="{{ asset('bundles/ezplatformadminui/img/ez-icons.svg') }}#{{ iconName }}"></use> | |||
</svg> | |||
{% elseif contentType is defined %} | |||
<svg class="ez-icon ez-icon-{{ contentType }}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is wrong here. From a line below contentType
is an object not string. In the other template you pass identifier
as a contentType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You was right, very good catch, I'm impressed! 😄
Fixed in: 92412c2
@@ -17,7 +17,7 @@ | |||
{% block page_title %} | |||
{% include '@ezdesign/parts/page_title.html.twig' with { | |||
title: 'content_type.view.view.title'|trans({ '%name%': content_type.name })|desc('%name%'), | |||
iconName: 'content-type' | |||
contentType: content_type.identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content_type_identifier
?
@@ -76,6 +76,8 @@ public function map(Pagerfanta $pager): array | |||
'language' => $contentInfo->mainLanguageCode, | |||
'contributor' => $contributor, | |||
'version' => $content->versionInfo->versionNo, | |||
'type' => $content->getContentType()->getName(), | |||
'content_type' => $content->getContentType(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of having these two? content_type
is sufficient if this goes to the twig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is @adamwojs part, but I think that it is my error made during rebasing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5e51a7e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything was fixed, just MFU left. It occurs when user tries to upload items when folder is empty - uploading for the first time. Later everything works fine. |
@@ -113,6 +113,13 @@ | |||
return total; | |||
}, {}); | |||
const udwConfigBulkMoveItems = JSON.parse(container.dataset.udwConfigBulkMoveItems); | |||
const mfuContentTypesMap = Object.values(eZ.adminUiConfig.contentTypes).reduce((contentTypeDataMap, contentTypeGroup) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pass different config to MFU because the one based on: container.dataset.contentTypes
contains only CTs of elements displayed in Sub-items.
Given that mfuContentTypesMap
in contrast to contentTypesMap
(which is passed to Sub-items) does not contain whole CT objects but rather data stored in eZ.adminUiConfig.contentTypes
, are we OK with passing mfuContentTypesMap
to MFU as contentTypesMap
- ping @dew326 @sunpietro ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the approach is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a difference only in missing data or in the data structure as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentTypesMap
is a map of CT objects; mfuContentTypesMap
in this case is a map of objects like:
{
href: "/api/ezp/v2/content/types/21"
identifier: "about"
name: "About"
thumbnail: "/bundles/ezplatformadminui/img/ez-icons.svg#about"
}
name
and thumbnail
does not exist on CT object.
We can always call it contentTypesDataMap
etc. We can also resign from passing this as a prop and extract it inside MFU. Or even make global helper function - getContentTypeIdentifierByHref
, which may be helpful in other React components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation. Can't the backend provide this structure instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We opted for this solution mostly because this is more efficient than extracting objects for all Content Types. But maybe it is way to go. This question is more to @adamwojs .
@@ -113,6 +113,13 @@ | |||
return total; | |||
}, {}); | |||
const udwConfigBulkMoveItems = JSON.parse(container.dataset.udwConfigBulkMoveItems); | |||
const mfuContentTypesMap = Object.values(eZ.adminUiConfig.contentTypes).reduce((contentTypeDataMap, contentTypeGroup) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation. Can't the backend provide this structure instead?
…ezsystems#805) * EZP-29999: Implement custom icons for content types * Change ezplatform_admin_ui_content_type_icon to ez_content_type_icon * Fix * contentType -> content_type_identifier * fixup! EZP-29999: Implement custom icons for content types * fixup! EZP-29999: Implement custom icons for content types * Pass different contentTypesMap to MFU
Requires: #804
UDW part in: ezsystems/ezplatform-admin-ui-modules#132
date-based-publisher: https://github.com/ezsystems/date-based-publisher/pull/89
Workflow: https://github.com/ezsystems/ezplatform-workflow/pull/46
Views with icons
Content item view & edit view
Bookmarks
Trash
Drafts
Content type list; content type view; content type edit
Dashboard
Checklist:
ez_content_type_icon
where necessary