Skip to content

Commit

Permalink
GroupActionCollection: fixed group text action collision with another…
Browse files Browse the repository at this point in the history
… datagrid
  • Loading branch information
paveljanda committed Jun 30, 2020
1 parent 54f1c47 commit 790b8fa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/GroupAction/GroupActionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class GroupActionCollection
{

private const ID_ATTRIBUTE_PREFIX = 'group_action_item_';
private const ID_ATTRIBUTE_PREFIX = '_item_';

/**
* @var array<GroupAction>
Expand All @@ -38,6 +38,7 @@ public function addToFormContainer(Container $container): void
{
/** @var Form $form */
$form = $container->lookup(Form::class);
$lookupPath = $container->lookupPath();
$translator = $form->getTranslator();
$main_options = [];

Expand Down Expand Up @@ -88,27 +89,27 @@ public function addToFormContainer(Container $container): void
if ($action->hasOptions()) {
if ($action instanceof GroupMultiSelectAction) {
$control = $container->addMultiSelect((string) $id, '', $action->getOptions());
$control->setAttribute('data-datagrid-multiselect-id', self::ID_ATTRIBUTE_PREFIX . $id);
$control->setAttribute('data-datagrid-multiselect-id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
$control->setAttribute('data-style', 'hidden');
$control->setAttribute('data-selected-icon-check', DataGrid::$iconPrefix . 'check');
} else {
$control = $container->addSelect((string) $id, '', $action->getOptions());
}

$control->setAttribute('id', self::ID_ATTRIBUTE_PREFIX . $id);
$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
}
} elseif ($action instanceof GroupTextAction) {
$control = $container->addText((string) $id, '');

$control->setAttribute('id', self::ID_ATTRIBUTE_PREFIX . $id)
$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'))
->endCondition();

} elseif ($action instanceof GroupTextareaAction) {
$control = $container->addTextArea((string) $id, '');

$control->setAttribute('id', self::ID_ATTRIBUTE_PREFIX . $id)
$control->setAttribute('id', $lookupPath . self::ID_ATTRIBUTE_PREFIX . $id)
->addConditionOn($groupActionSelect, Form::EQUAL, $id)
->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'));
}
Expand All @@ -131,7 +132,7 @@ public function addToFormContainer(Container $container): void
if ($main_options !== []) {
foreach (array_keys($this->groupActions) as $id) {
$groupActionSelect->addCondition(Form::EQUAL, $id)
->toggle(self::ID_ATTRIBUTE_PREFIX . $id);
->toggle($lookupPath . self::ID_ATTRIBUTE_PREFIX . $id);
}

$groupActionSelect->addCondition(Form::FILLED)
Expand Down

0 comments on commit 790b8fa

Please sign in to comment.