Skip to content

Commit

Permalink
Creating or editing a category would apply an unexpected filter in th…
Browse files Browse the repository at this point in the history
…e Browse view
  • Loading branch information
Nicholas K. Dionysopoulos committed May 15, 2018
1 parent 9c7f221 commit 9bfb1ff
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* gh-139 Sort selection lists
* Filter ARS logs by user_id (required for data export on our site)

**Bug fixes**

* Creating or editing a category would apply an unexpected filter in the Browse view

# 4.0.0

**New**
Expand Down
8 changes: 7 additions & 1 deletion component/backend/Controller/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

defined('_JEXEC') or die;

use Akeeba\ReleaseSystem\Admin\View\Categories\Html;
use FOF30\Controller\DataController;

class Category extends DataController
Expand Down Expand Up @@ -46,9 +47,14 @@ protected function onBeforeAdd()
'language' => '*',
];

/** @var Html $view */
$dataModel = $this->getModel();

foreach ($this->defaultsForAdd as $k => $v)
{
if ($stateValue = $this->getModel()->getState($k, $v))
$stateValue = $dataModel->getState($k);

if (!is_null($stateValue))
{
$this->defaultsForAdd[$k] = $stateValue;
}
Expand Down
22 changes: 9 additions & 13 deletions component/backend/View/Categories/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

defined('_JEXEC') or die;

use Akeeba\ReleaseSystem\Admin\Model\Categories;
use FOF30\View\DataView\Html as BaseView;
use JText;

Expand All @@ -29,21 +30,16 @@ protected function onBeforeBrowse()
{
parent::onBeforeBrowse();

$hash = 'ars'.strtolower($this->getName());

// ...ordering
$platform = $this->container->platform;
$input = $this->input;
$this->order = $platform->getUserStateFromRequest($hash . 'filter_order', 'filter_order', $input, 'id');
$this->order_Dir = $platform->getUserStateFromRequest($hash . 'filter_order_Dir', 'filter_order_Dir', $input, 'DESC');
/** @var Categories $model */
$model = $this->getModel();

// ...filter state
$this->filters['title'] = $platform->getUserStateFromRequest($hash . 'filter_title', 'title', $input);
$this->filters['published'] = $platform->getUserStateFromRequest($hash . 'filter_published', 'published', $input);
$this->filters['type'] = $platform->getUserStateFromRequest($hash . 'filter_type', 'type', $input);
$this->filters['vgroup'] = $platform->getUserStateFromRequest($hash . 'filter_vgroup', 'vgroup', $input);
$this->filters['access'] = $platform->getUserStateFromRequest($hash . 'filter_access', 'access', $input);
$this->filters['language'] = $platform->getUserStateFromRequest($hash . 'filter_language', 'language', $input);
$this->filters['title'] = $model->getState('title');
$this->filters['published'] = $model->getState('published');
$this->filters['type'] = $model->getState('type');
$this->filters['vgroup'] = $model->getState('vgroup');
$this->filters['access'] = $model->getState('access');
$this->filters['language'] = $model->getState('language');

// Construct the array of sorting fields
$this->sortFields = array(
Expand Down
20 changes: 10 additions & 10 deletions component/backend/View/Categories/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

defined('_JEXEC') or die;

$js = FEFHtml::jsOrderingBackend($this->order);
$js = FEFHtml::jsOrderingBackend($this->lists->order);
$this->getContainer()->template->addJSInline($js);

?>
Expand Down Expand Up @@ -49,7 +49,7 @@
</div>
</div>

<?php echo FEFHtml::selectOrderingBackend($this->getPagination(), $this->sortFields, $this->order, $this->order_Dir)?>
<?php echo FEFHtml::selectOrderingBackend($this->getPagination(), $this->sortFields, $this->lists->order, $this->lists->order_Dir)?>

</section>

Expand All @@ -63,22 +63,22 @@
<input type="checkbox" name="toggle" value="" onclick="Joomla.checkAll(this);"/>
</th>
<th>
<?php echo \JHtml::_('grid.sort', 'COM_ARS_CATEGORIES_FIELD_TITLE', 'title', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'COM_ARS_CATEGORIES_FIELD_TITLE', 'title', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
<th>
<?php echo \JHtml::_('grid.sort', 'LBL_CATEGORIES_VGROUP', 'vg_title', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'LBL_CATEGORIES_VGROUP', 'vg_title', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
<th>
<?php echo \JHtml::_('grid.sort', 'COM_ARS_CATEGORIES_FIELD_TYPE', 'type', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'COM_ARS_CATEGORIES_FIELD_TYPE', 'type', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
<th>
<?php echo \JHtml::_('grid.sort', 'JFIELD_ACCESS_LABEL', 'access', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'JFIELD_ACCESS_LABEL', 'access', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
<th width="8%">
<?php echo \JHtml::_('grid.sort', 'JPUBLISHED', 'published', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'JPUBLISHED', 'published', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
<th>
<?php echo \JHtml::_('grid.sort', 'JFIELD_LANGUAGE_LABEL', 'language', $this->order_Dir, $this->order, 'browse'); ?>
<?php echo \JHtml::_('grid.sort', 'JFIELD_LANGUAGE_LABEL', 'language', $this->lists->order_Dir, $this->lists->order, 'browse'); ?>
</th>
</tr>
</thead>
Expand Down Expand Up @@ -158,8 +158,8 @@
<input type="hidden" name="view" id="view" value="Categories"/>
<input type="hidden" name="boxchecked" id="boxchecked" value="0"/>
<input type="hidden" name="task" id="task" value="browse"/>
<input type="hidden" name="filter_order" id="filter_order" value="<?php echo $this->escape($this->order); ?>"/>
<input type="hidden" name="filter_order_Dir" id="filter_order_Dir" value="<?php echo $this->escape($this->order_Dir); ?>"/>
<input type="hidden" name="filter_order" id="filter_order" value="<?php echo $this->escape($this->lists->order); ?>"/>
<input type="hidden" name="filter_order_Dir" id="filter_order_Dir" value="<?php echo $this->escape($this->lists->order_Dir); ?>"/>
<input type="hidden" name="<?php echo $this->container->platform->getToken(true); ?>" value="1"/>
</div>
</form>

0 comments on commit 9bfb1ff

Please sign in to comment.