Skip to content

Commit

Permalink
Merge pull request #246 from skaut/omezeni-delky-zahlavi
Browse files Browse the repository at this point in the history
zkracování názvu vlastního pole v hlavičce
  • Loading branch information
Jan Staněk authored Mar 22, 2017
2 parents 702ee32 + f5de653 commit ec2d390
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/AdminModule/components/UsersGridControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function createComponentUsersGrid($name)
});

foreach ($this->customInputRepository->findAllOrderedByPosition() as $customInput) {
$grid->addColumnText('customInput' . $customInput->getId(), $customInput->getName())
$grid->addColumnText('customInput' . $customInput->getId(), $this->truncate($customInput->getName(), 35))
->setRenderer(function ($row) use ($customInput) {
$customInputValue = $row->getCustomInputValue($customInput);
if ($customInputValue) {
Expand Down Expand Up @@ -555,4 +555,14 @@ private function preparePaymentMethodFilterOptions()
$options[$type] = 'common.payment.' . $type;
return $options;
}

private function truncate($text, $length) {
if (strlen($text) > $length) {
$text = $text . " ";
$text = substr($text, 0, $length);
$text = substr($text, 0, strrpos($text, ' '));
$text = $text . "...";
}
return $text;
}
}

0 comments on commit ec2d390

Please sign in to comment.