Modifying the sermons admin view to put the filters on top.

This commit is contained in:
Emmanuel Danan 2020-11-12 14:51:05 +01:00
parent 57dc233c7f
commit c153288f78
7 changed files with 654 additions and 516 deletions

View File

@ -59,7 +59,9 @@ class JFormFieldPreachers extends JFormFieldList
$options = array();
if ($items)
{
if ($this->multiple === false) {
$options[] = JHtml::_('select.option', '', 'Select a preacher');
}
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name);

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_sermondistributor/models/rules"
addfieldpath="/administrator/components/com_sermondistributor/models/fields"
>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CONTENT_FILTER_SEARCH_LABEL"
description="COM_CONTENT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="COM_CONTENT_FILTER_PUBLISHED"
description="COM_CONTENT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_sermondistributor.sermon"
onchange="this.form.submit();"
published="0,1,2"
/>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<!-- Preacher Field. Type: Preachers. (custom) -->
<field
type="preachers"
name="preacher"
label="COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_PREACHER_DESCRIPTION"
class="multiplePreachers"
multiple="true"
onchange="this.form.submit();"
/>
<!-- Series Field. Type: Series. (custom) -->
<field
type="series"
name="series"
label="COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_SERIES_DESCRIPTION"
class="list_class"
multiple="false"
onchange="this.form.submit();"
/>
<!-- Link_type Field. Type: Radio. (joomla) -->
<field
type="list"
name="link_type"
label="COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_DESCRIPTION"
class="list_class"
onchange="this.form.submit();"
>
<!-- Option Set. -->
<option value="">
Select link type</option>
<option value="1">
COM_SERMONDISTRIBUTOR_SERMON_ENCRYPTED</option>
<option value="2">
COM_SERMONDISTRIBUTOR_SERMON_DIRECT</option>
</field>
<!-- Source Field. Type: List. (joomla) -->
<field
type="list"
name="source"
label="COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_SOURCE_DESCRIPTION"
class="multipleSource"
multiple="true"
onchange="this.form.submit();"
>
<!-- Option Set. -->
<option value="1">
COM_SERMONDISTRIBUTOR_SERMON_LOCAL_FOLDER</option>
<option value="2">
COM_SERMONDISTRIBUTOR_SERMON_EXTERNAL_SOURCE</option>
<option value="3">
COM_SERMONDISTRIBUTOR_SERMON_URL</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published ASC">JSTATUS_ASC</option>
<option value="a.published DESC">JSTATUS_DESC</option>
<option value="a.name ASC">Name ASC</option>
<option value="a.name DESC">Name DESC</option>
<option value="g.name ASC">Preacher ASC</option>
<option value="g.name DESC">Preacher DESC</option>
<option value="h.name ASC">Series ASC</option>
<option value="h.name DESC">Series DESC</option>
<option value="a.short_description ASC">Short description ASC</option>
<option value="a.short_description DESC">Short description DESC</option>
<option value="category_title ASC">Sermon categories ASC</option>
<option value="category_title DESC">Sermon categories DESC</option>
<option value="a.link_type ASC">Download Link Option ASC</option>
<option value="a.link_type DESC">Download Link Option DESC</option>
<option value="a.source ASC">File source ASC</option>
<option value="a.source DESC">File source DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@ -42,9 +42,10 @@ class SermondistributorModelSermons extends JModelList
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
'a.access','access',
'a.name','name',
'g.name',
'h.name',
'g.name','preacher',
'h.name','series',
'a.short_description','short_description',
'c.title','category_title',
'c.id', 'category_id',
@ -74,8 +75,8 @@ class SermondistributorModelSermons extends JModelList
$name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name');
$this->setState('filter.name', $name);
$preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
$this->setState('filter.preacher', $preacher);
// $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
// $this->setState('filter.preacher', $preacher);
$series = $this->getUserStateFromRequest($this->context . '.filter.series', 'filter_series');
$this->setState('filter.series', $series);
@ -86,8 +87,8 @@ class SermondistributorModelSermons extends JModelList
$category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category');
$this->setState('filter.category', $category);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
$this->setState('filter.category_id', $categoryId);
// $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
// $this->setState('filter.category_id', $categoryId);
$catid = $app->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid');
$this->setState('filter.catid', $catid);
@ -116,6 +117,23 @@ class SermondistributorModelSermons extends JModelList
$created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
$this->setState('filter.created', $created);
// Handle multiple fields -> original code commented above
$formSubmited = $app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access');
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
$preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
$categoryId = $app->input->post->get('category_id');
$this->setState('filter.category_id', $categoryId);
$preacher = $app->input->post->get('preacher');
$this->setState('filter.preacher', $preacher);
}
// List state information.
parent::populateState($ordering, $direction);
}
@ -253,10 +271,19 @@ class SermondistributorModelSermons extends JModelList
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Filter by access level.
if ($access = $this->getState('filter.access'))
$access = $this->getState('filter.access');
if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif (is_array($access))
{
$access = ArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}
// Implement View Level Access
if (!$user->authorise('core.options', 'com_sermondistributor'))
{
@ -279,9 +306,17 @@ class SermondistributorModelSermons extends JModelList
}
// Filter by preacher.
if ($preacher = $this->getState('filter.preacher'))
$preacher = $this->getState('filter.preacher');
if (is_numeric($preacher))
{
$query->where('a.preacher = ' . $db->quote($db->escape($preacher)));
$query->where('a.preacher = ' . (int) $preacher);
}
elseif (is_array($preacher))
{
$preacher = ArrayHelper::toInteger($preacher);
$preacher = implode(',', $preacher);
$query->where('a.preacher IN (' . $preacher . ')');
}
// Filter by series.
if ($series = $this->getState('filter.series'))
@ -294,9 +329,17 @@ class SermondistributorModelSermons extends JModelList
$query->where('a.link_type = ' . $db->quote($db->escape($link_type)));
}
// Filter by Source.
if ($source = $this->getState('filter.source'))
$source = $this->getState('filter.source');
if (is_numeric($source))
{
$query->where('a.source = ' . $db->quote($db->escape($source)));
$query->where('a.source = ' . (int) $source);
}
elseif (is_array($source))
{
$source = ArrayHelper::toInteger($source);
$source = implode(',', $source);
$query->where('a.source IN (' . $source . ')');
}
// Filter by a single or group of categories.
@ -317,7 +360,7 @@ class SermondistributorModelSermons extends JModelList
{
ArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $categoryId);
$query->where('a.category IN (' . $categoryId . ')');
$query->where('a.catid IN (' . $categoryId . ')');
}

View File

@ -29,6 +29,10 @@ defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY')));
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_ACCESS')));
JHtml::_('formbehavior.chosen', '.multiplePreachers', null, array('placeholder_text_multiple' => JText::_('Select preachers')));
JHtml::_('formbehavior.chosen', '.multipleSource', null, array('placeholder_text_multiple' => JText::_('Select source')));
JHtml::_('formbehavior.chosen', 'select');
if ($this->saveOrder)
@ -38,23 +42,6 @@ if ($this->saveOrder)
}
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $this->listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_sermondistributor&view=sermons'); ?>" method="post" name="adminForm" id="adminForm">
<?php if(!empty( $this->sidebar)): ?>
<div id="j-sidebar-container" class="span2">
@ -64,13 +51,15 @@ if ($this->saveOrder)
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php
// Search tools bar
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
<?php if (empty($this->items)): ?>
<?php echo $this->loadTemplate('toolbar');?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<?php echo $this->loadTemplate('toolbar');?>
<table class="table table-striped" id="sermonList">
<thead><?php echo $this->loadTemplate('head');?></thead>
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
@ -88,8 +77,6 @@ if ($this->saveOrder)
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<input type="hidden" name="filter_order" value="<?php echo $this->listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->listDirn; ?>" />
<input type="hidden" name="boxchecked" value="0" />
</div>
<?php endif; ?>

View File

@ -40,7 +40,7 @@ $edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit";
<?php
if ($this->saveOrder)
{
$iconClass = ' inactive';
$iconClass = '';
}
else
{

View File

@ -29,7 +29,7 @@ defined('_JEXEC') or die('Restricted access');
<tr>
<?php if ($this->canEdit&& $this->canState): ?>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th>
<th width="20" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
@ -43,29 +43,29 @@ defined('_JEXEC') or die('Restricted access');
</th>
<?php endif; ?>
<th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL', 'g.name', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL', 'g.name', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL', 'h.name', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL', 'h.name', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SHORT_DESCRIPTION_LABEL', 'a.short_description', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SHORT_DESCRIPTION_LABEL', 'a.short_description', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERMONS_CATEGORIES', 'category_title', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERMONS_CATEGORIES', 'category_title', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL', 'a.link_type', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL', 'a.link_type', $this->listDirn, $this->listOrder); ?>
</th>
<th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL', 'a.source', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL', 'a.source', $this->listDirn, $this->listOrder); ?>
</th>
<?php if ($this->canState): ?>
<th width="10" class="nowrap center" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
</th>
<?php else: ?>
<th width="10" class="nowrap center" >
@ -73,6 +73,6 @@ defined('_JEXEC') or die('Restricted access');
</th>
<?php endif; ?>
<th width="5" class="nowrap center hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
<?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
</th>
</tr>

View File

@ -50,7 +50,7 @@ class SermondistributorViewSermons extends JViewLegacy
// Add the list ordering clause.
$this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id'));
$this->listDirn = $this->escape($this->state->get('list.direction', 'asc'));
$this->saveOrder = $this->listOrder == 'ordering';
$this->saveOrder = $this->listOrder == 'a.ordering';
// set the return here value
$this->return_here = urlencode(base64_encode((string) JUri::getInstance()));
// get global action permissions
@ -60,6 +60,8 @@ class SermondistributorViewSermons extends JViewLegacy
$this->canCreate = $this->canDo->get('sermon.create');
$this->canDelete = $this->canDo->get('sermon.delete');
$this->canBatch = $this->canDo->get('core.batch');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
@ -169,11 +171,6 @@ class SermondistributorViewSermons extends JViewLegacy
if ($this->canState)
{
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_published',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
);
// only load if batch allowed
if ($this->canBatch)
{
@ -185,12 +182,6 @@ class SermondistributorViewSermons extends JViewLegacy
}
}
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_ACCESS'),
'filter_access',
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
JHtmlBatch_::addListSelection(
@ -200,13 +191,6 @@ class SermondistributorViewSermons extends JViewLegacy
);
}
// Category Filter.
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_sermondistributor.sermon'), 'value', 'text', $this->state->get('filter.category_id'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Category Batch selection.
@ -229,13 +213,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Preacher Name filter if it has values
if (SermondistributorHelper::checkArray($this->preacherNameOptions))
{
// Preacher Name Filter
JHtmlSidebar::addFilter(
'- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL').' -',
'filter_preacher',
JHtml::_('select.options', $this->preacherNameOptions, 'value', 'text', $this->state->get('filter.preacher'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Preacher Name Batch Selection
@ -259,13 +236,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Series Name filter if it has values
if (SermondistributorHelper::checkArray($this->seriesNameOptions))
{
// Series Name Filter
JHtmlSidebar::addFilter(
'- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL').' -',
'filter_series',
JHtml::_('select.options', $this->seriesNameOptions, 'value', 'text', $this->state->get('filter.series'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Series Name Batch Selection
@ -289,13 +259,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Link Type filter if it has values
if (SermondistributorHelper::checkArray($this->link_typeOptions))
{
// Link Type Filter
JHtmlSidebar::addFilter(
'- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL').' -',
'filter_link_type',
JHtml::_('select.options', $this->link_typeOptions, 'value', 'text', $this->state->get('filter.link_type'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Link Type Batch Selection
@ -319,13 +282,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Source filter if it has values
if (SermondistributorHelper::checkArray($this->sourceOptions))
{
// Source Filter
JHtmlSidebar::addFilter(
'- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL').' -',
'filter_source',
JHtml::_('select.options', $this->sourceOptions, 'value', 'text', $this->state->get('filter.source'))
);
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Source Batch Selection