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

Modal category searchtools optimization #8633

Closed
wants to merge 1 commit into from
Closed

Conversation

panopt
Copy link
Contributor

@panopt panopt commented Dec 9, 2015

Bring up all relevant filters to the modal category field.
The template code is simplified while enjoying the factorization of JLayoutHelper.

category_modal_exemple-01

Testing

To test the modal category field ( you can do what is indicated at #8185; listed below ) :

  1. Change the file :
    administrator/components/com_content/models/forms/article.xml
    45 - : <field name="catid" type="categoryedit"
    45 + : <field name="catid" type="modal_category"
  2. open an article to use the field :
    category_modal_exemple-on-article-01

Bring up all relevant filters to the modal category field.
The template code is simplified while enjoying the factorization of JLayoutHelper.

To test the modal category field ( you can you can do what is indicated at joomla#8185 ) :

Change the file
administrator/components/com_content/models/forms/article.xml
45: <field name="catid" type="categoryedit"
to
45: <field name="catid" type="modal_category"
and open an article
@Gerlof
Copy link

Gerlof commented Dec 12, 2015

I have tested this item ✅ successfully on b5cf4b8

Works as expected.
Maybe you have to doublecheck how the select/deselect buttons and modal look on mobile devices.


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

@panopt panopt changed the title Modal category field optimization Modal category searchtools optimization Dec 14, 2015
@panopt
Copy link
Contributor Author

panopt commented Dec 14, 2015

Thanks for testing @Gerlof.

You are right, I could notice that the category modal will not work on mobile. It could be an other PR.
This PR (I renamed it) focuses only on the category modal 'searchtools'.

@anibalsanchez
Copy link
Contributor

I have tested this item ✅ successfully on b5cf4b8

Test OK


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

@brianteeman
Copy link
Contributor

Setting RTC - thanks for testing


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Dec 19, 2015
@infograf768
Copy link
Member

I am taking off the RTC Label here as this patch has the potential of killing multilingual sites category associations by letting associate a category to itself or to the wrong target language. The language filter/Select should NOT display in this case. It should obey to ForcedLanguage
See this screen capture:

https://www.dropbox.com/s/ij46tywkgvpwtu6/modal_categories.mp4?dl=0

@infograf768
Copy link
Member

Taking off RTC


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

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Dec 20, 2015
@infograf768
Copy link
Member

@Bakual @phproberto

Can you have a look at this? I tried to play with filtersHidden without much success.

@infograf768
Copy link
Member

I have a solution which works here, by not displaying the language filter in SearchTools ONLY when dealing with category multilingual associations.
It introduces though a change in /layouts/joomla/searchtools/default/filters.php
This "may" not be an issue as we could use it in the other modals when forcedLanguage is used for associations.

We first have to check if the modal_category type field is used when dealing with category associations. The variable $function in this case contains jSelectCategory_jform_associations_xx_XX where xx_XX is en_GB, fr_FR, etc.

In /administrator/components/com_categories/views/categories/tmpl/modal.php (once applied this PR), I add on top

// Are we dealing with category associations?
$forcedLanguage = strpos($function, 'associations') !== false ? true : false ;

Then I modify further down the call to searchtools layout by adding an option:

        <?php if ($this->state->get('filter.forcedLanguage') && $forcedLanguage == true) : ?>
            <?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('language' => 'forcedlanguage'))); ?>
        <?php else : ?>
            <?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
        <?php endif; ?>

Then I modify /layouts/joomla/searchtools/default/filters.php to get something like:

<?php
/**
 * @package     Joomla.Site
 * @subpackage  Layout
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_BASE') or die;

$data = $displayData;

// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');

// Check for forcedlanguage in multilingual associations
$forcedLanguage = in_array('forcedlanguage', $data['options']) ? true : false ;
?>
<?php if ($filters) : ?>
    <?php foreach ($filters as $fieldName => $field) : ?>
        <?php if ($forcedLanguage == true) : ?>
            <?php if ($fieldName != 'filter_search' && $fieldName != 'filter_language') : ?>
                <div class="js-stools-field-filter">
                    <?php echo $field->input; ?>
                </div>
            <?php endif; ?>
        <?php else : ?>
            <?php if ($fieldName != 'filter_search') : ?>
                <div class="js-stools-field-filter">
                    <?php echo $field->input; ?>
                </div>
            <?php endif; ?>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endif; ?>

Here are the screenshots obtained.
First when associating categories, no more Language filter:
associatingcat

Then, after changing the catid field in article.xml to "modal_category"

modal_category field

Modal obtained:
choosing cat in article

@Bakual @phproberto
What do you think? Any better way?

@infograf768
Copy link
Member

Hmm, even that does not work perfectly when the field modal_category is added to other xmls.

@panopt
Copy link
Contributor Author

panopt commented Dec 21, 2015

@infograf768,

'filtersHidden' is a boolean. I guess it is used to hide all filters ?

I propose to introduce a 'hiddenFilters' (array) option that lets us set filters as hidden:

/layouts/joomla/searchtools/default/filters.php

<?php
/**
 * @package     Joomla.Site
 * @subpackage  Layout
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_BASE') or die;

$data = $displayData;

// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');

// Introduced a 'hiddenFilters' (array) option that lets us set filters as hidden
if (isset($data['options']['hiddenFilters']))
{
    foreach ($data['options']['hiddenFilters'] as $hiddenFilter){
        if (isset($filters[$hiddenFilter]))
        {
            unset($filters[$hiddenFilter]);
        }
    }
}

// Remove explicitly the search filter
unset($filters['filter_search']);

?>
<?php if ($filters) : ?>
    <?php foreach ($filters as $fieldName => $field) : ?>
            <div class="js-stools-field-filter">
                <?php echo $field->input; ?>
            </div>
    <?php endforeach; ?>
<?php endif; ?>

Then, We can do:

echo JLayoutHelper::render('joomla.searchtools.default', array(
        'view' => $this,
        'options' => array(
                'hiddenFilters' => array('filter_language')
        )
)); 

@infograf768
Copy link
Member

This does not work either in categories association. When using the Clear button it reinstate the language filter.

FYI, this modal and the "modal_category" field were never coded to be used elsewhere than for category associations...

If someone wants to use that field elsewhere it should never show the language filter in the associations case and always display it in any other case. It has to be tested on a multilingual site and the "modal_category" field should be able to replace everywhere the "categoryedit" field.

@panopt
Copy link
Contributor Author

panopt commented Dec 21, 2015

I Thank You for your help,

I'll open an other PR "Possibility to remove filters individually when using the searchtools layout helper" with the code I have just given. I am convinced it could be useful in many situations.

If it's validated,
Here, It would allow to use the 'searchtools layout helper' (removing unwanted filters) in the 'modal_category' template . It will be a first step...

@infograf768
Copy link
Member

Ok for the new feature for the filters.php, but please remember that in this precise case of "modal_category", with your code (this PR + your proposed filters.php), we still have an issue with the Clear button when we have a conditional.
I am using this in the modal.php (after applying your PR)

// Are we dealing with category associations?
$forcedLanguage = strpos($function, 'associations') !== false ? true : false ;
?>

<form action="<?php echo JRoute::_('index.php?option=com_categories&view=categories&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1'); ?>" method="post" name="adminForm" id="adminForm">
    <fieldset class="filter clearfix">
        <?php if ($this->state->get('filter.forcedLanguage') && $forcedLanguage == true) : ?>
            <?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('hiddenFilters' => array('filter_language')))); ?> 
        <?php else : ?>
            <?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
        <?php endif; ?>
        <hr class="hr-condensed" />
    </fieldset>
etc.

and I get

https://www.dropbox.com/s/qyi6j8pds5yrga4/cat_modal2.mp4?dl=0

If I do not have any conditional, then your filters.php works great.

@panopt
Copy link
Contributor Author

panopt commented Dec 21, 2015

Thank You,
You've pinpointed the problem : I had neglected 'forcedLanguage'.

There seems to work well with :

<fieldset class="filter clearfix">
<?php if ($this->state->get('filter.forcedLanguage')) : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('hiddenFilters' => array('filter_language')))); ?>
<input type="hidden" name="forcedLanguage" value="<?php echo $this->escape($this->state->get('filter.forcedLanguage')); ?>" />
<input type="hidden" name="filter_language" value="<?php echo $this->escape($this->state->get('filter.language')); ?>" />
<?php else : ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php endif; ?>
<hr class="hr-condensed" />

@infograf768
Copy link
Member

@panopt
This works indeed as far as the Language Filter display is concerned.
2 issues remain:

  1. we can't sort anymore when clicking on the column headings
  2. the Search Tools buttons tips are unreadable as they are displayed on top of the buttons

@infograf768
Copy link
Member

For issue 2, looks like it can be solved by re-adding

<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
``
in your PR

@infograf768
Copy link
Member

as for the tip we are already missing in the present modal.php the "data-placement="bottom"

@panopt
Copy link
Contributor Author

panopt commented Dec 22, 2015

<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />

The code above neutralizes the select ordering field:
capture du 2015-12-22 13 26 12

I am looking for a solution...

@panopt
Copy link
Contributor Author

panopt commented Dec 22, 2015

For fix the issue 1. 'we can't sort anymore when clicking on the column headings'.
Every occurrence (4) of JHtml::_('grid.sort' should be replaced with JHtml::_('searchtools.sort' .

@panopt
Copy link
Contributor Author

panopt commented Dec 22, 2015

For fix issue 2. 'the Search Tools buttons tips are unreadable as they are displayed on top of the buttons':

JHtml::_('bootstrap.tooltip');
should be replaced with:
JHtml::_('bootstrap.tooltip','.hasTooltip', array('placement' => 'bottom'));

(Notice that bootstrap 2 does not allow 'auto top' placement)

@infograf768, thank you again

@infograf768
Copy link
Member

These would work indeed.
One side aspect (but not very important), now all tooltips are displayed at bottom, not only the buttons.

@Bakual
Copy link
Contributor

Bakual commented Dec 23, 2015

If you can give the searchtools buttons a specific class, then you can place those tooltips different from the others by using two JHtml::_('bootstrap.tooltip) calls. One generic and one for the search tool specific ones.

@infograf768
Copy link
Member

@Bakual
This PR, once modified and once #8767 is merged, uses the top buttons which are defined in the core layouts bar.php

We could override this layout when using com_categories directly, but would it work when the modal_category field is used in other contexts (for example a module or a menu item)?

@panopt
Copy link
Contributor Author

panopt commented Dec 23, 2015

Thanks you,

'Language' and 'Id' (th) tooltips are truncated when placed on top :
tooltip-truncated

we must add them a class

<th ... class="nowrap hidden-phone tooltipBottom">

then

JHtml::_('bootstrap.tooltip',
   '.filter .hasTooltip, .tooltipBottom .hasTooltip', 
   array('placement' => 'bottom')
);

@Bakual
Copy link
Contributor

Bakual commented Dec 23, 2015

We could override this layout when using com_categories directly, but would it work when the modal_category field is used in other contexts (for example a module or a menu item)?

We could also directly add a second class to the core JLayout for Searchtools, which would then allow to target it. Or maybe adjust the JLayout so a class could be passed.

@andrepereiradasilva
Copy link
Contributor

if i understand correctly the issue here, this is already solved in latest staging @brianteeman @infograf768

@brianteeman
Copy link
Contributor

I am closing this at this time as it appears to have been resolved elsewhere and there has been no response to the comments. It can always be reopened if that is done.


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

@brianteeman brianteeman closed this Jun 7, 2016
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

8 participants