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

[4.0] [JLayout] merge two equal JLayouts for iconclass into one new JLayout for iconclass #30470

Merged

Conversation

hans2103
Copy link
Contributor

@hans2103 hans2103 commented Aug 24, 2020

This PR has influence on #30468 and #30464

Summary of Changes

This PR will prevent duplicate code.
Both layouts/joomla/button/iconclass.php and layouts/joomla/toolbar/iconclass.php are the same.
Merging both will make our code a bit DRY

Testing Instructions

Apply the PR and go to Joomla administrator or Joomla frontend and look for icons on buttons or in a toolbar.
There should be no change visible before or after applying the PR.

Actual result BEFORE applying this Pull Request

Buttons in the toolbar have icons

Expected result AFTER applying this Pull Request

Buttons in the toolbar have icons

Documentation Changes Required

The newly created Layout joomla.icon.iconclass has two parameters

  1. icon => name or className => the icon that should be displayed
  2. html => true/false to display html output or className only

Examples

call for className and as HTML output
use Joomla\CMS\Layout\LayoutHelper;

echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'fa-folder-open', 'html' => true]);

this will render

<span class="fas fa-folder-open" aria-hidden="true"></span>
call for className and className output
use Joomla\CMS\Layout\LayoutHelper;

echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'fa-folder-open']);

this will render

fas fa-folder-open
call for stateName and as HTML output
use Joomla\CMS\Layout\LayoutHelper;

echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'published', 'html' => true ]);

this will render

<span class="fas fa-check" aria-hidden="true"></span>
call for stateName and as className output
use Joomla\CMS\Layout\LayoutHelper;

echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'published' ]);

this will render

fas fa-check

@hans2103 hans2103 changed the title Feature/layouthelper for dry icons [4.0] [JLayout] merge two equal JLayouts for iconclass into one new JLayout for iconclass Aug 24, 2020
@brianteeman
Copy link
Contributor

Clearly the current code is not optimal but is merging the layouts the solution? I thought the whole point of layouts was that they were single purpose and could be overridden. Doesn't this change prevent that?

@hans2103
Copy link
Contributor Author

@brianteeman This PR reduces duplicate code but keeps the possibility to override the origin.
Developers still can both toolbar/iconclass.php and button/iconclass.php the way they did before.
Both files echo the icon/iconclass.php
Both files where exactly the same and there is no use of maintaining two equal files.
We should try not to repeat ourself while coding.

content of layouts/joomla/toolbar/iconclass.php === content of layouts/joomla/button/iconclass.php
Only that should be reason enough to merge it into one file.

@brianteeman
Copy link
Contributor

Files being identical is a consequence of the layouts concept.

Can the button still be overridden separately to the toolbar?

@hans2103
Copy link
Contributor Author

Can the button still be overridden separately to the toolbar?

yes.. I haven't deleted both files. The only echo the new layout. You can override button/iconclass to your own template and go wild in the code. Same goed for toolbar/iconclass

@brianteeman
Copy link
Contributor

@hans2103 much better now - thanks

@N6REJ
Copy link
Contributor

N6REJ commented Aug 26, 2020

nice to have @hans2103 working with me to take this project to the next step.

@Quy
Copy link
Contributor

Quy commented Aug 26, 2020

@N6REJ Close PR #30482?

@N6REJ
Copy link
Contributor

N6REJ commented Aug 27, 2020

@N6REJ Close PR #30482?
as I said in that pr, no, because they don't exactly replace each other. @hans2103 and I are working together and they will be merged appropiately

@Quy
Copy link
Contributor

Quy commented Aug 28, 2020

I have tested this item ✅ successfully on a62d5b5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

1 similar comment
@jwaisner
Copy link
Member

I have tested this item ✅ successfully on a62d5b5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

@jwaisner
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

@N6REJ
Copy link
Contributor

N6REJ commented Aug 31, 2020

I have tested this item ✅ successfully on 1b4e36b

#30468

and

#30482

now merged with this pr so will close them.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
@N6REJ
Copy link
Contributor

N6REJ commented Sep 4, 2020

I have tested this item ✅ successfully on 0d1156a

works as expected


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

hans2103 and others added 3 commits September 6, 2020 16:18
I like this PHP7 operator

Co-authored-by: Quy <quy@fluxbb.org>
# Conflicts:
#	layouts/joomla/content/info_block/category.php
…103/joomla-cms into feature/layouthelper-for-dry-icons
@hans2103
Copy link
Contributor Author

hans2103 commented Sep 6, 2020

merged recent 4.0-dev updates and solved merge conflict

@ghost
Copy link

ghost commented Sep 7, 2020

I have tested this item ✅ successfully on b00f232


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

2 similar comments
@paternax
Copy link

paternax commented Sep 7, 2020

I have tested this item ✅ successfully on b00f232


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

@paternax
Copy link

paternax commented Sep 7, 2020

I have tested this item ✅ successfully on b00f232


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

@richard67
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30470.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Sep 7, 2020
@infograf768 infograf768 merged commit 0d6db34 into joomla:4.0-dev Sep 11, 2020
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Sep 11, 2020
@infograf768
Copy link
Member

Thanks

@infograf768 infograf768 added this to the Joomla 4.0 milestone Sep 11, 2020
@hans2103 hans2103 deleted the feature/layouthelper-for-dry-icons branch September 11, 2020 09:43
sakiss pushed a commit to sakiss/joomla-cms that referenced this pull request Oct 16, 2020
…Layout for iconclass (joomla#30470)

* 🎨 merge two equal JLayouts into one new JLayout

* replace hard coded icon to call for JLayout

* replace icon mapping to call for JLayout

* add icon protected to layout

* icon protected moved to jlayout iconclass

* remove fas

* add icon trash to mapping

* add parameter to check if html should be rendered or icon class only

* simplify php

* replace massive if-then-elseif-then by switch

* merge duplicate outcome fa-times

* be consistent

* simplify switch thx @Quy

* copy changes from https://github.com/joomla/joomla-cms/pull/30468/files

* copy changes from https://github.com/joomla/joomla-cms/pull/30468/files

* remove setting icon to itself

* copy changes from joomla#30468

* change to use layout

* Update libraries/src/HTML/Helpers/ActionsDropdown.php

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>

* use LayoutHelper in function

* let default html output be true, instead of false

* Update layouts/joomla/icon/iconclass.php

I like this PHP7 operator

Co-authored-by: Quy <quy@fluxbb.org>

Co-authored-by: Troy T. Hall <programming@hallhome.us>
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Co-authored-by: Quy <quy@fluxbb.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants