-
Notifications
You must be signed in to change notification settings - Fork 108
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
Feature/card improvements #2025
base: develop
Are you sure you want to change the base?
Changes from all commits
860b7e4
35e00d4
db91796
f3ff230
ddb9a77
c61d65b
85ecc63
4438de5
22b31fd
488d86f
40e4a45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Atk4\Ui\Demos; | ||
|
||
use Atk4\Ui\Card; | ||
use Atk4\Ui\View; | ||
|
||
class CustomCard extends Card | ||
{ | ||
public function getButtonContainer() | ||
{ | ||
if (!$this->btnContainer) { | ||
// $this->btnContainer = $this->addExtraContent(new View(['ui' => 'buttons'])); | ||
$this->btnContainer = $this->add(new View(['ui' => 'buttons bottom attached'])); // attach buttons to bottom | ||
$this->getButtonContainer()->addClass('wrapping'); | ||
if ($this->hasFluidButton) { | ||
$this->getButtonContainer()->addClass('fluid'); | ||
} | ||
} | ||
|
||
return $this->btnContainer; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div data-id="{$dataId}" {$attributes}> | ||
<div class="content"> | ||
<i class="{$iso_lower} flag"></i> | ||
<i class="right floated like icon"></i> | ||
<i class="right floated star icon"></i> | ||
</div> | ||
{$Image} | ||
{$Content} | ||
{$Section} | ||
{$ExtraContent} | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,15 +64,15 @@ public function addFields(Model $model, array $fields, bool $useLabel = false, b | |
/** | ||
* Add fields label and value to section. | ||
*/ | ||
private function addSectionFields(Model $model, array $fields, bool $useLabel = false): void | ||
protected function addSectionFields(Model $model, array $fields, bool $useLabel = false): void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Private methods are often added as the API might not be well defined. If private, we do not have to care, but if protected, we need to support the API in a long term. Please confirm you understand this and also there are no simillar private methods in other components. |
||
{ | ||
foreach ($fields as $field) { | ||
if ($model->titleField === $field) { | ||
continue; | ||
} | ||
$label = $model->getField($field)->getCaption(); | ||
$value = $this->getApp()->uiPersistence->typecastSaveField($model->getField($field), $model->get($field)); | ||
if ($useLabel) { | ||
$label = $model->getField($field)->getCaption(); | ||
$value = $label . $this->glue . $value; | ||
} | ||
|
||
|
@@ -85,7 +85,7 @@ private function addSectionFields(Model $model, array $fields, bool $useLabel = | |
/** | ||
* Add field into section using a CardTable View. | ||
*/ | ||
private function addTableSection(Model $model, array $fields): void | ||
protected function addTableSection(Model $model, array $fields): void | ||
{ | ||
$cardTable = CardTable::addTo($this, ['class' => $this->tableClass]); | ||
$cardTable->setModel($model, $fields); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,7 +157,7 @@ protected function _setOrAppend($tag, string $value = null, bool $encodeHtml = t | |
// in this case we don't throw exception if tags don't exist | ||
if (is_array($tag) && $value === null) { | ||
foreach ($tag as $k => $v) { | ||
$this->_setOrAppend($k, $v, $encodeHtml, $append, false); | ||
$this->_setOrAppend($k, (string) $v, $encodeHtml, $append, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never cast to a string, string type is required There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see l153/typecasting above, this is already fully handled when set thru model, we cannot do it with array, as php type itself is not enought to determine DBAL/typecasting type, since #1987 we format |
||
} | ||
|
||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never use
(array)
cast, change the def. value to be an array seed insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will work on that a bit more probably tomorrow. Looks like there are more seed related things to fix in this (and Card) classes for consistency with other views and also to ease extending.