Skip to content

Commit

Permalink
Merge branch '4.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 25, 2020
2 parents e6a28d4 + 96e7fd8 commit 483d930
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
21 changes: 21 additions & 0 deletions src/Resources/contao/classes/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,27 @@ protected function getPickerInputField($value, $attributes='')
return '';
}

/**
* Return the data-picker-value attribute with the currently selected picker values (see #1816)
*
* @return string
*/
protected function getPickerValueAttribute()
{
// Only load the previously selected values for the checkbox field type (see #2346)
if ($this->strPickerFieldType != 'checkbox')
{
return '';
}

$values = array_map($this->objPickerCallback, $this->arrPickerValue);
$values = array_map('strval', $values);
$values = json_encode($values);
$values = htmlspecialchars($values);

return ' data-picker-value="' . $values . '"';
}

/**
* Build the sort panel and return it as string
*
Expand Down
10 changes: 1 addition & 9 deletions src/Resources/contao/drivers/DC_Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,6 @@ public function showAll()
$icon = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['icon'] ?: 'filemounts.svg';
$label = Image::getHtml($icon) . ' <label>' . $label . '</label>';

// Pass previously selected values to picker (#1816)
$prevPickerValue = '';

if ($this->strPickerFieldType)
{
$prevPickerValue = ' data-picker-value="' . htmlspecialchars(json_encode(array_map('strval', $this->arrPickerValue))) . '"';
}

// Build the tree
$return = $this->panel() . Message::generate() . '
<div id="tl_buttons">' . ((Input::get('act') == 'select') ? '
Expand All @@ -467,7 +459,7 @@ public function showAll()
<div id="paste_hint" data-add-to-scroll-offset="20">
<p>' . $GLOBALS['TL_LANG']['MSC']['selectNewPosition'] . '</p>
</div>' : '') . '
<div class="tl_listing_container tree_view" id="tl_listing"' . $prevPickerValue . '>' . ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['breadcrumb'] ?? '') . ((Input::get('act') == 'select' || $this->strPickerFieldType == 'checkbox') ? '
<div class="tl_listing_container tree_view" id="tl_listing"' . $this->getPickerValueAttribute() . '>' . ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['breadcrumb'] ?? '') . ((Input::get('act') == 'select' || $this->strPickerFieldType == 'checkbox') ? '
<div class="tl_select_trigger">
<label for="tl_select_trigger" class="tl_select_label">' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</label> <input type="checkbox" id="tl_select_trigger" onclick="Backend.toggleCheckboxes(this)" class="tl_tree_checkbox">
</div>' : '') . '
Expand Down
30 changes: 3 additions & 27 deletions src/Resources/contao/drivers/DC_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3643,14 +3643,6 @@ protected function treeView()
<p class="tl_empty">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
}

// Pass previously selected values to picker (#1816)
$prevPickerValue = '';

if ($this->strPickerFieldType)
{
$prevPickerValue = ' data-picker-value="' . htmlspecialchars(json_encode(array_map('strval', $this->arrPickerValue))) . '"';
}

$return .= ((Input::get('act') == 'select') ? '
<form id="tl_select" class="tl_form' . ((Input::get('act') == 'select') ? ' unselectable' : '') . '" method="post" novalidate>
<div class="tl_formbody_edit">
Expand All @@ -3659,7 +3651,7 @@ protected function treeView()
<div id="paste_hint" data-add-to-scroll-offset="20">
<p>' . $GLOBALS['TL_LANG']['MSC']['selectNewPosition'] . '</p>
</div>' : '') . '
<div class="tl_listing_container tree_view" id="tl_listing"' . $prevPickerValue . '>' . $breadcrumb . ((Input::get('act') == 'select' || ($this->strPickerFieldType == 'checkbox')) ? '
<div class="tl_listing_container tree_view" id="tl_listing"' . $this->getPickerValueAttribute() . '>' . $breadcrumb . ((Input::get('act') == 'select' || ($this->strPickerFieldType == 'checkbox')) ? '
<div class="tl_select_trigger">
<label for="tl_select_trigger" class="tl_select_label">' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</label> <input type="checkbox" id="tl_select_trigger" onclick="Backend.toggleCheckboxes(this)" class="tl_tree_checkbox">
</div>' : '') . '
Expand Down Expand Up @@ -4202,14 +4194,6 @@ protected function parentView()
return $return;
}

// Pass previously selected values to picker (#1816)
$prevPickerValue = '';

if ($this->strPickerFieldType)
{
$prevPickerValue = ' data-picker-value="' . htmlspecialchars(json_encode(array_map('strval', $this->arrPickerValue))) . '"';
}

$return .= ((Input::get('act') == 'select') ? '
<form id="tl_select" class="tl_form' . ((Input::get('act') == 'select') ? ' unselectable' : '') . '" method="post" novalidate>
Expand All @@ -4219,7 +4203,7 @@ protected function parentView()
<div id="paste_hint" data-add-to-scroll-offset="20">
<p>' . $GLOBALS['TL_LANG']['MSC']['selectNewPosition'] . '</p>
</div>' : '') . '
<div class="tl_listing_container parent_view' . ($this->strPickerFieldType ? ' picker unselectable' : '') . '" id="tl_listing"' . $prevPickerValue . '>
<div class="tl_listing_container parent_view' . ($this->strPickerFieldType ? ' picker unselectable' : '') . '" id="tl_listing"' . $this->getPickerValueAttribute() . '>
<div class="tl_header click2edit toggle_select hover-div">';

// List all records of the child table
Expand Down Expand Up @@ -4840,20 +4824,12 @@ protected function listView()
{
$result = $objRow->fetchAllAssoc();

// Pass previously selected values to picker (#1816)
$prevPickerValue = '';

if ($this->strPickerFieldType)
{
$prevPickerValue = ' data-picker-value="' . htmlspecialchars(json_encode(array_map('strval', $this->arrPickerValue))) . '"';
}

$return .= ((Input::get('act') == 'select') ? '
<form id="tl_select" class="tl_form' . ((Input::get('act') == 'select') ? ' unselectable' : '') . '" method="post" novalidate>
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_select">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">' : '') . '
<div class="tl_listing_container list_view" id="tl_listing"' . $prevPickerValue . '>' . ((Input::get('act') == 'select' || $this->strPickerFieldType == 'checkbox') ? '
<div class="tl_listing_container list_view" id="tl_listing"' . $this->getPickerValueAttribute() . '>' . ((Input::get('act') == 'select' || $this->strPickerFieldType == 'checkbox') ? '
<div class="tl_select_trigger">
<label for="tl_select_trigger" class="tl_select_label">' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</label> <input type="checkbox" id="tl_select_trigger" onclick="Backend.toggleCheckboxes(this)" class="tl_tree_checkbox">
</div>' : '') . '
Expand Down

0 comments on commit 483d930

Please sign in to comment.