detail pages for customers and projects (#1371)

This commit is contained in:
Kevin Papst
2020-01-16 16:25:28 +01:00
committed by GitHub
parent 28c5357f11
commit 6a44dbfe83
131 changed files with 3055 additions and 1742 deletions

View File

@@ -82,6 +82,7 @@ class DateExtensions extends AbstractExtension
/**
* @param DateTime|string $date
* @return string
* @throws \Exception
*/
public function dateShort($date)
{
@@ -99,6 +100,7 @@ class DateExtensions extends AbstractExtension
/**
* @param DateTime|string $date
* @return string
* @throws \Exception
*/
public function dateTime($date)
{
@@ -110,14 +112,16 @@ class DateExtensions extends AbstractExtension
$date = new DateTime($date);
}
return date_format($date, $this->dateTimeFormat);
return $date->format($this->dateTimeFormat);
}
/**
* @param DateTime|string $date
* @return string
* @param bool $userTimezone
* @return bool|false|string
* @throws \Exception
*/
public function dateTimeFull($date)
public function dateTimeFull($date, bool $userTimezone = true)
{
if (null === $this->dateTimeTypeFormat) {
$this->dateTimeTypeFormat = $this->localeSettings->getDateTimeTypeFormat();
@@ -127,11 +131,17 @@ class DateExtensions extends AbstractExtension
$date = new DateTime($date);
}
$timezone = date_default_timezone_get();
if (!$userTimezone) {
$timezone = $date->getTimezone()->getName();
}
$formatter = new \IntlDateFormatter(
$this->localeSettings->getLocale(),
\IntlDateFormatter::MEDIUM,
\IntlDateFormatter::MEDIUM,
date_default_timezone_get(),
$timezone,
\IntlDateFormatter::GREGORIAN,
$this->dateTimeTypeFormat
);
@@ -143,6 +153,7 @@ class DateExtensions extends AbstractExtension
* @param DateTime|string $date
* @param string $format
* @return false|string
* @throws \Exception
*/
public function dateFormat($date, string $format)
{
@@ -156,6 +167,7 @@ class DateExtensions extends AbstractExtension
/**
* @param DateTime|string $date
* @return string
* @throws \Exception
*/
public function time($date)
{

View File

@@ -40,12 +40,14 @@ final class IconExtension extends AbstractExtension
'edit' => 'far fa-edit',
'end' => 'fas fa-stopwatch',
'export' => 'fas fa-file-export',
'fax' => 'fas fa-fax',
'filter' => 'fas fa-filter',
'help' => 'far fa-question-circle',
'home' => 'fas fa-home',
'invoice' => 'fas fa-file-invoice-dollar',
'invoice-template' => 'fas fa-file-signature',
'list' => 'fas fa-list',
'locked' => 'fas fa-lock',
'logout' => 'fas fa-sign-out-alt',
'mail' => 'fas fa-envelope-open',
'mail-sent' => 'fas fa-paper-plane',
@@ -55,6 +57,7 @@ final class IconExtension extends AbstractExtension
'ods' => 'fas fa-table',
'off' => 'fas fa-toggle-off',
'on' => 'fas fa-toggle-on',
'pin' => 'fas fa-thumbtack',
'pdf' => 'fas fa-file-pdf',
'pause' => 'fas fa-pause',
'pause-small' => 'far fa-pause-circle',

View File

@@ -15,9 +15,9 @@ use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
/**
* A twig extension to handle markdown parser.
* A twig extension to handle markdown content.
*/
class MarkdownExtension extends AbstractExtension
final class MarkdownExtension extends AbstractExtension
{
/**
* @var Markdown
@@ -26,10 +26,9 @@ class MarkdownExtension extends AbstractExtension
/**
* @var TimesheetConfiguration
*/
protected $configuration;
private $configuration;
/**
* MarkdownExtension constructor.
* @param Markdown $parser
*/
public function __construct(Markdown $parser, TimesheetConfiguration $configuration)
@@ -46,10 +45,36 @@ class MarkdownExtension extends AbstractExtension
return [
new TwigFilter('md2html', [$this, 'markdownToHtml'], ['is_safe' => ['html']]),
new TwigFilter('desc2html', [$this, 'timesheetContent'], ['is_safe' => ['html']]),
new TwigFilter('comment2html', [$this, 'timesheetContent'], ['is_safe' => ['html']]),
new TwigFilter('comment2html', [$this, 'commentContent'], ['is_safe' => ['html']]),
];
}
/**
* Transforms the entities comment (customer, project, activity ...) into HTML.
*
* @param string $content
* @param bool $fullLength
* @return string
*/
public function commentContent(?string $content, bool $fullLength = false): string
{
if (empty($content)) {
return '';
}
if (!$fullLength && strlen($content) > 101) {
$content = trim(substr($content, 0, 100)) . ' …';
}
if ($this->configuration->isMarkdownEnabled()) {
$content = $this->markdown->toHtml($content, false);
} elseif ($fullLength) {
$content = '<p>' . nl2br($content) . '</p>';
}
return $content;
}
/**
* Transforms the timesheet description content into HTML.
*