? Pending
Referenced as Related to: # 8767

User tests: Successful: Unsuccessful:

avatar panopt
panopt
9 Dec 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

avatar panopt panopt - open - 9 Dec 2015
avatar panopt panopt - change - 9 Dec 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 9 Dec 2015
Labels Added: ?
avatar Gerlof Gerlof - test_item - 12 Dec 2015 - Tested successfully
avatar Gerlof
Gerlof - comment - 12 Dec 2015

I have tested this item :white_check_mark: 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.

avatar panopt panopt - change - 14 Dec 2015
Title
Modal category field optimization
Modal category searchtools optimization
avatar panopt
panopt - comment - 14 Dec 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'.

avatar anibalsanchez anibalsanchez - test_item - 19 Dec 2015 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 19 Dec 2015

I have tested this item :white_check_mark: successfully on b5cf4b8

Test OK


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

avatar brianteeman brianteeman - change - 19 Dec 2015
Status Pending Ready to Commit
avatar brianteeman
brianteeman - comment - 19 Dec 2015

Setting RTC - thanks for testing


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

avatar joomla-cms-bot joomla-cms-bot - change - 19 Dec 2015
Labels Added: ?
avatar infograf768
infograf768 - comment - 20 Dec 2015

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

avatar infograf768 infograf768 - change - 20 Dec 2015
Status Ready to Commit Pending
avatar infograf768 infograf768 - alter_testresult - 20 Dec 2015 - Gerlof: Not tested
avatar infograf768 infograf768 - alter_testresult - 20 Dec 2015 - anibalsanchez: Not tested
avatar infograf768
infograf768 - comment - 20 Dec 2015

Taking off RTC


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

avatar joomla-cms-bot joomla-cms-bot - change - 20 Dec 2015
Labels Removed: ?
avatar infograf768
infograf768 - comment - 20 Dec 2015

@Bakual @phproberto

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

avatar infograf768
infograf768 - comment - 21 Dec 2015

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?

avatar infograf768
infograf768 - comment - 21 Dec 2015

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

avatar panopt
panopt - comment - 21 Dec 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')
        )
)); 
avatar infograf768
infograf768 - comment - 21 Dec 2015

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.

avatar panopt
panopt - comment - 21 Dec 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...

avatar infograf768
infograf768 - comment - 21 Dec 2015

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.

avatar panopt
panopt - comment - 21 Dec 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" />
avatar infograf768
infograf768 - comment - 22 Dec 2015

@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

avatar infograf768
infograf768 - comment - 22 Dec 2015

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
avatar infograf768
infograf768 - comment - 22 Dec 2015

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

avatar panopt
panopt - comment - 22 Dec 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...

avatar panopt
panopt - comment - 22 Dec 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' .

avatar panopt
panopt - comment - 22 Dec 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

avatar infograf768
infograf768 - comment - 23 Dec 2015

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

avatar Bakual
Bakual - comment - 23 Dec 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.

avatar infograf768
infograf768 - comment - 23 Dec 2015

@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)?

avatar panopt
panopt - comment - 23 Dec 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')
);
avatar Bakual
Bakual - comment - 23 Dec 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.

avatar brianteeman brianteeman - change - 28 Mar 2016
Category Layout
avatar andrepereiradasilva
andrepereiradasilva - comment - 8 May 2016

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

avatar brianteeman brianteeman - change - 8 May 2016
Status Pending Information Required
avatar brianteeman
brianteeman - comment - 7 Jun 2016

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.

avatar brianteeman brianteeman - change - 7 Jun 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-06-07 09:59:25
Closed_By brianteeman
avatar brianteeman brianteeman - close - 7 Jun 2016

Add a Comment

Login with GitHub to post a comment