22 Commits

Author SHA1 Message Date
9db4ad808b CHG description and label 2023-10-06 17:42:37 +02:00
df22394e33 ADD details in documentation for DepotComponent 2023-10-06 05:22:40 +02:00
2b5e287a78 DEL unnecessary code 2023-10-06 04:47:51 +02:00
7f79667409 CHG component_name and its label, description 2023-10-06 04:46:37 +02:00
a3787d1965 typo in .editorconfig 2023-10-06 04:38:41 +02:00
6928ff5a74 Fix syntax error, unexpected token "(" 2023-10-05 14:56:39 +02:00
e30b2c6550 Fix header of file 2023-10-05 14:51:28 +02:00
4786bf13d9 reduce forms/part.xml 2023-10-05 14:48:35 +02:00
d9220cd888 FIX typo form(s)! 2023-10-05 14:36:41 +02:00
70e987b338 part.xml was in wrong folder, must be "admin/forms" 2023-10-05 14:34:11 +02:00
47796a6ada try to get it work 2023-10-05 11:45:44 +02:00
f85556f466 try to get it compile 2023-10-05 11:45:29 +02:00
5f1db1b0f5 Echo instead of the short php form 2023-10-05 03:26:48 +02:00
eebafe0241 ADD PartTable, several typos 2023-10-05 03:06:49 +02:00
336eb346a7 remove old style array() 2023-10-05 02:43:12 +02:00
f0b8e1ed02 ADD MVC for part 2023-10-05 02:28:17 +02:00
35c19b24e3 FIX typo in Menu Stocks 2023-10-04 21:00:04 +02:00
618a995a94 CHG SQL style for creating the table 2023-10-04 20:55:41 +02:00
d9dcfeea3a ADD the update 0.0.2.sql 2023-10-04 19:12:52 +02:00
4e75af67ed ADD database tables b_2 2023-10-04 18:06:13 +02:00
f9004e46cb Add .editorconfig file to get right representation in gitea editor and view 2023-10-03 12:55:24 +02:00
22e7f13228 MVCComponent already extended by Extension\DepotComponent 2023-10-03 11:09:44 +02:00
17 changed files with 616 additions and 36 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# Top-most EditorConfig file
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = UTF-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

327
README.md
View File

@ -36,6 +36,17 @@ Add the following basic six files:
##### 1. DepotComponent.php ##### 1. DepotComponent.php
This file contains class for the extension. The class extends MVCComponent. This file contains class for the extension. The class extends MVCComponent.
Compare this version with the original at [Tech Fry Tutorium](https://www.techfry.com/joomla/adding-basic-files-for-component).
```php
namespace KW4NZ\Component\Depot\Administrator\Extension;
use Joomla\CMS\Extension\MVCComponent;
class DepotComponent extends MVCComponent
{
}
```
##### 2. provider.php ##### 2. provider.php
This is a special file that tells Joomla how to initialize the component - which This is a special file that tells Joomla how to initialize the component - which
@ -112,3 +123,319 @@ the directory /admin/language/en-GB/ naming it
- com_depot.sys.ini - com_depot.sys.ini
--- ---
### Creating and managing Joomla database (b2_database)
With the new git branch **b2_database** we continue our workflow.
Joomla usually manage its content with a database. In our component, we use
a MariaDB database. At the time of development of this component we have PHP8.2,
and we use Mariadb database with version from 11.1,
client 15.2 for Linux (x86_64) using readline 5.1
We support MySQL and MariaDB; not tested support for PostgreSQL.
In the manifest file \<component_name\>.xml, here the file **depot.xml**,
there are installation instructions to "install", "uninstall", and
"update" the Joomla extension/component.
The SQL plain text files are stored in and as:
- admin/sql/
- install.mysql.utf8.sql
- uninstall.mysql.utf8.sql
- admin/sql/updates/mysql/
- 0.0.1.sql
- 0.0.4.sql
- 0.0.5.sql
#### Database table installation
1. When the component is installed for the first time, the file
**install.mysql.utf8.sql** is executed.
1. If the component is already installed, the update
scenario comes into play, the folder **admin/sql/updates/mysql/**: Only the files with higher version
numbers than the installed version of the component will be
executed in ascending order.<br>
Hint: The version of the installed component is stored in the
Joomla's table "#__schemas".
The "#__"-prefix is substituted automatically with the database prefix, (e.g. "jm_") which is defined in the configuration file (configuration.php) of the installed Joomla version as parameter $dbprefix.
**install.mysql.utf8.sql**
```sql
DROP TABLE IF EXISTS `#__depot`;
CREATE TABLE `#__depot`(
`id` SERIAL,
`component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique component name (ASCII characters only)',
`alias` VARCHAR(1024) NOT NULL DEFAULT '',
`description` VARCHAR(4000) NOT NULL DEFAULT '',
`quantity` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`quantity_exp` INT(11) NOT NULL DEFAULT 0
COMMENT 'Exponent of the quantity (10^x of the number, usually 0 i.e. 10⁰)',
`asset_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`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,
`path` VARCHAR(400) NOT NULL DEFAULT '',
`state` TINYINT(4) NOT NULL DEFAULT 0
COMMENT 'Published=1,Unpublished=0,Archived=2,Trashed=-2',
`access` TINYINT(4) NOT NULL DEFAULT 0,
`params` 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,
-- references to other tables:
`category_id` INT(11) NOT NULL DEFAULT 0,
`datasheet_id` INT(11) NOT NULL DEFAULT 0,
`datasheet_alt` VARCHAR(1024) NOT NULL DEFAULT '',
`manufacturer_id` INT(11) NOT NULL DEFAULT 0,
`stock_id` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_state` (`state`),
KEY `idx_stock_id` (`stock_id`),
KEY `idx_manufacturer` (`manufacturer_id`),
UNIQUE KEY `aliasindex` (`alias`,`manufacturer_id`,`stock_id`)
) ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`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);
```
The table is created in the database when the component is installed.
Also two lines of sample data are inserted into the table "#__depot".
#### Database table uninstallation
When the component is uninstalled the
**uninstall.mysql.utf8 sql** is executed.
We drop the used tables from the database.
**install.mysql.utf8.sql**
```sql
DROP TABLE IF EXISTS `#__depot`;
```
#### Database table update
When the component is updated the
**admin/sql/updates/mysql** folder with its files is executed.
Even if you do not need a database update, you can add an empty file in admin/sql/updates/mysql/0.0.2.sql to initialize the schema version.
In future versions, if you plan to use database tables, the update can be performed automatically.
We create an empty file, just with a comment "-- version 0.0.2"
**admin/sql/updates/mysql/0.0.2.sql**
```sql
-- version 0.0.2
```
#### Manifest file for extensions
The sql files are only executed if they exist in the \<component_name\>.xml manifest file. We add this after the namespace tag, just before the files information tag:
```php
<install> <!-- Runs on install -->
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
<uninstall> <!-- Runs on uninstall -->
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
```
The **\<version\> tag** of the manifest must be updated to 0.0.2 and
also add the sql folder in the administration files section.
#### Table class
**src/table/DepotTable.php**
For each database table, you have to define a table class. The model
asks the table to get information or perform database operations.
This table class has to be defined in admin/src/Table/DepotTable.php file.
```php
<?php
namespace KW4NZ\Component\Depot\Administrator\Table;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
\defined('_JEXEC') or die;
class DepotTable extends Table
{
function __contruct(DatabaseDriver $db)
{
parent::__contruct('#__depot', 'id', $db);
}
}
```
Joomla uses the **Table Object** to get item or record, insert records,
update or delete records for the database operations.
Methods in the table objects are:
1. **load()** to load the existing record from the database, passing
the primary key of the record.
1. **bind()** to set the new values for the fields.
1. **check()** to perform any validation.
1. **store()** to save the new values to the database.
1. **delete()** to delete the record from the database.
---
### Get a Form in Joomla component
The **Form** class of Joomla is used to create complex forms with flexible
layouts and dynamic properties. First, the form fields are defined in the
XML file. Then the view file gets the form from the model and layout file
displays the form.
#### XML Form file
**admin/forms/part.xml**
```xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
required="true"
/>
</form>
```
Similarly you can add other fields to the XML file.
#### View file
**admin/src/View/Part/HtmlView.php**
This file is similar to the view file added earlier for the "Parts" view.
The view file gets the form from the model in the display() method.
```php
<?php
namespace KW4NZ\Component\Depot\Administrator\View\Part;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
\defined('_JEDEC') or die;
class HtmlView extends BaseHtmlView
{
protected $form;
protected $item;
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
parent::display($tpl);
}
}
```
The code will look for the method **getForm()**
and **getItem()** in the model file.
We need to get the item to get the ID
of the record in case of editing the existing record.
#### Model file
**admin/src/Model/PartModel.php**
We need to extend the model class with the **AdminModel**.
The AdminModel class extends FormModel class. The **getForm()**
method gets the Form object for the edit form.
```php
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\AdminModel;
\defined('_JEXEC') or die;
class PartModel extends AdminModel
{
public function getForm($data = array(), $loadData = true)
{
$form = $this->loadForm('com_depot.part',
'part', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
}
```
The **loadForm()** and **preprocessForm()** methods are defined in
the FromModel class and the **bind()** method is defined in the
Form class. The first argument (name) of loadForm() is set to
"com_depot.part". The second argument (form xml source) is "part",
and the third argument is the associative array for options.
The form is defined in the source file: **forms/part.xml**
After you have set the $form variable with the Form object,
you check to see if you are loading data to the form.
If you want to pre-load data for the form, you include an element
called "load_data" that is set to a boolean true.
Then, the method calls the loadFormData() method to get the data
for the form. This method gets any previously loaded data from
the session or database.
###### Modifying Form dynamically
Inside the getForm() method, before returning the $form, you can modify the form with many methods of the Form class. You can easily fine-tune your forms dynamically before they are rendered.
#### Layout file - rendering Form
**tmpl/part/edit.php**
After you get the form in the view file ($this->form), the form
is rendered in the layout file (edit.php).
```php
<?php
use Joomla\CMS\HTML\HTMLHelper;
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive');
$wa->useScript('form.validate');
?>
<form action="<?= Route::_('index.php?option=com_depot&layout=edit&id=' .
(int) $this->item->id); ?>"
method="post" name="adminForm" id="item-form" class="form-validate">
<?= $this->form->renderField('title'); ?>
<input type="hidden" name="task" value="part.edit" />
<?= HTMLHelper::_('form.token'); ?>
</form>
```
The form validate script is required to submit the for. The renderField() method
of the Form class displays the field - both label and input.
We can access the form using following URL:
```php
administrator/index.php?option=com_depot&view=part&layout=edit
```
It displays edit.php layout file of the Part View. When the form is submitted, the
data is sent to the controller depending upon the action buttons in the toolbar.
Please remember to add the additional folder `form` to the Manifest file "depot.xml", i.e.
just a line before `<folder>services</folder>` :
```xml
<folder>form</folder>
```
---

18
admin/forms/part.xml Normal file
View File

@ -0,0 +1,18 @@
<?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"
/>
</form>

View File

@ -5,4 +5,6 @@
; @license GNU General Public License version 2 or later; see LICENSE.md ; @license GNU General Public License version 2 or later; see LICENSE.md
; @since 0.0.1 ; @since 0.0.1
; ;
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_XML_DESCRIPTION="Depot, the component warehouse" COM_DEPOT_XML_DESCRIPTION="Depot, the component warehouse"

View File

@ -16,7 +16,6 @@ use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\DI\Container; use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface; use Joomla\DI\ServiceProviderInterface;
use KW4NZ\Component\Depot\Administrator\Extension\DepotComponent; use KW4NZ\Component\Depot\Administrator\Extension\DepotComponent;
use Joomla\CMS\Extension\MVCComponent;
return new class implements ServiceProviderInterface return new class implements ServiceProviderInterface
{ {

View File

@ -3,17 +3,18 @@
-- @author Thomas Kuschel <thomas@kuschel.at> -- @author Thomas Kuschel <thomas@kuschel.at>
-- @copyright (C) 2023 KW4NZ, <https://www.kuschel.at> -- @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
-- @license GNU General Public License version 2 or later; see LICENSE.md -- @license GNU General Public License version 2 or later; see LICENSE.md
-- @since 0.0.1 -- @since 0.0.2
DROP TABLE IF EXISTS `#__depot`; DROP TABLE IF EXISTS `#__depot`;
CREATE TABLE `#__depot`( CREATE TABLE `#__depot` (
`id` SERIAL, `id` SERIAL,
`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 '',
`description` VARCHAR(4000) NOT NULL DEFAULT '', `description` VARCHAR(4000) NOT NULL DEFAULT '',
`quantity` INT(10) UNSIGNED NOT NULL DEFAULT 0, `quantity` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`quantity_exp` INT(11) NOT NULL DEFAULT 0 COMMENT 'Exponent of the quantity (10^x of the number, usually 0 i.e. 10⁰)', `quantity_exp` INT(11) NOT NULL DEFAULT 0
COMMENT 'Exponent of the quantity (10^x of the number, usually 0 i.e. 10⁰)',
`asset_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', `asset_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0, `created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
@ -22,7 +23,8 @@ CREATE TABLE `#__depot`(
`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,
`path` VARCHAR(400) NOT NULL DEFAULT '', `path` VARCHAR(400) NOT NULL DEFAULT '',
`state` TINYINT(4) NOT NULL DEFAULT 0 COMMENT 'Published=1,Unpublished=0,Archived=2,Trashed=-2', `state` TINYINT(4) NOT NULL DEFAULT 0
COMMENT 'Published=1,Unpublished=0,Archived=2,Trashed=-2',
`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 '',

View File

@ -3,6 +3,6 @@
-- @author Thomas Kuschel <thomas@kuschel.at> -- @author Thomas Kuschel <thomas@kuschel.at>
-- @copyright (C) 2023 KW4NZ, <https://www.kuschel.at> -- @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
-- @license GNU General Public License version 2 or later; see LICENSE.md -- @license GNU General Public License version 2 or later; see LICENSE.md
-- @since 0.0.1 -- @since 0.0.2
DROP TABLE IF EXISTS `#__depot`; DROP TABLE IF EXISTS `#__depot`;

View File

@ -0,0 +1,8 @@
-- @package Depot.SQL MariaDB -- UPDATE to 0.0.1
-- @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.2
-- dummy

View File

@ -0,0 +1,50 @@
-- @package Depot.SQL MariaDB -- UPDATE to 0.0.2
-- @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.2
CREATE TABLE IF NOT EXISTS `#__depot` (
`id` SERIAL,
`component_name` VARCHAR(1024) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL
COMMENT 'unique component name (ASCII characters only)',
`alias` VARCHAR(1024) NOT NULL DEFAULT '',
`description` VARCHAR(4000) NOT NULL DEFAULT '',
`quantity` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`quantity_exp` INT(11) NOT NULL DEFAULT 0
COMMENT 'Exponent of the quantity (10^x of the number, usually 0 i.e. 10⁰)',
`asset_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
`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,
`path` VARCHAR(400) NOT NULL DEFAULT '',
`state` TINYINT(4) NOT NULL DEFAULT 0
COMMENT 'Published=1,Unpublished=0,Archived=2,Trashed=-2',
`access` TINYINT(4) NOT NULL DEFAULT 0,
`params` 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,
-- references to other tables:
`category_id` INT(11) NOT NULL DEFAULT 0,
`datasheet_id` INT(11) NOT NULL DEFAULT 0,
`datasheet_alt` VARCHAR(1024) NOT NULL DEFAULT '',
`manufacturer_id` INT(11) NOT NULL DEFAULT 0,
`stock_id` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `idx_state` (`state`),
KEY `idx_stock_id` (`stock_id`),
KEY `idx_manufacturer` (`manufacturer_id`),
UNIQUE KEY `aliasindex` (`alias`,`manufacturer_id`,`stock_id`)
) ENGINE=InnoDB
AUTO_INCREMENT=0
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `#__depot` (`component_name`,`alias`,`description`,`quantity`,`created`,
`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);

View File

@ -17,4 +17,4 @@ use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController class DisplayController extends BaseController
{ {
protected $default_view = 'parts'; protected $default_view = 'parts';
} }

View File

@ -14,5 +14,4 @@ use Joomla\CMS\Extension\MVCComponent;
class DepotComponent extends MVCComponent class DepotComponent extends MVCComponent
{ {
}
}

View File

@ -0,0 +1,29 @@
<?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.3
*/
namespace KW4NZ\Component\Depot\Administrator\Model;
use Joomla\CMS\MVC\Model\AdminModel;
\defined('_JEXEC') or die;
class PartModel extends AdminModel
{
public function getForm($data = [], $loadData = true)
{
$form = $this->loadForm('com_depot.part', 'part', ['control' => 'jform', 'load_data' => $loadData]);
if (empty($form)) {
return false;
}
return $form;
}
}

View File

@ -0,0 +1,24 @@
<?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.2
*/
namespace KW4NZ\Component\Depot\Administrator\Table;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
\defined('_JEXEC') or die;
class PartTable extends Table
{
function __construct(DatabaseDriver $db)
{
parent::__construct('#__depot', 'id', $db);
}
}

View File

@ -0,0 +1,60 @@
<?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.3
*/
namespace KW4NZ\Component\Depot\Administrator\View\Part;
defined('_JEXEC') or die;
// use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
/**
* View to edit an article.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @throws \Exception
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
// if (count($errors = $this->get('Errors'))) {
// throw new GenericDataException(implode("\n", $errors), 500);
// }
return parent::display($tpl);
}
}

26
admin/tmpl/part/edit.php Normal file
View File

@ -0,0 +1,26 @@
<?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.3
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('form.validate')
->useScript('keepalive');
?>
<form action="<?php echo 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">
<?php echo $this->form->renderField('component_name'); ?>
<input type="hidden" name="task" value="part.edit" />
<?php echo HTMLHelper::_('form.token'); ?>
</form>

View File

@ -9,3 +9,5 @@
*/ */
?> ?>
<h2>Welcome to my Depot Component!</h2> <h2>Welcome to my Depot Component!</h2>
<p>Link: <a href="index.php?option=com_depot&view=part&layout=edit">Part</a></p>

View File

@ -2,39 +2,14 @@
<extension type="component" method="upgrade"> <extension type="component" method="upgrade">
<name>Depot</name> <name>Depot</name>
<author>KW4NZ</author> <author>KW4NZ</author>
<creationDate>2023-10-02</creationDate> <creationDate>2023-10-06</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.0.1</version> <version>0.0.3</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>
<files folder="site/">
<file>CODING_STANDARDS.md</file>
<file>LICENSE.md</file>
<file>README.md</file>
</files>
<administration>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu>COM_DEPOT_MENU</menu>
<submenu>
<menu link="option=com_depot">COM_DEPOT_MENU</menu>
</submenu>
<files folder="admin">
<folder>services</folder>
<folder>sql</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages folder="admin/language">
<language tag="en-GB">en-GB/com_depot.ini</language>
<language tag="en-GB">en-GB/com_depot.sys.ini</language>
</languages>
</administration>
<install> <!-- Runs on install --> <install> <!-- Runs on install -->
<sql> <sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file> <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
@ -45,4 +20,50 @@
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file> <file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql> </sql>
</uninstall> </uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas>
</update>
<files folder="site/">
<file>CODING_STANDARDS.md</file>
<file>LICENSE.md</file>
<file>README.md</file>
</files>
<administration>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu img="class:barcode">COM_DEPOT_MENU</menu>
<submenu>
<menu
link="option=com_depot"
view="parts"
img="class:depot"
alt="Depot/Parts"
>
COM_DEPOT_MENU
</menu>
<menu
link="option=com_depot"
view="stocks"
img="class:depot-stocks"
alt="Depot/Stocks"
>
COM_DEPOT_MENU_STOCKS
</menu>
</submenu>
<files folder="admin">
<folder>forms</folder>
<folder>services</folder>
<folder>sql</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages folder="admin/language">
<language tag="en-GB">en-GB/com_depot.ini</language>
<language tag="en-GB">en-GB/com_depot.sys.ini</language>
</languages>
</administration>
</extension> </extension>