Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviMenezes committed May 2, 2018
1 parent 5637ec0 commit 426a133
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 3 deletions.
21 changes: 21 additions & 0 deletions app/control/contato/CityForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Control\Contato;

use App\Model\Contato\City;
use Dvi\Adianti\Control\DviSearchFormList;

/**
* Contato CityForm
*
* @package Contato
* @subpackage Dvi
* @author Davi Menezes
* @copyright Copyright (c) 2018. ([email protected])
* @link https://github.com/DaviMenezes
*/
class CityForm extends DviSearchFormList
{
protected $objectClass = City::class;
protected $pageTitle = 'Cidades';
}
28 changes: 28 additions & 0 deletions app/control/contato/ContatoForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Control\Contato;

use App\Model\Contato\Contato;
use Dvi\Adianti\Control\DviStandardForm;

/**
* Contato ContatoForm
*
* @package Contato
* @subpackage Dvi
* @author Davi Menezes
* @copyright Copyright (c) 2018. ([email protected])
* @link https://github.com/DaviMenezes
*/
class ContatoForm extends DviStandardForm
{
protected $objectClass = Contato::class;
protected $pageTitle = 'Contato';

protected function createActions()
{
parent::createActions();

$this->panel->addCustomActionLink([ContatoList::class], 'fa:bars', 'Listagem');
}
}
40 changes: 40 additions & 0 deletions app/control/contato/ContatoList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Control\Contato;

use Adianti\Base\Lib\Control\TAction;
use Adianti\Base\Lib\Widget\Datagrid\TDataGridAction;
use App\Model\Contato\Contato;
use Dvi\Adianti\Control\DviSearchList;
use Dvi\Adianti\Widget\Base\DGridColumn;
use Dvi\Adianti\Widget\Form\DEntry;

/**
* Contato ContatoList
*
* @package Contato
* @subpackage Dvi
* @author Davi Menezes
* @copyright Copyright (c) 2018. ([email protected])
* @link https://github.com/DaviMenezes
*/
class ContatoList extends DviSearchList
{
protected $objectClass = Contato::class;
protected $pageTitle = 'Contatos';

protected function mountModelFields()
{
$name = new DEntry('Entity_name', 'nome', 150);
$this->panel->addRow([new DGridColumn($name)]);
}

protected function createDatagridColumns($showId = false)
{
$this->datagrid->useDeleteAction(self::class);

parent::createDatagridColumns($showId);

$this->datagrid->useEditAction(ContatoForm::class);
}
}
29 changes: 29 additions & 0 deletions app/model/contato/City.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Model\Contato;

use Dvi\Adianti\Model\DviModel;

/**
* Contato City
*
* @package Contato
* @subpackage Dvi
* @author Davi Menezes
* @copyright Copyright (c) 2018. ([email protected])
* @link https://github.com/DaviMenezes
*/
class City extends DviModel
{
const TABLENAME = 'ctt_city';

public function buildFieldTypes()
{
$this->addVarchar('name', 150, true, 'nome');
}

protected function buildStructureForm()
{
parent::setStructureForm([[$this->field_name]]);
}
}
39 changes: 39 additions & 0 deletions app/model/contato/Contato.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Model\Contato;

use Dvi\Adianti\Model\DviModel;

/**
* Contato Contato
*
* @package Contato
* @subpackage Dvi
* @author Davi Menezes
* @copyright Copyright (c) 2018. ([email protected])
* @link https://github.com/DaviMenezes
*/
class Contato extends DviModel
{
const TABLENAME = 'ctt_contact';

public function buildFieldTypes()
{
$this->addVarchar('name', 150, true, 'nome');
$this->addVarchar('cpf', 14)->mask('999.999.999-99');
$this->addVarchar('rg', 12);
$this->addDate('birthday', 'data de nascimento');
$this->addText('observation', 0, 80, false, 'observações');
$this->addCombo('city_id', 'cidade')->model(City::class);
}

protected function buildStructureForm()
{
$form_structure = [
[$this->field_name],
[$this->field_cpf, $this->field_rg, $this->field_birthday, $this->field_city_id],
[$this->field_observation]
];
parent::setStructureForm($form_structure);
}
}
10 changes: 7 additions & 3 deletions menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@
</menu>
</menuitem>

<menuitem label="Formulários">
<menuitem label="Exemplos">
<icon>fa:bars fa-fw</icon>
<menu>
<menuitem label="Form1">
<action>HumanForm</action>
<menuitem label="Contato">
<action>ContatoForm</action>
<icon>fa:bars fa-fw</icon>
</menuitem>
<menuitem label="Cidade">
<action>CityForm</action>
<icon>fa:bars fa-fw</icon>
</menuitem>
</menu>
Expand Down

0 comments on commit 426a133

Please sign in to comment.