ADD list of items

This commit is contained in:
Thomas Kuschel 2023-10-15 23:23:02 +02:00
parent 36cb70eea0
commit 303f1c8a00
5 changed files with 105 additions and 28 deletions

View File

@ -20,6 +20,8 @@ COM_DEPOT_FIELD_SELECT_MANUFACTURER="Manufacturer"
COM_DEPOT_FIELD_SELECT_STOCK="Stock Location"
COM_DEPOT_LEGEND_DETAILS="Component Details"
COM_DEPOT_LEGEND_STATISTICS="Component Statistics"
COM_DEPOT_N_ITEMS_DELETED_1="One component deleted"
COM_DEPOT_N_ITEMS_DELETED_MORE="%d components deleted"
COM_DEPOT_SELECT_YOUR_OPTION="Select your option"
COM_DEPOT_TAB_NEW_PART="New Component"
COM_DEPOT_TAB_EDIT_PART="Component Details"

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Depot.Administrator
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.6
*/
namespace KW4NZ\Component\Depot\Administrator\Controller;
use Joomla\CMS\MVC\Controller\AdminController;
defined('_JEXEC') or die;
class PartsController extends AdminController
{
public function getModel($name = 'Part', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
}

View File

@ -30,14 +30,14 @@ class PartsModel extends ListModel
$query = $db->getQuery(true);
$query->select('*')
->from($db->quoteName('#__depot', 'd'));
// $query->select('*')
// ->from($db->quoteName('#__depot', 'd'));
// order by
$query->order('d.id ASC');
if (true) {
return $query;
}
// $query->order('d.id ASC');
// if (true) {
// return $query;
// }
// select the required fields from the table
$query->select(
@ -57,8 +57,8 @@ class PartsModel extends ListModel
->select(
[
$db->quoteName('u.name', 'creator'),
$db->quoteName('m.short_name', 'manufacturer'),
$db->quoteName('m.long_name', 'manufacturer_long'),
$db->quoteName('m.name_short', 'manufacturer'),
$db->quoteName('m.name_long', 'manufacturer_long'),
$db->quoteName('s.name', 'stock_name'),
]
)

View File

@ -12,8 +12,13 @@ namespace KW4NZ\Component\Depot\Administrator\View\Parts;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// use Joomla\CMS\Language\Text;
class HtmlView extends BaseHtmlView
@ -25,6 +30,18 @@ class HtmlView extends BaseHtmlView
$this->items = $this->get('Items');
// set the toolbar
$this->addToolbar();
parent::display($tpl);
}
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_DEPOT_MANAGER_PARTS'));
ToolbarHelper::addNew('part.add');
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'parts.delete');
ToolbarHelper::publish('parts.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('parts.unpublish', 'JTOOLBAR_UNPUBLISH', true);
}
}

View File

@ -7,26 +7,61 @@
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.0.1
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
?>
<h2>Welcome to my Depot Component!</h2>
<p>Link: <a href="index.php?option=com_depot&view=part&layout=edit&id=1">Part</a></p>
<form action="<?= Route::_('index.php?option=com_depot&view=parts'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (empty($this->items)): ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true">
</span>
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else: ?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>COM_DEPOT_TABLE_HEAD_ID</th>
<th>COM_DEPOT_TABLE_HEAD_NAME</th>
<th>
<?= HTMLHelper::_('grid.checkall'); ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_ID') ?>
</th>
<th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_NAME') ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item): ?>
<tr>
<td>
<?= $item->id ?>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?= $item->component_name ?>
<?= $item->id ?>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=part.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->component_name); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?= HTMLHelper::_('form.token'); ?>
</form>