-
Notifications
You must be signed in to change notification settings - Fork 111
Using flag decorator in card table #1756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ddac8c8
Adds Table\Column\Flag decorator
DarkSide666 1dbeacc
fix style
DarkSide666 02a86d2
remove useless ternary
DarkSide666 98a9918
Adding test what fails - see in demos/collection/test.php
DarkSide666 65415d8
fix cs/stan & simplify code
mvorisek 3709c3c
remove other unsafe hasField uses in atk4/ui
mvorisek e046779
POC of value /w entity link
mvorisek 0159693
Update grid.php
DarkSide666 3aef068
Update test.php
DarkSide666 190002f
Update Flag.php
DarkSide666 962b61b
Merge branch 'develop' into feature/flag-decorator
DarkSide666 e474216
fixes
DarkSide666 9e5f515
Merge branch 'develop'
mvorisek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,29 @@ | ||
| <?php | ||
| /* TODO - merge this into /demos/interactive/cardtable.php */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Atk4\Ui\Demos; | ||
|
|
||
| use Atk4\Ui\CardTable; | ||
| use Atk4\Ui\Table; | ||
|
|
||
| /** @var \Atk4\Ui\App $app */ | ||
| require_once __DIR__ . '/../init-app.php'; | ||
|
|
||
| $m = new Country($app->db); | ||
| $m->addField('flag', [ | ||
| 'neverPersist' => true, // no need for actual value in this field | ||
| 'ui' => [ | ||
| 'table' => [ | ||
| Table\Column\Flag::class, | ||
| [ | ||
| 'codeField' => $m->fieldName()->iso, | ||
| 'nameField' => $m->fieldName()->name, | ||
| ], | ||
| ], | ||
| ], | ||
| ]); | ||
|
|
||
| $e = $m->loadAny(); | ||
| $t = CardTable::addTo($app); | ||
| $t->setModel($e); |
This file contains hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Atk4\Ui\Table\Column; | ||
|
|
||
| use Atk4\Data\Field; | ||
| use Atk4\Data\Model; | ||
| use Atk4\Ui\Table; | ||
|
|
||
| /** | ||
| * Column for formatting country code as flags. | ||
| */ | ||
| class Flag extends Table\Column | ||
| { | ||
| /** @var string Name of model field which contains country ALPHA-2 (2 letter) codes. */ | ||
| public $codeField; | ||
|
|
||
| /** @var string|null Optional name of model field which contains country names. */ | ||
| public $nameField; | ||
|
|
||
| public function getHtmlTags(Model $row, ?Field $field): array | ||
| { | ||
| $countryCode = $row->get($this->codeField); | ||
| $countryName = $this->nameField ? $row->get($this->nameField) : null; | ||
|
|
||
| return [ | ||
| $field->shortName => $countryCode === null ? '' : $this->getApp()->getTag('i', [ | ||
| 'class' => strtolower($countryCode) . ' flag', | ||
| 'title' => $countryCode . ($countryName === null ? '' : ' - ' . $countryName), | ||
|
DarkSide666 marked this conversation as resolved.
Outdated
|
||
| ]), | ||
| ]; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.