-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Fohn-Group/update-atk-data
Table Filtering / Sizing
- Loading branch information
Showing
95 changed files
with
3,898 additions
and
1,517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
'build', | ||
'vendor', | ||
'js', | ||
'app-test/_app-data', | ||
]); | ||
|
||
return (new PhpCsFixer\Config()) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* Employees. | ||
*/ | ||
|
||
namespace Fohn\Ui\AppTest\Model; | ||
|
||
use Atk4\Data\Model; | ||
use Fohn\Ui\Component\Table\Column\Currency; | ||
use Fohn\Ui\Component\Table\Column\Date; | ||
use Fohn\Ui\Component\Table\Column\Generic; | ||
use Fohn\Ui\Component\Table\Filter\Number; | ||
use Fohn\Ui\Component\Table\Filter\Text; | ||
use Fohn\Ui\Service\Ui; | ||
|
||
class Employees extends Model | ||
{ | ||
public $table = 'employees'; | ||
|
||
// public ?string $titleField = 'first_name'; | ||
|
||
protected function init(): void | ||
{ | ||
parent::init(); | ||
$this->addExpression('name', ['expr' => 'concat(last_name, ", ", first_name)']); | ||
$this->addField('first_name', ['caption' => 'First Name', 'type' => 'string']); | ||
$this->addField('last_name', ['caption' => 'Last Name', 'type' => 'string']); | ||
$this->addField('email', ['caption' => 'Email', 'type' => 'string']); | ||
$this->addField('title', ['caption' => 'Title', 'type' => 'string']); | ||
$this->addField('city', ['caption' => 'City', 'type' => 'string']); | ||
$this->addField('state', ['caption' => 'State', 'type' => 'string']); | ||
$this->addField('country', ['caption' => 'Country', 'type' => 'string']); | ||
$this->addField('birth_date', ['caption' => 'Birthdate', 'type' => 'date']); | ||
$this->addField('salary', ['caption' => 'Gender', 'type' => 'atk4_money']); | ||
} | ||
|
||
public function getTableColumns(): array | ||
{ | ||
return [ | ||
'name' => Generic::factory(['isSortable' => true]), | ||
'title' => Generic::factory(['isSortable' => true]), | ||
'city' => Generic::factory(['isSortable' => true]), | ||
'state' => Generic::factory(['isSortable' => true]), | ||
'birth_date' => Date::factory(['isSortable' => true, 'caption' => 'Birthdate', 'format' => Ui::getDisplayFormat('date')]), | ||
'salary' => Currency::factory(['isSortable' => true]), | ||
]; | ||
} | ||
|
||
public function getTableFilters(): array | ||
{ | ||
return [ | ||
new Text('name'), | ||
new Text('first_name', 'First Name'), | ||
new Text('last_name', 'Last Name'), | ||
new \Fohn\Ui\Component\Table\Filter\Date('birth_date', Ui::getDisplayFormat('date'), 'Birthdate'), | ||
new Number('salary', 'Salary'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Fohn\Ui\AppTest; | ||
|
||
use Fohn\Ui\AppTest\Model\Employees; | ||
use Fohn\Ui\Component\Table; | ||
use Fohn\Ui\Js\JsStatements; | ||
use Fohn\Ui\Js\JsToast; | ||
use Fohn\Ui\Service\Data; | ||
use Fohn\Ui\Service\Ui; | ||
use Fohn\Ui\Tailwind\Tw; | ||
use Fohn\Ui\View\Button; | ||
|
||
require_once __DIR__ . '/../init-ui.php'; | ||
|
||
$modelCtrl = Data::tableModelCtrl(new Employees(Data::db())); | ||
$modelCtrl->setSearchFields(['firt_name', 'last_name']); | ||
|
||
$table = Table::addTo(Ui::layout(), ['keepSelectionAcrossPage' => true]); | ||
$table->setCaption(AppTest::tableCaptionFactory('Employees')); | ||
$table->getTableTw()->merge([Tw::textSize('sm')]); | ||
|
||
// Multiple process action | ||
$actionProcess = (new Table\Action(['keepSelection' => true]))->setTrigger(Button::factory(['label' => 'Process', 'color' => 'neutral'])); | ||
$table->addRowsAction($actionProcess)->onTrigger(static function ($ids) { | ||
$count = count($ids); | ||
|
||
return JsStatements::with([JsToast::success("Process Action on {$count} employee(s)")]); | ||
}); | ||
|
||
// @phpstan-ignore-next-line | ||
$table->addColumns($modelCtrl->getModel()->getTableColumns()); | ||
// @phpstan-ignore-next-line | ||
$table->filterColumns($modelCtrl->getModel()->getTableFilters()); | ||
|
||
$table->onDataRequest(static function (Table\Payload $payload, Table\Result\Set $result) use ($modelCtrl): void { | ||
$modelCtrl->setTableResultSet($payload, $result); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.