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

EZP-29999: As an editor, I want to see custom icons for content types #805

Merged

Conversation

tischsoic
Copy link
Contributor

@tischsoic tischsoic commented Jan 17, 2019

Question Answer
Tickets https://jira.ez.no/browse/EZP-29999
Bug fix? no
New feature? yes
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

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

screen shot 2019-01-21 at 13 00 55

Content item view & edit view

screen shot 2019-01-21 at 13 01 30

screen shot 2019-01-21 at 13 01 42

Bookmarks

screen shot 2019-01-28 at 09 22 08

Trash

screen shot 2019-01-28 at 09 22 20

Drafts

screen shot 2019-01-30 at 13 09 17

Content type list; content type view; content type edit

screen shot 2019-01-21 at 13 02 51
screen shot 2019-01-21 at 13 14 23
screen shot 2019-01-21 at 13 14 39

Dashboard

screen shot 2019-01-30 at 13 08 45

Checklist:

  • pass content types data to twig templates, which lack them
  • add ez_content_type_icon where necessary
  • ready for Code Review

* Example configuration:
*
* ```yaml
* ezpublish:
Copy link
Contributor

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?

Copy link
Member

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
Copy link
Contributor

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) => {
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

@tischsoic tischsoic Jan 24, 2019

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.

Copy link
Contributor Author

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)

Copy link
Member

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.

@tischsoic tischsoic force-pushed the EZP-29999-as-editor-i-want-custom-icons-for-content-types-2 branch from 98f8197 to 600496c Compare January 30, 2019 12:00
@tischsoic tischsoic changed the title [WIP] EZP-29999: As an editor, I want to see custom icons for content types EZP-29999: As an editor, I want to see custom icons for content types Jan 30, 2019
@tischsoic
Copy link
Contributor Author

Branch was rebased onto master and is ready for review.

top: 0;
left: calculateRem(20px);
width: calculateRem(16px);
height: calculateRem(16px);
Copy link
Member

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

Copy link
Contributor Author

@tischsoic tischsoic Jan 30, 2019

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
Copy link
Member

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 _.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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 }}">
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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(),
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5e51a7e

@barbaragr barbaragr self-assigned this Jan 31, 2019
Copy link

@barbaragr barbaragr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing icons for:

  1. Sub-items list - grid view

screen shot 2019-02-01 at 11 08 20

  1. Dashboard/My scheduled:

screen shot 2019-02-01 at 11 12 51

  1. Dashboard/Drafts under review:

screen shot 2019-02-01 at 11 12 57

  1. Dashboard/Review queue

screen shot 2019-02-01 at 11 13 03

  1. Dashboard/All scheduled:

screen shot 2019-02-01 at 11 13 11

  1. Multi file upload after drag and drop:

screen shot 2019-02-01 at 11 16 25

@barbaragr
Copy link

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) => {
Copy link
Contributor Author

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 ?

Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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) => {
Copy link
Contributor

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?

@sunpietro sunpietro merged commit e1682c2 into master Feb 5, 2019
@sunpietro sunpietro deleted the EZP-29999-as-editor-i-want-custom-icons-for-content-types-2 branch February 5, 2019 14:49
@m-tyrala m-tyrala mentioned this pull request Feb 6, 2019
2 tasks
konradoboza pushed a commit to konradoboza/ezplatform-admin-ui that referenced this pull request May 29, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants