Fixes #934 - Scheduled items now drop into the right days
This commit is contained in:
@@ -65,7 +65,13 @@ class HomeController extends AbstractController
|
|||||||
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [
|
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [
|
||||||
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
|
||||||
$startDate->format('Y-m-d').' 23:59:59',
|
$startDate->format('Y-m-d').' 23:59:59',
|
||||||
])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
|
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
|
||||||
|
// If it's scheduled, get the scheduled at date.
|
||||||
|
if ($incident->is_scheduled) {
|
||||||
|
return (new Date($incident->scheduled_at))
|
||||||
|
->setTimezone($dateTimeZone)->toDateString();
|
||||||
|
}
|
||||||
|
|
||||||
return (new Date($incident->created_at))
|
return (new Date($incident->created_at))
|
||||||
->setTimezone($dateTimeZone)->toDateString();
|
->setTimezone($dateTimeZone)->toDateString();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class Incident extends Model implements HasPresenter
|
|||||||
*/
|
*/
|
||||||
public function getIsScheduledAttribute()
|
public function getIsScheduledAttribute()
|
||||||
{
|
{
|
||||||
return $this->getOriginal('scheduled_at');
|
return $this->getOriginal('scheduled_at') !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -129,6 +129,34 @@ class IncidentPresenter extends AbstractPresenter
|
|||||||
return $this->wrappedObject->scheduled_at->setTimezone($this->setting->get('app_timezone'))->format('d/m/Y H:i');
|
return $this->wrappedObject->scheduled_at->setTimezone($this->setting->get('app_timezone'))->format('d/m/Y H:i');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a formatted timestamp for use within the timeline.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function timestamp_formatted()
|
||||||
|
{
|
||||||
|
if ($this->wrappedObject->is_scheduled) {
|
||||||
|
return $this->scheduled_at_formatted;
|
||||||
|
} else {
|
||||||
|
return $this->created_at_formatted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the iso timestamp for use within the timeline.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function timestamp_iso()
|
||||||
|
{
|
||||||
|
if ($this->wrappedObject->is_scheduled) {
|
||||||
|
return $this->scheduled_at_iso;
|
||||||
|
} else {
|
||||||
|
return $this->created_at_iso;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Present the status with an icon.
|
* Present the status with an icon.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
<strong>{{ $incident->name }}</strong>{{ $incident->isScheduled ? trans("cachet.incidents.scheduled_at", ["timestamp" => $incident->scheduled_at_diff]) : null }}
|
<strong>{{ $incident->name }}</strong>{{ $incident->isScheduled ? trans("cachet.incidents.scheduled_at", ["timestamp" => $incident->scheduled_at_diff]) : null }}
|
||||||
<br>
|
<br>
|
||||||
<small class="date">
|
<small class="date">
|
||||||
<abbr class="timeago" data-toggle="tooltip" data-placement="right" title="{{ $incident->created_at_formatted }}" data-timeago="{{ $incident->created_at_iso }}">
|
<abbr class="timeago" data-toggle="tooltip" data-placement="right" title="{{ $incident->timestamp_formatted }}" data-timeago="{{ $incident->timestamp_iso }}"></abbr>
|
||||||
</abbr>
|
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|||||||
Reference in New Issue
Block a user