Version 0.9.13

This commit is contained in:
Thomas Kuschel 2023-11-18 21:05:43 +01:00
parent f656fb70fa
commit bedb36c136
24 changed files with 383 additions and 136 deletions

View File

@ -574,7 +574,9 @@ incrementing it.
/* if it is 0 -> get the max + 1 value */ /* if it is 0 -> get the max + 1 value */
if (!$data['ordering']) { if (!$data['ordering']) {
$db = Factory::getDbo(); $db = Factory::getDbo();
$query = $db->getQuery(true) // $query = $db->getQuery(true) // is deprecated,
// using createQuery() instead:
$query = $db->createQuery()
->select('MAX(ordering)') ->select('MAX(ordering)')
->from('#__depot'); ->from('#__depot');

View File

@ -35,6 +35,8 @@
<option value="p.state DESC">JSTATUS_DESC</option> <option value="p.state DESC">JSTATUS_DESC</option>
<option value="p.name ASC">JGLOBAL_NAME_ASC</option> <option value="p.name ASC">JGLOBAL_NAME_ASC</option>
<option value="p.name DESC">JGLOBAL_NAME_DESC</option> <option value="p.name DESC">JGLOBAL_NAME_DESC</option>
<option value="p.description ASC">COM_DEPOT_SORT_BY_DESCRIPTION_ASC</option>
<option value="p.description DESC">COM_DEPOT_SORT_BY_DESCRIPTION_DESC</option>
<option value="p.id ASC">JGRID_HEADING_ID_ASC</option> <option value="p.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="p.id DESC">JGRID_HEADING_ID_DESC</option> <option value="p.id DESC">JGRID_HEADING_ID_DESC</option>
</field> </field>

View File

@ -35,6 +35,8 @@
<option value="d.state DESC">JSTATUS_DESC</option> <option value="d.state DESC">JSTATUS_DESC</option>
<option value="d.component_name ASC">JGLOBAL_NAME_ASC</option> <option value="d.component_name ASC">JGLOBAL_NAME_ASC</option>
<option value="d.component_name DESC">JGLOBAL_NAME_DESC</option> <option value="d.component_name DESC">JGLOBAL_NAME_DESC</option>
<option value="d.description ASC">COM_DEPOT_SORT_BY_DESCRIPTION_ASC</option>
<option value="d.description DESC">COM_DEPOT_SORT_BY_DESCRIPTION_DESC</option>
<option value="d.quantity ASC">COM_DEPOT_SORT_BY_QUANTITY_ASC</option> <option value="d.quantity ASC">COM_DEPOT_SORT_BY_QUANTITY_ASC</option>
<option value="d.quantity DESC">COM_DEPOT_SORT_BY_QUANTITY_DESC</option> <option value="d.quantity DESC">COM_DEPOT_SORT_BY_QUANTITY_DESC</option>
<option value="manufacturer ASC">COM_DEPOT_SORT_BY_MANUFACTURER_ASC</option> <option value="manufacturer ASC">COM_DEPOT_SORT_BY_MANUFACTURER_ASC</option>

View File

@ -25,10 +25,12 @@
label="JGLOBAL_SORT_BY" label="JGLOBAL_SORT_BY"
statuses="*,0,1,2,-2" statuses="*,0,1,2,-2"
class="js-select-submit-on-change" class="js-select-submit-on-change"
default="s.name ASC" default=""
validate="options" validate="options"
> >
<option value="">JGLOBAL_SORT_BY</option> <option value="">JGLOBAL_SORT_BY</option>
<option value="s.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="s.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="s.state ASC">JSTATUS_ASC</option> <option value="s.state ASC">JSTATUS_ASC</option>
<option value="s.state DESC">JSTATUS_DESC</option> <option value="s.state DESC">JSTATUS_DESC</option>
<option value="s.name ASC">JGLOBAL_NAME_ASC</option> <option value="s.name ASC">JGLOBAL_NAME_ASC</option>

View File

@ -36,6 +36,12 @@
hint="COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER" hint="COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER"
size="40" size="40"
/> />
<field
name="description"
type="text"
label="COM_DEPOT_FIELD_DESCRIPTION_LABEL"
description="COM_DEPOT_FIELD_DESCRIPTION_DESC"
/>
<field <field
name="package_id" name="package_id"
type="sql" type="sql"

View File

@ -95,5 +95,13 @@
class="readonly" class="readonly"
readonly="true" readonly="true"
/> />
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
class="readonly"
default="0"
readonly="true"
/>
</fieldset> </fieldset>
</form> </form>

View File

@ -11,6 +11,8 @@ COM_DEPOT_FIELD_ALIAS_PART_PLACEHOLDER="Auto-generate from component name"
COM_DEPOT_FIELD_ALIAS_STOCK_PLACEHOLDER="Auto-generate from stock name" COM_DEPOT_FIELD_ALIAS_STOCK_PLACEHOLDER="Auto-generate from stock name"
COM_DEPOT_FIELD_COMPONENT_NAME_DESC="The name of the component is unique. Please do not enter special characters or umlauts." COM_DEPOT_FIELD_COMPONENT_NAME_DESC="The name of the component is unique. Please do not enter special characters or umlauts."
COM_DEPOT_FIELD_COMPONENT_NAME_LABEL="Component Name" COM_DEPOT_FIELD_COMPONENT_NAME_LABEL="Component Name"
COM_DEPOT_FIELD_DESCRIPTION_DESC="Enter here the description of the component"
COM_DEPOT_FIELD_DESCRIPTION_LABEL="Description"
COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_DESC="Enter here the acronym of the manufacturer or short name" COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_DESC="Enter here the acronym of the manufacturer or short name"
COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_LABEL="Manufacturer Acronym" COM_DEPOT_FIELD_MANUFACTURER_ACRONYM_LABEL="Manufacturer Acronym"
COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_DESC="Enter here the long name of the manufacturer" COM_DEPOT_FIELD_MANUFACTURER_LONG_NAME_DESC="Enter here the long name of the manufacturer"

View File

@ -8,6 +8,7 @@
DROP TABLE IF EXISTS `#__depot`; DROP TABLE IF EXISTS `#__depot`;
CREATE TABLE `#__depot` ( CREATE TABLE `#__depot` (
`id` SERIAL, `id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL `component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique component name (ASCII characters only)', COMMENT 'unique component name (ASCII characters only)',
`alias` VARCHAR(1024) NOT NULL DEFAULT '', `alias` VARCHAR(1024) NOT NULL DEFAULT '',
@ -28,7 +29,6 @@ CREATE TABLE `#__depot` (
`access` TINYINT(4) NOT NULL DEFAULT 0, `access` TINYINT(4) NOT NULL DEFAULT 0,
`params` VARCHAR(1024) NOT NULL DEFAULT '', `params` VARCHAR(1024) NOT NULL DEFAULT '',
`image` VARCHAR(1024) NOT NULL DEFAULT '', `image` VARCHAR(1024) NOT NULL DEFAULT '',
`ordering` INT(11) NOT NULL DEFAULT 0,
`version` int unsigned NOT NULL DEFAULT 1, `version` int unsigned NOT NULL DEFAULT 1,
-- references to other tables: -- references to other tables:
`category_id` INT(11) NOT NULL DEFAULT 0, `category_id` INT(11) NOT NULL DEFAULT 0,
@ -49,11 +49,13 @@ CREATE TABLE `#__depot` (
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`, INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`ordering`,`state`,`manufacturer_id`,`stock_id`,`package_id`) VALUES `ordering`,`state`,`manufacturer_id`,`stock_id`,`package_id`) VALUES
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1,9), ('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1,1,9),
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8); ('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2,1,8)
('R_120R','r_120r','resistor, metalic',46,'2023-11-15 23:40:00',3,1,1,2,11);
DROP TABLE IF EXISTS `#__depot_manufacturer`; DROP TABLE IF EXISTS `#__depot_manufacturer`;
CREATE TABLE `#__depot_manufacturer` ( CREATE TABLE `#__depot_manufacturer` (
`id` SERIAL, `id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL `name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique manufacturer name or abbriviation', COMMENT 'unique manufacturer name or abbriviation',
`alias` VARCHAR(127) NOT NULL DEFAULT '', `alias` VARCHAR(127) NOT NULL DEFAULT '',
@ -85,6 +87,7 @@ INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
DROP TABLE IF EXISTS `#__depot_stock`; DROP TABLE IF EXISTS `#__depot_stock`;
CREATE TABLE `#__depot_stock` ( CREATE TABLE `#__depot_stock` (
`id` SERIAL, `id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name` VARCHAR(1024) NOT NULL DEFAULT '', `name` VARCHAR(1024) NOT NULL DEFAULT '',
`alias` VARCHAR(1024) NOT NULL DEFAULT '', `alias` VARCHAR(1024) NOT NULL DEFAULT '',
`owner_id` INT(10) UNSIGNED NOT NULL DEFAULT 0, `owner_id` INT(10) UNSIGNED NOT NULL DEFAULT 0,
@ -123,6 +126,7 @@ INSERT INTO `#__depot_stock`(`name`, `location`, `description`, `state`, `access
DROP TABLE IF EXISTS `#__depot_package`; DROP TABLE IF EXISTS `#__depot_package`;
CREATE TABLE `#__depot_package` ( CREATE TABLE `#__depot_package` (
`id` SERIAL, `id` SERIAL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`name` VARCHAR(400) NOT NULL DEFAULT '', `name` VARCHAR(400) NOT NULL DEFAULT '',
`description` VARCHAR(4000) NOT NULL DEFAULT '', `description` VARCHAR(4000) NOT NULL DEFAULT '',
`alias` VARCHAR(400) NOT NULL DEFAULT '', `alias` VARCHAR(400) NOT NULL DEFAULT '',
@ -137,7 +141,6 @@ CREATE TABLE `#__depot_package` (
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0, `modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`ordering` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT=0 AUTO_INCREMENT=0
@ -163,8 +166,8 @@ INSERT INTO `#__depot_package` (`name`,`description`,`state`,`mounting_style_id`
DROP TABLE IF EXISTS `#__depot_mounting_style`; DROP TABLE IF EXISTS `#__depot_mounting_style`;
CREATE TABLE `#__depot_mounting_style` ( CREATE TABLE `#__depot_mounting_style` (
`id` SERIAL, `id` SERIAL,
`title` VARCHAR(100) NOT NULL DEFAULT '',
`ordering` INT(11) NOT NULL DEFAULT 0, `ordering` INT(11) NOT NULL DEFAULT 0,
`title` VARCHAR(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT=0 AUTO_INCREMENT=0

View File

@ -41,6 +41,37 @@ class PackageModel extends AdminModel
return $data; return $data;
} }
protected function prepareTable($table)
{
$date = Factory::getDate();
$user = $this->getCurrentUser();
if (empty($table->id)) {
// Set the values
$table->created = $date->toSql();
$table->created_by = $user->id;
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = $this->getDatabase();
$query = $db->createQuery()
->select('MAX(' . $db->quoteName('ordering') . ')')
->from($db->quoteName('#__depot_package'));
$db->setQuery($query);
$max = $db->loadResult();
$table->ordering = ++$max;
}
} else {
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->id;
}
}
public function save($data) public function save($data)
{ {
/* Add code to modify data before saving */ /* Add code to modify data before saving */

View File

@ -10,7 +10,6 @@
namespace KW4NZ\Component\Depot\Administrator\Model; namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType; use Joomla\Database\ParameterType;
@ -124,8 +123,9 @@ class PackagesModel extends ListModel
return $query; return $query;
} }
/** /**
* Returns a reference to the a Table object, always creating it. * Returns a reference to the Table object, always creating it.
* *
* @param string $type The table type to instantiate * @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional. * @param string $prefix A prefix for the table class name. Optional.
@ -139,5 +139,4 @@ class PackagesModel extends ListModel
{ {
return parent::getTable($type, $prefix, $config); return parent::getTable($type, $prefix, $config);
} }
} }

View File

@ -11,10 +11,11 @@
namespace KW4NZ\Component\Depot\Administrator\Model; namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\MVC\Model\ListModel;
// use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType; use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die; \defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class PartsModel extends ListModel class PartsModel extends ListModel
{ {
@ -31,6 +32,10 @@ class PartsModel extends ListModel
'd.alias', 'd.alias',
'quantity', 'quantity',
'd.quantity', 'd.quantity',
'ordering',
'd.ordering',
'description',
'd.description',
'published', 'published',
'd.published', 'd.published',
'package', 'package',
@ -75,6 +80,8 @@ class PartsModel extends ListModel
$db->quoteName('d.quantity_exp'), $db->quoteName('d.quantity_exp'),
$db->quoteName('d.ordering'), $db->quoteName('d.ordering'),
$db->quoteName('d.package_id'), $db->quoteName('d.package_id'),
$db->quoteName('d.checked_out'),
$db->quoteName('d.checked_out_time'),
] ]
) )
) )
@ -103,6 +110,7 @@ class PartsModel extends ListModel
$like = $db->quote('%' . $search . '%'); $like = $db->quote('%' . $search . '%');
$query->where($db->quoteName('d.component_name') . ' LIKE ' . $like); $query->where($db->quoteName('d.component_name') . ' LIKE ' . $like);
} }
// Filter by published state // Filter by published state
$published = (string) $this->getState('filter.published'); $published = (string) $this->getState('filter.published');
if (is_numeric($published)) { if (is_numeric($published)) {
@ -114,9 +122,10 @@ class PartsModel extends ListModel
} }
// add list ordering clause // add list ordering clause
$orderCol = $this->state->get('list.ordering', 'id'); $query->order(
$orderDirn = $this->state->get('list.direction', 'desc'); $db->quoteName($db->escape($this->getState('list.ordering', 'd.ordering'))) . ' ' .
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn)); $db->escape($this->getState('list.direction', 'ASC'))
);
return $query; return $query;
} }

View File

@ -11,10 +11,12 @@
namespace KW4NZ\Component\Depot\Administrator\Model; namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\MVC\Model\ListModel;
// use Joomla\CMS\Table\Table; use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType; use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die; \defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class StocksModel extends ListModel class StocksModel extends ListModel
{ {
@ -23,18 +25,25 @@ class StocksModel extends ListModel
$config['filter_fields'] = [ $config['filter_fields'] = [
'id', 'id',
's.id', 's.id',
's.name',
'name', 'name',
's.name',
'alias', 'alias',
's.alias', 's.alias',
's.description', 'state',
'description', 's.state',
'published', 'published',
'd.published', 's.published',
'description',
's.description',
'ordering',
's.ordering',
'checked_out',
's.checked_out',
'owner', 'owner',
]; ];
parent::__construct($config); parent::__construct($config);
} }
/** /**
* Build an SQL query to load the list data. * Build an SQL query to load the list data.
* *
@ -66,6 +75,10 @@ class StocksModel extends ListModel
$db->quoteName('s.name'), $db->quoteName('s.name'),
$db->quoteName('s.alias'), $db->quoteName('s.alias'),
$db->quoteName('s.description'), $db->quoteName('s.description'),
$db->quoteName('s.state'),
$db->quoteName('s.ordering'),
$db->quoteName('s.checked_out'),
$db->quoteName('s.checked_out_time'),
] ]
) )
) )
@ -99,9 +112,27 @@ class StocksModel extends ListModel
// Add the list ordering clause. // Add the list ordering clause.
$query->order( $query->order(
$db->quoteName($db->escape($this->getState('list.ordering', 'id'))) . ' ' . $db->escape($this->getState('list.direction', 'ASC')) $db->quoteName($db->escape($this->getState('list.ordering', 's.ordering'))) . ' ' .
$db->escape($this->getState('list.direction', 'ASC'))
); );
return $query; return $query;
} }
/**
* Returns a reference to the Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return Table A Table object
*
* @since 1.6
*/
public function getTable($type = 'Stock', $prefix = 'Administrator', $config = [])
{
return parent::getTable($type, $prefix, $config);
}
} }

View File

@ -32,6 +32,7 @@ class PackageTable extends Table
parent::check(); parent::check();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->setError($e->getMessage()); $this->setError($e->getMessage());
return false; return false;
} }
@ -50,7 +51,7 @@ class PackageTable extends Table
} }
// Set modified to created if not set // Set modified to created if not set
if ($this->modified) { if (!$this->modified) {
$this->modified = $this->created; $this->modified = $this->created;
} }
// Set modified_by to created_by if not set // Set modified_by to created_by if not set

View File

@ -26,6 +26,42 @@ class PartTable extends Table
$this->setColumnAlias('published', 'state'); $this->setColumnAlias('published', 'state');
} }
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Set created date if not set.
if (!(int) $this->created) {
$this->created = Factory::getDate()->toSql();
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('state') . ' >= 0');
}
// Set modified to created if not set
if (!$this->modified) {
$this->modified = $this->created;
}
// Set modified_by to created_by if not set
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
return true;
}
public function store($updateNulls = true) public function store($updateNulls = true)
{ {
$app = Factory::getApplication(); $app = Factory::getApplication();

View File

@ -26,6 +26,40 @@ class StockTable extends Table
$this->setColumnAlias('published', 'state'); $this->setColumnAlias('published', 'state');
} }
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Set created date if not set.
if (!(int) $this->created) {
$this->created = Factory::getDate()->toSql();
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('state') . ' >= 0');
}
// Set modified to created if not set
if (!$this->modified) {
$this->modified = $this->created;
}
// Set modified_by to created_by if not set
if (empty($this->modified_by)) {
$this->modified_by = $this->created_by;
}
}
public function store($updateNulls = true) public function store($updateNulls = true)
{ {
$app = Factory::getApplication(); $app = Factory::getApplication();

View File

@ -10,10 +10,8 @@
namespace KW4NZ\Component\Depot\Administrator\View\Packages; namespace KW4NZ\Component\Depot\Administrator\View\Packages;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects // phpcs:disable PSR1.Files.SideEffects
@ -37,7 +35,7 @@ class HtmlView extends BaseHtmlView
$this->setLayout('emptystate'); $this->setLayout('emptystate');
} }
// set the toolbar // Set the toolbar
$this->addToolbar(); $this->addToolbar();
parent::display($tpl); parent::display($tpl);

View File

@ -10,15 +10,13 @@
namespace KW4NZ\Component\Depot\Administrator\View\Parts; namespace KW4NZ\Component\Depot\Administrator\View\Parts;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Toolbar\ToolbarHelper;
// use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class HtmlView extends BaseHtmlView class HtmlView extends BaseHtmlView
@ -33,7 +31,11 @@ class HtmlView extends BaseHtmlView
$this->filterForm = $model->getFilterForm(); $this->filterForm = $model->getFilterForm();
$this->activeFilters = $model->getActiveFilters(); $this->activeFilters = $model->getActiveFilters();
// set the toolbar if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}
// Set the toolbar
$this->addToolbar(); $this->addToolbar();
parent::display($tpl); parent::display($tpl);

View File

@ -10,36 +10,33 @@
namespace KW4NZ\Component\Depot\Administrator\View\Stocks; namespace KW4NZ\Component\Depot\Administrator\View\Stocks;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// use Joomla\CMS\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper; use Joomla\CMS\Toolbar\ToolbarHelper;
// use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
class HtmlView extends BaseHtmlView class HtmlView extends BaseHtmlView
{ {
public function display($tpl = null) public function display($tpl = null)
{ {
// Get application /**@var StocksModel $model */
$app = Factory::getApplication(); $model = $this->getModel();
$this->items = $this->get('Items'); $this->items = $model->getItems();
$this->state = $this->get('State'); $this->pagination = $model->getPagination();
// list order $this->state = $model->getState();
$this->listOrder = $this->escape($this->state->get('list.ordering')); $this->filterForm = $model->getFilterForm();
$this->listDirn = $this->escape($this->state->get('list.direction')); $this->activeFilters = $model->getActiveFilters();
// add pagination
$this->pagination = $this->get('Pagination');
// adding filters
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// set the toolbar if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}
// Set the toolbar
$this->addToolbar(); $this->addToolbar();
parent::display($tpl); parent::display($tpl);

View File

@ -84,7 +84,7 @@ use Joomla\CMS\Layout\LayoutHelper;
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php echo $this->pagination->getListFooter(); ?> <?= $this->pagination->getListFooter(); ?>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="task" value=""> <input type="hidden" name="task" value="">

View File

@ -10,9 +10,8 @@
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Session\Session; use Joomla\CMS\Router\Route;
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager(); $wa = $this->document->getWebAssetManager();
@ -44,12 +43,12 @@ if ($saveOrder && !empty($this->items)) {
<?php else: ?> <?php else: ?>
<table class="table table-striped table-hover" id="packageList"> <table class="table table-striped table-hover" id="packageList">
<caption class="visually-hidden"> <caption class="visually-hidden">
<?php echo Text::_('COM_DEPOT_PACKAGES_TABLE_CAPTION'); ?>, <?= Text::_('COM_DEPOT_PACKAGES_TABLE_CAPTION'); ?>,
<span id="orderedBy"> <span id="orderedBy">
<?php echo Text::_('JGLOBAL_SORTED_BY'); ?> <?= Text::_('JGLOBAL_SORTED_BY'); ?>
</span>, </span>,
<span id="filteredBy"> <span id="filteredBy">
<?php echo Text::_('JGLOBAL_FILTERED_BY'); ?> <?= Text::_('JGLOBAL_FILTERED_BY'); ?>
</span> </span>
</caption> </caption>
<thead> <thead>
@ -58,10 +57,10 @@ if ($saveOrder && !empty($this->items)) {
<?= HTMLHelper::_('grid.checkall'); ?> <?= HTMLHelper::_('grid.checkall'); ?>
</td> </td>
<th scope="col" class="w-1 text-center"> <th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', '', 'p.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?> <?= HTMLHelper::_('searchtools.sort', '', 'p.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th> </th>
<th scope="col" class="w-1 text-center"> <th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'p.state', $listDirn, $listOrder); ?> <?= HTMLHelper::_('searchtools.sort', 'JSTATUS', 'p.state', $listDirn, $listOrder); ?>
</th> </th>
<th> <th>
<?= HTMLHelper::_( <?= HTMLHelper::_(
@ -109,7 +108,7 @@ if ($saveOrder && !empty($this->items)) {
$ordering = ($listOrder == 'ordering'); $ordering = ($listOrder == 'ordering');
$canChange = true; $canChange = true;
?> ?>
<tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?php echo $item->id; ?>"> <tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th> <th>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?> <?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</th> </th>
@ -123,11 +122,11 @@ if ($saveOrder && !empty($this->items)) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED'); $iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
} }
?> ?>
<span class="sortable-handler <?php echo $iconClass ?>"> <span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span> <span class="icon-ellipsis-v" aria-hidden="true"></span>
</span> </span>
<?php if ($saveOrder): ?> <?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?php echo $item->ordering; ?>" <input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden"> class="width-20 text-area-order hidden">
<?php endif; ?> <?php endif; ?>
<div class="small"> <div class="small">
@ -135,7 +134,7 @@ if ($saveOrder && !empty($this->items)) {
</div> </div>
</td> </td>
<td class="text-center"> <td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'packages.', $canChange); ?> <?= HTMLHelper::_('jgrid.published', $item->state, $i, 'packages.', $canChange); ?>
</td> </td>
<th> <th>
<a href="<?= Route::_('index.php?option=com_depot&task=package.edit&id=' . <a href="<?= Route::_('index.php?option=com_depot&task=package.edit&id=' .
@ -156,7 +155,7 @@ if ($saveOrder && !empty($this->items)) {
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php echo $this->pagination->getListFooter(); ?> <?= $this->pagination->getListFooter(); ?>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="task" value=""> <input type="hidden" name="task" value="">

View File

@ -32,12 +32,9 @@ $wa->useScript('form.validate')
<?= Text::_('COM_DEPOT_LEGEND_PART_DETAILS') ?> <?= Text::_('COM_DEPOT_LEGEND_PART_DETAILS') ?>
</legend> </legend>
<div class="row"> <div class="row">
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-9">
<?= $this->form->renderFieldset('details'); ?> <?= $this->form->renderFieldset('details'); ?>
</div> </div>
<div class="col-12 col-lg-6">
<?= $this->form->getInput('description'); ?>
</div>
</div> </div>
</fieldset> </fieldset>
<?= HtmlHelper::_('uitab.endTab'); ?> <?= HtmlHelper::_('uitab.endTab'); ?>

View File

@ -39,14 +39,14 @@ if ($saveOrder && !empty($this->items)) {
<?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> <?= Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div> </div>
<?php else: ?> <?php else: ?>
<table class="table table-striped table-hover" id="partsList"> <table class="table table-striped table-hover" id="partList">
<caption class="visually-hidden"> <caption class="visually-hidden">
<?php echo Text::_('COM_BANNERS_CLIENTS_TABLE_CAPTION'); ?>, <?= Text::_('COM_DEPOT_PARTS_TABLE_CAPTION'); ?>,
<span id="orderedBy"> <span id="orderedBy">
<?php echo Text::_('JGLOBAL_SORTED_BY'); ?> <?= Text::_('JGLOBAL_SORTED_BY'); ?>
</span>, </span>,
<span id="filteredBy"> <span id="filteredBy">
<?php echo Text::_('JGLOBAL_FILTERED_BY'); ?> <?= Text::_('JGLOBAL_FILTERED_BY'); ?>
</span> </span>
</caption> </caption>
<thead> <thead>
@ -55,7 +55,10 @@ if ($saveOrder && !empty($this->items)) {
<?= HTMLHelper::_('grid.checkall'); ?> <?= HTMLHelper::_('grid.checkall'); ?>
</td> </td>
<th scope="col" class="w-1 text-center"> <th scope="col" class="w-1 text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'd.state', $listDirn, $listOrder); ?> <?= HTMLHelper::_('searchtools.sort', '', 'd.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
</th>
<th scope="col" class="w-1 text-center">
<?= HTMLHelper::_('searchtools.sort', 'JSTATUS', 'd.state', $listDirn, $listOrder); ?>
</th> </th>
<th scope="col"> <th scope="col">
<?= HTMLHelper::_( <?= HTMLHelper::_(
@ -78,6 +81,15 @@ if ($saveOrder && !empty($this->items)) {
<th> <th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_QUANTITY_EXP') ?> <?= Text::_('COM_DEPOT_TABLE_HEAD_QUANTITY_EXP') ?>
</th> </th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_DESCRIPTION',
'd.description',
$listDirn,
$listOrder
); ?>
</th>
<th> <th>
<?= HTMLHelper::_( <?= HTMLHelper::_(
'searchtools.sort', 'searchtools.sort',
@ -107,14 +119,39 @@ if ($saveOrder && !empty($this->items)) {
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody <?php if ($saveOrder): ?> class="js-draggable" data-url="<?= $saveOrderingUrl; ?>"
<?php foreach ($this->items as $i => $item): ?> data-direction="<?= strtolower($listDirn); ?>" data-nested="true" <?php endif; ?>>
<tr> <?php foreach ($this->items as $i => $item):
<td class="text-center"> $ordering = ($listOrder == 'ordering');
$canChange = true;
?>
<tr class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th>
<?= HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->component_name); ?> <?= HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->component_name); ?>
</th>
<td class="text-center d-none d-md-table-cell">
<?php
$iconClass = '';
if (!$canChange) {
$iconClass = ' inactive';
} elseif (!$saveOrder) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden">
<?php endif; ?>
<div class="small">
<?= $item->ordering; ?>
</div>
</td> </td>
<td class="text-center"> <td class="text-center">
<?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'parts.', $canChange); ?> <?= HTMLHelper::_('jgrid.published', $item->state, $i, 'parts.', $canChange); ?>
</td> </td>
<th> <th>
<div class="break-word"> <div class="break-word">
@ -142,6 +179,11 @@ if ($saveOrder && !empty($this->items)) {
<td> <td>
<?= "10^" . $item->quantity_exp; ?> <?= "10^" . $item->quantity_exp; ?>
</td> </td>
<td>
<div class="break-word">
<?= $this->escape($item->description); ?>
</div>
</td>
<td> <td>
<a href="<?= Route::_('index.php?option=com_depot&task=manufacturer.edit&id=' . <a href="<?= Route::_('index.php?option=com_depot&task=manufacturer.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>"> (int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
@ -164,7 +206,7 @@ if ($saveOrder && !empty($this->items)) {
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php echo $this->pagination->getListFooter(); ?> <?= $this->pagination->getListFooter(); ?>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="task" value=""> <input type="hidden" name="task" value="">

View File

@ -13,6 +13,20 @@ use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route; use Joomla\CMS\Router\Route;
use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Layout\LayoutHelper;
$wa = $this->document->getWebAssetManager();
$wa->useScript('table.columns')
->useScript('multiselect');
$user = $this->getCurrentUser();
$userID = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 's.ordering';
if ($saveOrder && !empty($this->items)) {
$saveOrderingUrl = 'index.php?option=com_depot&task=stocks.saveOrderAjax&tmpl=component';
HTMLHelper::_('draggablelist.draggable');
}
?> ?>
<form action="<?= Route::_('index.php?option=com_depot&view=stocks'); ?>" method="post" name="adminForm" id="adminForm"> <form action="<?= Route::_('index.php?option=com_depot&view=stocks'); ?>" method="post" name="adminForm" id="adminForm">
@ -26,59 +40,86 @@ use Joomla\CMS\Layout\LayoutHelper;
</div> </div>
<?php else: ?> <?php else: ?>
<table class="table table-striped table-hover"> <table class="table table-striped table-hover" id="stockList">
<thead> <thead>
<tr> <tr>
<th> <td>
<?= HTMLHelper::_('grid.checkall'); ?> <?= HTMLHelper::_('grid.checkall'); ?>
</th> </td>
<th> <th scope="col" class="w-1 text-center">
<?= HTMLHelper::_( <?= HTMLHelper::_('searchtools.sort', '', 's.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?>
'searchtools.sort',
'JGRID_HEADING_ID',
's.id',
$this->listDirn,
$this->listOrder
); ?>
</th> </th>
<th> <th>
<?= HTMLHelper::_( <?= HTMLHelper::_(
'searchtools.sort', 'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_STOCK', 'COM_DEPOT_TABLE_HEAD_STOCK',
's.name', 's.name',
$this->listDirn, $listDirn,
$this->listOrder $listOrder
); ?> ); ?>
</th> </th>
<th> <th>
<?= Text::_('COM_DEPOT_TABLE_HEAD_DESCRIPTION') ?> <?= HTMLHelper::_(
'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_DESCRIPTION',
's.description',
$listDirn,
$listOrder
); ?>
</th> </th>
<th> <th>
<?= HTMLHelper::_( <?= HTMLHelper::_(
'searchtools.sort', 'searchtools.sort',
'COM_DEPOT_TABLE_HEAD_OWNER', 'COM_DEPOT_TABLE_HEAD_OWNER',
'owner', 'owner',
$this->listDirn, $listDirn,
$this->listOrder $listOrder
); ?>
</th>
<th>
<?= HTMLHelper::_(
'searchtools.sort',
'JGRID_HEADING_ID',
's.id',
$listDirn,
$listOrder
); ?> ); ?>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody <?php if ($saveOrder): ?> class="js-draggable" data-url="<?= $saveOrderingUrl; ?>"
<?php foreach ($this->items as $i => $item): ?> data-direction="<?= strtolower($listDirn); ?>" data-nested="true" <?php endif; ?> <?php foreach ($this->items as $i => $item):
<tr> $ordering = ($listOrder == 'ordering');
<td> $canChange = true;
?> <tr
class="row<?= $i % 2; ?>" data-draggable-group="0" item-id="<?= $item->id; ?>">
<th>
<?= HTMLHelper::_('grid.id', $i, $item->id); ?> <?= HTMLHelper::_('grid.id', $i, $item->id); ?>
</th>
<td class="text-center d-none d-md-table-cell">
<?php
$iconClass = '';
if (!$canChange) {
$iconClass = ' inactive';
} elseif (!$saveOrder) {
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?= $iconClass ?>">
<span class="icon-ellipsis-v" aria-hidden="true"></span>
</span>
<?php if ($saveOrder): ?>
<input type="text" name="order[]" size="5" value="<?= $item->ordering; ?>"
class="width-20 text-area-order hidden">
<?php endif; ?>
</td> </td>
<td> <th>
<?= $item->id ?>
</td>
<td>
<a href="<?= Route::_('index.php?option=com_depot&task=stock.edit&id=' . <a href="<?= Route::_('index.php?option=com_depot&task=stock.edit&id=' .
(int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>"> (int) $item->id) ?>" title="<?= Text::_('JACTION_EDIT') ?>">
<?= $this->escape($item->name); ?> <?= $this->escape($item->name); ?>
</a> </a>
</td> </th>
<td> <td>
<?= $this->escape($item->description); ?> <?= $this->escape($item->description); ?>
</td> </td>
@ -94,11 +135,14 @@ use Joomla\CMS\Layout\LayoutHelper;
<?php endif; ?> <?php endif; ?>
</div> </div>
</td> </td>
<td>
<?= $item->id ?>
</td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php echo $this->pagination->getListFooter(); ?> <?= $this->pagination->getListFooter(); ?>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="task" value=""> <input type="hidden" name="task" value="">

View File

@ -2,12 +2,12 @@
<extension type="component" method="upgrade"> <extension type="component" method="upgrade">
<name>Depot</name> <name>Depot</name>
<author>KW4NZ</author> <author>KW4NZ</author>
<creationDate>2023-11-02</creationDate> <creationDate>2023-11-18</creationDate>
<copyright>(C) KW4NZ Thomas Kuschel</copyright> <copyright>(C) KW4NZ Thomas Kuschel</copyright>
<license>GPL v2 +; see LICENSE.md</license> <license>GPL v2 +; see LICENSE.md</license>
<authorEmail>thomas@kuschel.at</authorEmail> <authorEmail>thomas@kuschel.at</authorEmail>
<authorUrl>https://kuschel.at</authorUrl> <authorUrl>https://kuschel.at</authorUrl>
<version>0.9.12</version> <version>0.9.13</version>
<description>COM_DEPOT_XML_DESCRIPTION</description> <description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace> <namespace path="src/">KW4NZ\Component\Depot</namespace>
<install> <!-- Runs on install --> <install> <!-- Runs on install -->