@php
$steps_paginator_length = 2; // Number of steps to show before and after the current step
$pipelines = $task->pipeline->scrumBoard->pipelines; // Getting the pipelines for easier reference
$currentOrder = $task->pipeline->order; // Current order of the task's pipeline
$totalPipelines = $pipelines->count(); // Total number of pipelines
$currentIndex = $pipelines->search(function ($pl) use ($currentOrder) {
return $pl->order === $currentOrder;
}); // Find the index of the current pipeline
@endphp
@if ($totalPipelines > 0)
@foreach ($pipelines as $index => $pl)
@if ($index == 0) {{-- First item --}}
-
{{ $loop->iteration }}
{{ $pl->name }} {{-- Truncated text --}}
@elseif ($index == $totalPipelines - 1) {{-- Last item --}}
-
{{ $loop->iteration }}
{{ $pl->name }} {{-- Truncated text --}}
@elseif ($index == $currentIndex) {{-- Current item --}}
-
{{ $loop->iteration }}
{{ $pl->name }} {{-- Truncated text --}}
@elseif ($index == $currentIndex - 1 || $index == $currentIndex + 1) {{-- Previous and Next items --}}
-
{{ $loop->iteration }}
{{ $pl->name }} {{-- Truncated text --}}
@elseif ($index == $currentIndex - $steps_paginator_length - 1 && $currentIndex - $steps_paginator_length > 0) {{-- Show ellipsis before previous items --}}
- ...
@elseif ($index == $currentIndex + $steps_paginator_length + 1 && $currentIndex + $steps_paginator_length < $totalPipelines - 1) {{-- Show ellipsis after next items --}}
- ...
@endif
@endforeach
@else
- No pipelines available.
@endif
{{--
@php
$steps_paginator_length = 2
@endphp
@forelse ($task->pipeline->scrumBoard->pipelines as $pl)
@if($loop->index >= $steps_paginator_length && $loop->iteration < $loop->count - 1)
@if($loop->index == $steps_paginator_length)
- ...
@endif
@else
- {{ $loop->iteration }} {{ $pl->name }}
@endif
@empty
@endforelse
--}}