Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Mar 26, 2024
1 parent 2baee1a commit 836853d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ public function setModel(Model $entity, ?array $fields = null): void
parent::setModel($entity);

if ($fields === null) {
$fields = array_keys($this->model->getFields(['editable', 'visible']));
$fields = array_keys($this->entity->getFields(['editable', 'visible']));
}

$this->template->trySet('dataId', $this->getApp()->uiPersistence->typecastAttributeSaveField($this->model->getIdField(), $this->model->getId()));
$this->template->trySet('dataId', $this->getApp()->uiPersistence->typecastAttributeSaveField($this->entity->getIdField(), $this->entity->getId()));

View::addTo($this->getSection(), [$entity->getTitle(), 'class.header' => true]);
$this->getSection()->addFields($entity, $fields, $this->useLabel, $this->useTable);
Expand Down Expand Up @@ -220,10 +220,10 @@ public function addClickAction(Model\UserAction $action, ?Button $button = null,

// setting arg for model ID
// $args[0] is consider to hold a model ID, i.e. as a JS expression
if ($this->model !== null && $this->model->isLoaded() && !isset($args[0])) {
$defaults[] = $this->model->getId();
if ($this->entity !== null && $this->entity->isLoaded() && !isset($args[0])) {
$defaults[] = $this->entity->getId();
if ($cardDeck === null && !$action->isOwnerEntity()) {
$action = $action->getActionForEntity($this->model);
$action = $action->getActionForEntity($this->entity);
}
}

Expand Down Expand Up @@ -259,19 +259,19 @@ public function addClickAction(Model\UserAction $action, ?Button $button = null,
/**
* Set extra content using model field.
*/
public function addExtraFields(Model $model, array $fields, ?string $glue = null): void
public function addExtraFields(Model $entity, array $fields, ?string $glue = null): void
{
// display extra field in line
if ($glue) {
$extra = '';
foreach ($fields as $field) {
$extra .= $model->get($field) . $glue;
$extra .= $entity->get($field) . $glue;
}
$extra = rtrim($extra, $glue);
$this->addExtraContent(new View([$extra, 'ui' => 'basic fitted segment']));
} else {
foreach ($fields as $field) {
$this->addExtraContent(new View([$model->get($field), 'class.ui basic fitted segment' => true]));
$this->addExtraContent(new View([$entity->get($field), 'class.ui basic fitted segment' => true]));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/CardDeck.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ public function setModel(Model $model, ?array $fields = null, ?array $extra = nu

$count = $this->initPaginator();
if ($count) {
foreach ($this->model as $m) {
foreach ($this->model as $entity) {
/** @var Card */
$c = $this->cardHolder->add(Factory::factory($this->cardSeed, ['useLabel' => $this->useLabel, 'useTable' => $this->useTable]));
$c->setModel($m, $fields);
$c->setModel($entity, $fields);
if ($extra) {
$c->addExtraFields($m, $extra, $this->extraGlue);
$c->addExtraFields($entity, $extra, $this->extraGlue);
}
if ($this->useAction) {
foreach ($this->getModelActions(Model\UserAction::APPLIES_TO_SINGLE_RECORD) as $action) {
Expand Down

0 comments on commit 836853d

Please sign in to comment.