Merge pull request 'womtfix/negative-werte' (#12) from womtfix/negative-werte into master
Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
@@ -91,12 +91,13 @@ class WorkingHoursView implements ModelInterface
|
||||
'overtime' => "string"
|
||||
])] public function jsonSerialize(): array
|
||||
{
|
||||
$formatOvertime = (($this->getOvertime()->invert === 1) ? '-' : '') . '%H:%I:%S';
|
||||
return [
|
||||
'period' => $this->getPeriod()->format($this->getPeriodDesignation()->getValue()),
|
||||
'periodDesignation' => strtolower($this->getPeriodDesignation()->getKey()),
|
||||
'workingDays' => $this->getWorkingDays(),
|
||||
'totalHours' => $this->getTotalHours()->format('%H:%I:%S'),
|
||||
'overtime' => $this->getOvertime()->format('%H:%I:%S')
|
||||
'overtime' => $this->getOvertime()->format($formatOvertime)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Slim\App;
|
||||
use Slim\Exception\HttpException;
|
||||
use Slim\Interfaces\RouteParserInterface;
|
||||
use Slim\Routing\RouteContext;
|
||||
use Slim\Routing\RoutingResults;
|
||||
use TorstenHettstedt\TimekeepingApi\Middleware\ErrorHandler;
|
||||
|
||||
class ErrorHandlerTest extends Unit
|
||||
@@ -28,6 +31,7 @@ class ErrorHandlerTest extends Unit
|
||||
protected function _before(): void
|
||||
{
|
||||
parent::_before();
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->app = $this->makeEmpty(App::class, [
|
||||
'getResponseFactory' => $this->makeEmpty(ResponseFactoryInterface::class, [
|
||||
'createResponse' => $this->makeEmpty(ResponseInterface::class, [
|
||||
@@ -40,7 +44,16 @@ class ErrorHandlerTest extends Unit
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
$this->request = $this->makeEmpty(ServerRequestInterface::class);
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->request = $this->makeEmpty(ServerRequestInterface::class, [
|
||||
'getAttribute' => function($name) {
|
||||
return match ($name) {
|
||||
RouteContext::ROUTE_PARSER => $this->makeEmpty(RouteParserInterface::class),
|
||||
RouteContext::ROUTING_RESULTS => $this->makeEmpty(RoutingResults::class),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,11 +61,13 @@ class ErrorHandlerTest extends Unit
|
||||
*/
|
||||
public function testUseWithLogger(): void
|
||||
{
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->exception = $this->make(Exception::class, [
|
||||
'message' => '',
|
||||
'code' => 400,
|
||||
'file' => '/path(to/file',
|
||||
]);
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->logger = $this->makeEmpty(LoggerInterface::class, [
|
||||
'error' => Expected::once(),
|
||||
]);
|
||||
@@ -66,12 +81,14 @@ class ErrorHandlerTest extends Unit
|
||||
*/
|
||||
public function testUseWithHttpException(): void
|
||||
{
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->exception = $this->make(HttpException::class, [
|
||||
'message' => '',
|
||||
'code' => 400,
|
||||
'file' => '/path(to/file',
|
||||
'getTitle' => Expected::once('The Title'),
|
||||
]);
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->logger = $this->makeEmpty(LoggerInterface::class, []);
|
||||
|
||||
$middleWare = new ErrorHandler($this->app);
|
||||
@@ -84,11 +101,13 @@ class ErrorHandlerTest extends Unit
|
||||
*/
|
||||
public function testUseWithGeneralException(): void
|
||||
{
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->exception = $this->make(Exception::class, [
|
||||
'message' => '',
|
||||
'code' => 400,
|
||||
'file' => '/path(to/file',
|
||||
]);
|
||||
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
|
||||
$this->logger = $this->makeEmpty(LoggerInterface::class, []);
|
||||
|
||||
$middleWare = new ErrorHandler($this->app);
|
||||
|
||||
@@ -17,13 +17,15 @@ class WorkingHoursViewTest extends Unit
|
||||
*/
|
||||
public function workingHoursProvider(): array
|
||||
{
|
||||
$date = new DateTime('2020-11-30');
|
||||
$work_days = 15;
|
||||
$total_hours = new DateInterval("PT32H22M");
|
||||
$overtime = new DateInterval("PT22M");
|
||||
$absence_time = clone $overtime;
|
||||
$absence_time->invert = 1;
|
||||
return [
|
||||
[
|
||||
new DateTime('2020-11-30'),
|
||||
PeriodDesignationEnum::WEEKLY(),
|
||||
15,
|
||||
new DateInterval("PT32H22M"),
|
||||
new DateInterval("PT22M"),
|
||||
$date, PeriodDesignationEnum::WEEKLY(), $work_days, $total_hours, $overtime,
|
||||
[
|
||||
'period' => '2020#49',
|
||||
'periodDesignation' => 'weekly',
|
||||
@@ -33,11 +35,17 @@ class WorkingHoursViewTest extends Unit
|
||||
],
|
||||
],
|
||||
[
|
||||
new DateTime('2020-11-30'),
|
||||
PeriodDesignationEnum::MONTHLY(),
|
||||
15,
|
||||
new DateInterval("PT32H22M"),
|
||||
new DateInterval("PT22M"),
|
||||
$date, PeriodDesignationEnum::WEEKLY(), $work_days, $total_hours, $absence_time,
|
||||
[
|
||||
'period' => '2020#49',
|
||||
'periodDesignation' => 'weekly',
|
||||
'workingDays' => 15,
|
||||
'totalHours' => '32:22:00',
|
||||
'overtime' => '-00:22:00'
|
||||
],
|
||||
],
|
||||
[
|
||||
$date, PeriodDesignationEnum::MONTHLY(), $work_days, $total_hours, $overtime,
|
||||
[
|
||||
'period' => '2020-11',
|
||||
'periodDesignation' => 'monthly',
|
||||
@@ -47,12 +55,17 @@ class WorkingHoursViewTest extends Unit
|
||||
],
|
||||
],
|
||||
[
|
||||
new DateTime('2020-11-30'),
|
||||
PeriodDesignationEnum::YEARLY(),
|
||||
15,
|
||||
new DateInterval("PT32H22M"),
|
||||
new DateInterval("PT22M"),
|
||||
$date, PeriodDesignationEnum::MONTHLY(), $work_days, $total_hours, $absence_time,
|
||||
[
|
||||
'period' => '2020-11',
|
||||
'periodDesignation' => 'monthly',
|
||||
'workingDays' => 15,
|
||||
'totalHours' => '32:22:00',
|
||||
'overtime' => '-00:22:00'
|
||||
],
|
||||
],
|
||||
[
|
||||
$date, PeriodDesignationEnum::YEARLY(), $work_days, $total_hours, $overtime, [
|
||||
'period' => '2020',
|
||||
'periodDesignation' => 'yearly',
|
||||
'workingDays' => 15,
|
||||
@@ -60,6 +73,15 @@ class WorkingHoursViewTest extends Unit
|
||||
'overtime' => '00:22:00'
|
||||
],
|
||||
],
|
||||
[
|
||||
$date, PeriodDesignationEnum::YEARLY(), $work_days, $total_hours, $absence_time, [
|
||||
'period' => '2020',
|
||||
'periodDesignation' => 'yearly',
|
||||
'workingDays' => 15,
|
||||
'totalHours' => '32:22:00',
|
||||
'overtime' => '-00:22:00'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ Definition der Farben
|
||||
@hueSub: 215;
|
||||
|
||||
@mainColor: hsl(@hueMain, 90%, 29%);
|
||||
@redColor: hsl(0, 90%, 29%);
|
||||
@mainColorDark: darken(@mainColor,66%,relativ);
|
||||
@mainColorLight: lighten(@mainColor,66%,relativ);
|
||||
@subColor: hsl(@hueSub, 90%, 29%);
|
||||
|
||||
@@ -79,6 +79,13 @@ main {
|
||||
border-bottom: @mainColor solid thin;
|
||||
}
|
||||
}
|
||||
};
|
||||
tbody {
|
||||
td.absence-time {
|
||||
color: @redColor;
|
||||
text-decoration-line: underline;
|
||||
text-decoration-style: dashed;
|
||||
}
|
||||
}
|
||||
}
|
||||
form {
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
<script>
|
||||
export let params;
|
||||
console.log(params)
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.indexOf(searchString, position) === position;
|
||||
};
|
||||
}
|
||||
$: isNegative = time => time.startsWith('-') ? 'absence-time' : '';
|
||||
$: cutMinusChar = time => time.startsWith('-') ? time.substr(1) : time;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -36,7 +44,7 @@
|
||||
<td>{record.period}</td>
|
||||
<td>{record.workingDays}</td>
|
||||
<td>{record.totalHours}</td>
|
||||
<td>{record.overtime}</td>
|
||||
<td class="{ isNegative(record.overtime) }">{cutMinusChar(record.overtime)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user