ADD search and filtering to the component
This commit is contained in:
parent
d5263e7405
commit
e69f2af6b0
78
admin/forms/filter_parts.xml
Normal file
78
admin/forms/filter_parts.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form addfieldprefix="Joomla\Component\Depot\Administrator\Field">
|
||||
<fields name="filter">
|
||||
<field
|
||||
name="search"
|
||||
type="text"
|
||||
inputmode="search"
|
||||
label="COM_DEPOT_PARTS_FILTER_SEARCH_LABEL"
|
||||
description="COM_DEPOT_PARTS_FILTER_SEARCH_DESC"
|
||||
hint="JSEARCH_FILTER"
|
||||
/>
|
||||
<field
|
||||
name="published"
|
||||
type="status"
|
||||
label="JSTATUS"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">JOPTION_SELECT_PUBLISHED</option>
|
||||
</field>
|
||||
<field
|
||||
name="manufacturer_id"
|
||||
type="depotmanufacturer"
|
||||
label="COM_DEPOT_HEADING_MANUFACTURER"
|
||||
extension="com_depot"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">COM_DEPOT_SELECT_MANUFACTURER</option>
|
||||
</field>
|
||||
<field
|
||||
name="stock_id"
|
||||
type="depotstock"
|
||||
label="COM_DEPOT_HEADING_STOCK"
|
||||
extension="com_depot"
|
||||
class="js-select-submit-on-change"
|
||||
>
|
||||
<option value="">COM_DEPOT_SELECT_STOCK</option>
|
||||
</field>
|
||||
</fields>
|
||||
|
||||
<!-- ('d.id'),
|
||||
$db->quoteName('d.component_name'),
|
||||
$db->quoteName('d.alias'),
|
||||
$db->quoteName('d.description'),
|
||||
$db->quoteName('d.quantity'),
|
||||
$db->quoteName('d.quantity_exp'),
|
||||
$db->quoteName('d.ordering'),
|
||||
-->
|
||||
<fields name="list">
|
||||
<field
|
||||
name="fullordering"
|
||||
type="list"
|
||||
label="JGLOBAL_SORT_BY"
|
||||
statuses="*,0,1,2,-2"
|
||||
class="js-select-submit-on-change"
|
||||
default="d.component_name ASC"
|
||||
validate="options"
|
||||
>
|
||||
<option value="">JGLOBAL_SORT_BY</option>
|
||||
<option value="d.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
|
||||
<option value="d.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
|
||||
<option value="d.state ASC">JSTATUS_ASC</option>
|
||||
<option value="d.state DESC">JSTATUS_DESC</option>
|
||||
<option value="d.component_name ASC">JGLOBAL_NAME_ASC</option>
|
||||
<option value="d.component_name DESC">JGLOBAL_NAME_DESC</option>
|
||||
<option value="d.quantity ASC">COM_DEPOT_QUANTITY_ASC</option>
|
||||
<option value="d.quantity DESC">COM_DEPOT_QUANTITY_DESC</option>
|
||||
<option value="d.id ASC">JGRID_HEADING_ID_ASC</option>
|
||||
<option value="d.id DESC">JGRID_HEADING_ID_DESC</option>
|
||||
</field>
|
||||
<field
|
||||
name="limit"
|
||||
type="limitbox"
|
||||
label="JGLOBAL_LIST_LIMIT"
|
||||
default="25"
|
||||
class="js-select-submit-on-change"
|
||||
/>
|
||||
</fields>
|
||||
</form>
|
@ -11,7 +11,8 @@
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\CMS\Table\Table;
|
||||
// use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\ParameterType;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
@ -67,6 +68,12 @@ class PartsModel extends ListModel
|
||||
->join('LEFT', $db->quoteName('#__depot_stock', 's'), $db->quoteName('s.id') . ' = ' . $db->quoteName('d.stock_id'))
|
||||
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('d.checked_out'));
|
||||
|
||||
// filter: like / search
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search)) {
|
||||
$like = $db->quote('%' . $search . '%');
|
||||
$query->where($db->quoteName('d.component_name') . ' LIKE ' . $like);
|
||||
}
|
||||
// Filter by published state
|
||||
$published = (string) $this->getState('filter.published');
|
||||
if (is_numeric($published)) {
|
||||
@ -74,7 +81,8 @@ class PartsModel extends ListModel
|
||||
$query->where($db->quoteName('d.state') . ' = :published')
|
||||
->bind(':published', $published, ParameterType::INTEGER);
|
||||
} elseif ($published === '') {
|
||||
$query->where($db->quoteName('d.state') . ' IN (0, 1)');
|
||||
//$query->where($db->quoteName('d.state') . ' IN (0, 1)');
|
||||
$query->whereIn($db->quoteName('d.state'), [0, 1]);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
@ -30,6 +30,10 @@ class HtmlView extends BaseHtmlView
|
||||
|
||||
$this->items = $this->get('Items');
|
||||
|
||||
// adding filters
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
|
@ -11,11 +11,14 @@
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?= Route::_('index.php?option=com_depot&view=parts'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
|
||||
<?= LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
|
||||
|
||||
<?php if (empty($this->items)): ?>
|
||||
<div class="alert alert-info">
|
||||
<span class="icon-info-circle" aria-hidden="true">
|
||||
@ -23,7 +26,6 @@ use Joomla\CMS\Router\Route;
|
||||
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -2,12 +2,12 @@
|
||||
<extension type="component" method="upgrade">
|
||||
<name>Depot</name>
|
||||
<author>KW4NZ</author>
|
||||
<creationDate>2023-10-15</creationDate>
|
||||
<creationDate>2023-10-24</creationDate>
|
||||
<copyright>(C) KW4NZ Thomas Kuschel</copyright>
|
||||
<license>GPL v2 +; see LICENSE.md</license>
|
||||
<authorEmail>thomas@kuschel.at</authorEmail>
|
||||
<authorUrl>https://kuschel.at</authorUrl>
|
||||
<version>0.9.3</version>
|
||||
<version>0.9.4</version>
|
||||
<description>COM_DEPOT_XML_DESCRIPTION</description>
|
||||
<namespace path="src/">KW4NZ\Component\Depot</namespace>
|
||||
<install> <!-- Runs on install -->
|
||||
|
Loading…
Reference in New Issue
Block a user