ADD fields, field manipulators
This commit is contained in:
@ -1,18 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<field
|
||||
name="component_name"
|
||||
type="text"
|
||||
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
|
||||
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
|
||||
required="true"
|
||||
/>
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
class="readonly"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<fieldset
|
||||
name="details"
|
||||
label="COM_DEPOT_DETAILS"
|
||||
addruleprefix="KW4NZ\Component\Depot\Administrator\Rule"
|
||||
addfieldprefix="KW4NZ\Component\Depot\Administrator\Field"
|
||||
>
|
||||
<field
|
||||
name="component_name"
|
||||
type="text"
|
||||
label="COM_DEPOT_FIELD_COMPONENT_NAME_LABEL"
|
||||
description="COM_DEPOT_FIELD_COMPONENT_NAME_DESC"
|
||||
required="true"
|
||||
autofocus="1"
|
||||
/>
|
||||
<field
|
||||
name="quantity"
|
||||
type="number"
|
||||
label="COM_DEPOT_FIELD_QUANTITY_LABEL"
|
||||
description="COM_DEPOT_FIELD_QUANTITY_DESC"
|
||||
default="0"
|
||||
/>
|
||||
<field
|
||||
name="quantity_exp"
|
||||
type="number"
|
||||
label="COM_DEPOT_FIELD_QUANTITY_EXP_LABEL"
|
||||
description="COM_DEPOT_FIELD_QUANTITY_EXP_DESC"
|
||||
default="0"
|
||||
/>
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
class="readonly"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<field
|
||||
name="alias"
|
||||
type="text"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
hint="COM_DEPOT_FIELD_ALIAS_PLACEHOLDER"
|
||||
size="40"
|
||||
/>
|
||||
<field
|
||||
name="manufacturer_id"
|
||||
type="sql"
|
||||
label="COM_DEPOT_FIELD_SELECT_MANUFACTURER"
|
||||
query="SELECT id, CONCAT( name_short, ' (', name_long, ')') AS title FROM #__depot_manufacturer ORDER BY title"
|
||||
key_field="id"
|
||||
value_field="title"
|
||||
required="true"
|
||||
>
|
||||
<option value="">COM_DEPOT_SELECT_YOUR_OPTION</option>
|
||||
</field>
|
||||
<field
|
||||
name="state"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
default="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="2">JARCHIVED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -5,6 +5,16 @@
|
||||
; @license GNU General Public License version 2 or later; see LICENSE.md
|
||||
; @since 0.0.1
|
||||
;
|
||||
COM_DEPOT_FIELD_ALIAS_PLACEHOLDER="Auto-generate from component 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_LABEL="Component Name"
|
||||
COM_DEPOT_FIELD_QUANTITY_LABEL="Quantity"
|
||||
COM_DEPOT_FIELD_QUANTITY_DESC="Enter here the current number of components"
|
||||
COM_DEPOT_FIELD_QUANTITY_EXP_LABEL="Quantity Exponent"
|
||||
COM_DEPOT_FIELD_QUANTITY_EXP_DESC="Exponent (10^x of the number, usually 0 i.e. 10⁰)"
|
||||
COM_DEPOT_FIELD_SELECT_MANUFACTURER="Manufacturer"
|
||||
COM_DEPOT_LEGEND_DETAILS="Component Details"
|
||||
COM_DEPOT_SELECT_YOUR_OPTION="Select your option"
|
||||
COM_DEPOT_TAB_NEW_PART="New Component"
|
||||
COM_DEPOT_TAB_EDIT_PART="Component Details"
|
||||
COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"
|
||||
|
@ -49,3 +49,33 @@ INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`creat
|
||||
`ordering`,`state`,`manufacturer_id`) VALUES
|
||||
('1N5404','1n5404','diode, rectifier 3A',9,'2023-09-25 15:00:00',1,1,1),
|
||||
('1N4148','1n4148','diode, general purpose',1234,'2023-09-25 15:15:15',2,1,2);
|
||||
|
||||
DROP TABLE IF EXISTS `#__depot_manufacturer`;
|
||||
CREATE TABLE `#__depot_manufacturer` (
|
||||
`id` SERIAL,
|
||||
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
|
||||
COMMENT 'unique manufacturer name or abbriviation',
|
||||
`name_long` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`url` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`checked_out` INT(11) NOT NULL DEFAULT 0,
|
||||
`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_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`description` VARCHAR(4000) NOT NULL DEFAULT '',
|
||||
`state` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
`image` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`access` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_short` (`name_short`)
|
||||
) ENGINE=InnoDB
|
||||
AUTO_INCREMENT=0
|
||||
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
|
||||
`description`, `image`) VALUES
|
||||
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
|
||||
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''),
|
||||
('ST','STMicroelectronics','https://www.st.com',
|
||||
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','');
|
||||
|
35
admin/sql/updates/mysql/0.0.5.sql
Normal file
35
admin/sql/updates/mysql/0.0.5.sql
Normal file
@ -0,0 +1,35 @@
|
||||
-- @package Depot.SQL MariaDB -- UPDATE to 0.0.5
|
||||
-- @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.5
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__depot_manufacturer` (
|
||||
`id` SERIAL,
|
||||
`name_short` CHAR(25) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
|
||||
COMMENT 'unique manufacturer name or abbriviation',
|
||||
`name_long` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`url` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`checked_out` INT(11) NOT NULL DEFAULT 0,
|
||||
`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_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`description` VARCHAR(4000) NOT NULL DEFAULT '',
|
||||
`state` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
`image` VARCHAR(1024) NOT NULL DEFAULT '',
|
||||
`access` TINYINT(4) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_short` (`name_short`)
|
||||
) ENGINE=InnoDB
|
||||
AUTO_INCREMENT=0
|
||||
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT INTO `#__depot_manufacturer` (`name_short`, `name_long`, `url`,
|
||||
`description`, `image`) VALUES
|
||||
('TSC','Taiwan Semiconductor','https://www.taiwansemi.com',
|
||||
'Diodes, ECAD Models, ICs, MOSFETs, Protection Devices, AEC-Q qualified',''),
|
||||
('ST','STMicroelectronics','https://www.st.com',
|
||||
'Microprocessors, Audio ICs, OPamps, Diodes, Memories, MEMS, NFCs, Transistors, Wireless, Automotive electronics, etc.','');
|
@ -10,6 +10,7 @@
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
|
||||
@ -39,4 +40,25 @@ class PartModel extends AdminModel
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function save($data)
|
||||
{
|
||||
/* Add code to modify data before saving */
|
||||
|
||||
// if (Factory::getConfig()->get('unicodeslugs') == 1) {
|
||||
// $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['component_name']);
|
||||
// } else {
|
||||
// $data['alias'] = OutputFilter::stringURLSafe($data['component_name']);
|
||||
// }
|
||||
|
||||
/* replaced by: */
|
||||
if (empty($data['alias'])) {
|
||||
$data['alias'] = ApplicationHelper::stringURLSafe($data['component_name']);
|
||||
}
|
||||
$result = parent::save($data);
|
||||
// if ($result) {
|
||||
// $this->getTable('', 'Administrator')->rebuild(1);
|
||||
// }
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
* @since 0.0.3
|
||||
*/
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
||||
@ -19,9 +20,35 @@ $wa->useScript('form.validate')
|
||||
<form action="<?= Route::_('index.php?option=com_depot&view=part&layout=edit&id=' . (int) $this->item->id); ?>"
|
||||
method="post" name="adminForm" id="item-form" class="form-validate">
|
||||
|
||||
<?= $this->form->renderField('component_name'); ?>
|
||||
<?= $this->form->renderField('id'); ?>
|
||||
|
||||
<div class="form-horizontal">
|
||||
<?= HtmlHelper::_(
|
||||
'bootstrap.startTabSet',
|
||||
'myTab',
|
||||
['active' => 'details']
|
||||
); ?>
|
||||
<?= HTMLHelper::_(
|
||||
'bootstrap.addTab',
|
||||
'myTab',
|
||||
'details',
|
||||
empty($this->item->id) ? Text::_('COM_DEPOT_TAB_NEW_PART') :
|
||||
Text::_('COM_DEPOT_TAB_EDIT_PART')
|
||||
); ?>
|
||||
<fieldset class="adminform">
|
||||
<legend>
|
||||
<?= Text::_('COM_DEPOT_LEGEND_DETAILS') ?>
|
||||
</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-3">
|
||||
<?= $this->form->renderFieldset('details'); ?>
|
||||
</div>
|
||||
<div class="col-12 col-lg-9">
|
||||
<?= $this->form->getInput('description'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?= HtmlHelper::_('bootstrap.endTab'); ?>
|
||||
<?= HtmlHelper::_('bootstrap.endTabSet'); ?>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="part.edit" />
|
||||
<?= HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
Reference in New Issue
Block a user