Skip to content

Commit c3c2f91

Browse files
committed
Merge branch 'master' into fixNewsNotificationBadge
2 parents ef6a6c6 + 281bb2d commit c3c2f91

File tree

12 files changed

+70
-63
lines changed

12 files changed

+70
-63
lines changed

.idea/leantime-oss.iml

+1-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpspec.xml

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpunit.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Core/Middleware/RequestRateLimiter.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Leantime\Core\Frontcontroller;
1111
use Leantime\Core\IncomingRequest;
1212
use Leantime\Core\Middleware\Request;
13+
use Leantime\Domain\Api\Services\Api;
1314
use Symfony\Component\HttpFoundation\Response;
1415

1516
/**
@@ -55,7 +56,7 @@ public function handle(IncomingRequest $request, Closure $next): Response
5556
//API Routes Limit
5657
if ($request instanceof ApiRequest) {
5758
$apiKey = "";
58-
$key = app()->make(ApiRequest::class)->getAPIKeyUser($apiKey);
59+
$key = app()->make(Api::class)->getAPIKeyUser($apiKey);
5960
$limit = 10;
6061
}
6162

app/Domain/Timesheets/Controllers/ShowMy.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,16 @@ public function saveTimeSheet(array $postData): void
137137
"kind" => $kind,
138138
);
139139

140-
try {
141-
$this->timesheetService->upsertTime($ticketId, $values);
142-
$this->tpl->setNotification("Timesheet saved successfully", "success", "save_timesheet");
143-
} catch (\Exception $e) {
144-
$this->tpl->setNotification("Error logging time: " . $e->getMessage(), "error", "save_timesheet");
145-
error_log($e);
146-
continue;
140+
//This should not be the case since we set the input to disabled, but check anyways
141+
if($timestamp !== "false" && $timestamp != false) {
142+
try {
143+
$this->timesheetService->upsertTime($ticketId, $values);
144+
$this->tpl->setNotification("Timesheet saved successfully", "success", "save_timesheet");
145+
} catch (\Exception $e) {
146+
$this->tpl->setNotification("Error logging time: " . $e->getMessage(), "error", "save_timesheet");
147+
error_log($e);
148+
continue;
149+
}
147150
}
148151
}
149152
}

app/Domain/Timesheets/Controllers/ShowMyList.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function run(): Response
4949
// The front end javascript is hardcode to start the week on mondays, so we use that here too.
5050

5151
//Get start of the week in current users timezone and then switch to UTC
52-
$dateFrom = dtHelper()->userNow()->startOfMonth()->setToDbTimezone();
53-
$dateTo = dtHelper()->userNow()->endOfMonth()->setToDbTimezone();
52+
$dateFrom = dtHelper()->userNow()->startOfWeek(CarbonInterface::MONDAY)->setToDbTimezone();
53+
$dateTo = dtHelper()->userNow()->endOfWeek()->setToDbTimezone();
5454

5555
if (!empty($_POST['dateFrom'])) {
5656
$dateFrom = dtHelper()->parseUserDateTime($_POST['dateFrom'])->setToDbTimezone();

app/Domain/Timesheets/Services/Timesheets.php

+24-8
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,12 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i
316316
$currentWorkDate = dtHelper()->parseDbDateTime($timesheet['workDate']);
317317

318318
// Detect timezone offset
319+
319320
$workdateOffsetStart = ($currentWorkDate->setToUserTimezone()->secondsSinceMidnight() / 60 / 60);
320321

321322
// Various Entries can be in different timezones and thus would not be caught by upsert or grouping by
322323
// default Creating new rows for each timezone adjustment
324+
//to avoid timezone collisions we disable adding new times to rows that were created in an different timezone
323325
$timezonedTime = $currentWorkDate->format("H:i:s");
324326

325327
$groupKey = $timesheet["ticketId"] . "-" . $timesheet["kind"] . "-" . $timezonedTime;
@@ -336,50 +338,50 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i
336338
"day1" => array(
337339
"start" => $fromDate,
338340
"end" => $fromDate->addHours(23)->addMinutes(59),
339-
"actualWorkDate" => $fromDate->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
341+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
340342

341343
"hours" => 0,
342344
"description" => "",
343345
),
344346
"day2" => array(
345347
"start" => $fromDate->addDays(1),
346348
"end" => $fromDate->addDays(1)->addHours(23)->addMinutes(59),
347-
"actualWorkDate" => $fromDate->addDays(1)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
349+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(1)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
348350
"hours" => 0,
349351
"description" => "",
350352
),
351353
"day3" => array(
352354
"start" => $fromDate->addDays(2),
353355
"end" => $fromDate->addDays(2)->addHours(23)->addMinutes(59),
354-
"actualWorkDate" => $fromDate->addDays(2)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
356+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(2)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
355357
"hours" => 0,
356358
"description" => "",
357359
),
358360
"day4" => array(
359361
"start" => $fromDate->addDays(3),
360362
"end" => $fromDate->addDays(3)->addHours(23)->addMinutes(59),
361-
"actualWorkDate" => $fromDate->addDays(3)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
363+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(3)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
362364
"hours" => 0,
363365
"description" => "",
364366
),
365367
"day5" => array(
366368
"start" => $fromDate->addDays(4),
367369
"end" => $fromDate->addDays(4)->addHours(23)->addMinutes(59),
368-
"actualWorkDate" => $fromDate->addDays(4)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
370+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(4)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
369371
"hours" => 0,
370372
"description" => "",
371373
),
372374
"day6" => array(
373375
"start" => $fromDate->addDays(5),
374376
"end" => $fromDate->addDays(5)->addHours(23)->addMinutes(59),
375-
"actualWorkDate" => $fromDate->addDays(5)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
377+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(5)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
376378
"hours" => 0,
377379
"description" => "",
378380
),
379381
"day7" => array(
380382
"start" => $fromDate->addDays(6),
381383
"end" => $fromDate->addDays(6)->addHours(23)->addMinutes(59),
382-
"actualWorkDate" => $fromDate->addDays(6)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second),
384+
"actualWorkDate" => $workdateOffsetStart === 0 ? $fromDate->addDays(6)->setTime($currentWorkDate->hour, $currentWorkDate->minute, $currentWorkDate->second) : "",
383385
"hours" => 0,
384386
"description" => "",
385387
),
@@ -397,9 +399,11 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i
397399
// stored as UTC timezone shoifted value in the db.
398400
// If the value is not exact but falls within the time period we're adding a new row
399401
for ($i = 1; $i < 8; $i++) {
402+
400403
$start = $timesheetGroups[$groupKey]["day" . $i]["start"];
401404
$end = $timesheetGroups[$groupKey]["day" . $i]["end"];
402-
if ($currentWorkDate->gte($start) && $currentWorkDate->lte($end)) {
405+
406+
if ($currentWorkDate->gte($start) && $currentWorkDate->lt($end)) {
403407
$timesheetGroups[$groupKey]["day" . $i]['hours'] += $timesheet['hours'];
404408
$timesheetGroups[$groupKey]["day" . $i]['actualWorkDate'] = $currentWorkDate;
405409
$timesheetGroups[$groupKey]["day" . $i]['description'] = $timesheet['description'];
@@ -409,6 +413,18 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i
409413
}
410414
}
411415

416+
/*for ($i = 1; $i < 8; $i++) {
417+
if ($timesheetGroups[$groupKey]["day" . $i]['actualWorkDate'] == $currentWorkDate) {
418+
$timesheetGroups[$groupKey]["day" . $i]['hours'] += $timesheet['hours'];
419+
$timesheetGroups[$groupKey]["day" . $i]['description'] = $timesheet['description'];
420+
// No need to check further, we found what we came for
421+
break;
422+
}
423+
}*/
424+
425+
426+
427+
412428
// Add to rowsum
413429
$timesheetGroups[$groupKey]["rowSum"] += $timesheet['hours'];
414430
}

app/Domain/Timesheets/Templates/showMy.tpl.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,10 @@
258258
<?php
259259
$i = 0;
260260
foreach ($days as $day) { ?>
261-
<th class="<?php if ($dateFrom->isToday()) {
261+
<th class="<?php if ($dateFrom->addDays($i)->setToUserTimezone()->isToday()) {
262262
echo "active";
263-
} ?>"><?php echo $day ?><br />
263+
} ?>
264+
"><?php echo $day ?><br />
264265
<?php
265266

266267
echo $dateFrom->addDays($i)->formatDateForUser();
@@ -293,7 +294,7 @@
293294
<?php echo $tpl->__($tpl->get('kind')[$timeRow['kind']]); ?>
294295
<?php if ($timeRow['hasTimesheetOffset']) { ?>
295296
<i class="fa-solid fa-clock-rotate-left pull-right label-blue"
296-
data-tippy-content="This entry was likely created using a different timezone">
297+
data-tippy-content="This entry was likely created using a different timezone. Only existing entries can be updated in this timezone">
297298
</i>
298299
<?php } ?>
299300
</td>
@@ -304,19 +305,23 @@
304305

305306
<td width="7%" class="row<?php
306307
echo $dayKey;
307-
if ($timeRow[$dayKey]["actualWorkDate"]->setToUserTimezone()->isToday()) {
308+
if ($timeRow[$dayKey]["start"]->setToUserTimezone()->isToday()) {
308309
echo " active";
309310
}
310311
?>">
311312

312313

313314
<?php
314-
$inputNameKey = $timeRow["ticketId"] . "|" . $timeRow["kind"] . "|" . $timeRow[$dayKey]["actualWorkDate"]->formatDateForUser() . "|" . $timeRow[$dayKey]["actualWorkDate"]->getTimestamp();
315+
$inputNameKey = $timeRow["ticketId"] . "|" . $timeRow["kind"] . "|" . ($timeRow[$dayKey]["actualWorkDate"] ? $timeRow[$dayKey]["actualWorkDate"]->formatDateForUser() : "false" ). "|" . ($timeRow[$dayKey]["actualWorkDate"] ? $timeRow[$dayKey]["actualWorkDate"]->getTimestamp() : "false");
315316
?>
316317
<input type="text"
317318
class="hourCell"
319+
<?php if(empty($timeRow[$dayKey]["actualWorkDate"])) echo "disabled='disabled'"; ?>
318320
name="<?php echo $inputNameKey ?>"
319321
value="<?php echo $timeRow[$dayKey]["hours"]; ?>"
322+
<?php if(empty($timeRow[$dayKey]["actualWorkDate"])) { ?>
323+
data-tippy-content="Cannot add time entry in previous timezone"
324+
<?php } ?>
320325
/>
321326

322327
<?php if (!empty($timeRow[$dayKey]["description"])) {?>
@@ -418,7 +423,7 @@ class="hourCell"
418423
</tfoot>
419424
</table>
420425
<div class="right">
421-
<input type="submit" name="saveTimeSheet" value="Save"/>
426+
<input type="submit" name="saveTimeSheet" value="Save" />
422427
</div>
423428
<div class="clearall"></div>
424429
</form>

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/css/components/forms.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ select, textarea, input[type="text"], input[type="password"], input[type="dateti
5050
color:var(--primary-font-color);
5151
}
5252

53-
input:read-only,
53+
input[type="text"]:read-only,
5454
input:disabled,
5555
.btn-primary[disabled]{
5656
border:none;
5757
box-shadow:none;
58-
padding-left: 0px;
58+
opacity:0.4;
5959
}
6060

6161
body input:focus {

public/dist/mix-manifest.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"/js/compiled-htmx.3.1.2.min.js": "/js/compiled-htmx.3.1.2.min.js",
3-
"/js/compiled-htmx-headSupport.3.1.2.min.js": "/js/compiled-htmx-headSupport.3.1.2.min.js",
4-
"/css/main.3.1.2.min.css": "/css/main.3.1.2.min.css",
5-
"/css/editor.3.1.2.min.css": "/css/editor.3.1.2.min.css",
6-
"/css/app.3.1.2.min.css": "/css/app.3.1.2.min.css",
7-
"/js/compiled-footer.3.1.2.min.js": "/js/compiled-footer.3.1.2.min.js",
8-
"/js/compiled-app.3.1.2.min.js": "/js/compiled-app.3.1.2.min.js",
9-
"/js/compiled-frameworks.3.1.2.min.js": "/js/compiled-frameworks.3.1.2.min.js",
10-
"/js/compiled-framework-plugins.3.1.2.min.js": "/js/compiled-framework-plugins.3.1.2.min.js",
11-
"/js/compiled-global-component.3.1.2.min.js": "/js/compiled-global-component.3.1.2.min.js",
12-
"/js/compiled-calendar-component.3.1.2.min.js": "/js/compiled-calendar-component.3.1.2.min.js",
13-
"/js/compiled-table-component.3.1.2.min.js": "/js/compiled-table-component.3.1.2.min.js",
14-
"/js/compiled-editor-component.3.1.2.min.js": "/js/compiled-editor-component.3.1.2.min.js",
15-
"/js/compiled-gantt-component.3.1.2.min.js": "/js/compiled-gantt-component.3.1.2.min.js",
16-
"/js/compiled-chart-component.3.1.2.min.js": "/js/compiled-chart-component.3.1.2.min.js",
2+
"/js/compiled-htmx.3.1.3.min.js": "/js/compiled-htmx.3.1.3.min.js",
3+
"/js/compiled-htmx-headSupport.3.1.3.min.js": "/js/compiled-htmx-headSupport.3.1.3.min.js",
4+
"/css/main.3.1.3.min.css": "/css/main.3.1.3.min.css",
5+
"/css/editor.3.1.3.min.css": "/css/editor.3.1.3.min.css",
6+
"/css/app.3.1.3.min.css": "/css/app.3.1.3.min.css",
7+
"/js/compiled-footer.3.1.3.min.js": "/js/compiled-footer.3.1.3.min.js",
8+
"/js/compiled-app.3.1.3.min.js": "/js/compiled-app.3.1.3.min.js",
9+
"/js/compiled-frameworks.3.1.3.min.js": "/js/compiled-frameworks.3.1.3.min.js",
10+
"/js/compiled-framework-plugins.3.1.3.min.js": "/js/compiled-framework-plugins.3.1.3.min.js",
11+
"/js/compiled-global-component.3.1.3.min.js": "/js/compiled-global-component.3.1.3.min.js",
12+
"/js/compiled-calendar-component.3.1.3.min.js": "/js/compiled-calendar-component.3.1.3.min.js",
13+
"/js/compiled-table-component.3.1.3.min.js": "/js/compiled-table-component.3.1.3.min.js",
14+
"/js/compiled-editor-component.3.1.3.min.js": "/js/compiled-editor-component.3.1.3.min.js",
15+
"/js/compiled-gantt-component.3.1.3.min.js": "/js/compiled-gantt-component.3.1.3.min.js",
16+
"/js/compiled-chart-component.3.1.3.min.js": "/js/compiled-chart-component.3.1.3.min.js",
1717
"/images/03-1.png": "/images/03-1.png",
1818
"/images/32px.png": "/images/32px.png",
1919
"/images/40px.png": "/images/40px.png",

0 commit comments

Comments
 (0)