close #3203 Enhancement: Document recurring index blade flexible columns

This commit is contained in:
Cüneyt Şentürk 2024-08-23 23:33:24 +01:00
parent dbbb11d4b0
commit bd3c5c8f02
2 changed files with 240 additions and 13 deletions

View File

@ -161,6 +161,21 @@ abstract class Index extends Component
/** @var string */
public $textIssuedAt;
/** @var bool */
public $hideStartedAt;
/** @var bool */
public $hideEndedAt;
/** @var string */
public $classStartedAtAndEndedAt;
/** @var string */
public $textStartedAt;
/** @var string */
public $textEndedAt;
/** @var bool */
public $hideStatus;
@ -170,6 +185,21 @@ abstract class Index extends Component
/** @var bool */
public $hideContactName;
/** @var bool */
public $hideCategory;
/** @var string */
public $textCategory;
/** @var bool */
public $hideFrequency;
/** @var string */
public $classFrequencyAndDuration;
/** @var bool */
public $hideDuration;
/** @var bool */
public $hideDocumentNumber;
@ -237,7 +267,10 @@ abstract class Index extends Component
bool $hideSearchString = false, bool $hideBulkAction = false,
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '', string $classBulkAction = '',
bool $hideDueAt = false, bool $hideIssuedAt = false, string $classDueAtAndIssueAt = '', string $textDueAt = '', string $textIssuedAt = '',
bool $hideStartedAt = false, bool $hideEndedAt = false, string $classStartedAtAndEndedAt = '', string $textStartedAt = '', string $textEndedAt = '',
bool $hideStatus = false, string $classStatus = '',
bool $hideCategory = false, string $textCategory = '',
bool $hideFrequency = false, bool $hideDuration = false, string $classFrequencyAndDuration = '',
bool $hideContactName = false, bool $hideDocumentNumber = false, string $classContactNameAndDocumentNumber = '', string $textContactName = '', string $showContactRoute = '', string $textDocumentNumber = '',
bool $hideAmount = false, string $classAmount = '',
bool $hideShow = false, string $showRoute = '', bool $hideEdit = false, string $editRoute = '', bool $hideDuplicate = false, string $duplicateRoute = '',
@ -320,9 +353,22 @@ abstract class Index extends Component
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
$this->hideStartedAt = $hideStartedAt;
$this->hideEndedAt = $hideEndedAt;
$this->classStartedAtAndEndedAt = $this->getClassStartedAndEndedAt($type, $classStartedAtAndEndedAt);
$this->textStartedAt = $this->getTextStartedAt($type, $textStartedAt);
$this->textEndedAt = $this->getTextEndedAt($type, $textEndedAt);
$this->hideStatus = $hideStatus;
$this->classStatus = $this->getClassStatus($type, $classStatus);
$this->hideCategory = $hideCategory;
$this->textCategory = $this->getTextCategory($type, $textCategory);
$this->hideFrequency = $hideFrequency;
$this->hideDuration = $hideDuration;
$this->classFrequencyAndDuration = $this->getClassFrequencyAndDuration($type, $classFrequencyAndDuration);
$this->hideContactName = $hideContactName;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->classContactNameAndDocumentNumber = $this->getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber);
@ -606,6 +652,66 @@ abstract class Index extends Component
return 'invoices.invoice_date';
}
protected function getClassStartedAndEndedAt($type, $classStartedAtAndEndedAt)
{
if (! empty($classStartedAtAndEndedAt)) {
return $classStartedAtAndEndedAt;
}
$class = $this->getClassFromConfig($type, 'started_at_and_end_at');
if (! empty($class)) {
return $class;
}
return 'w-4/12 table-title hidden sm:table-cell';
}
protected function getClassFrequencyAndDuration($type, $classFrequencyAndDuration)
{
if (! empty($classFrequencyAndDuration)) {
return $classFrequencyAndDuration;
}
$class = $this->getClassFromConfig($type, 'frequency_and_duration');
if (! empty($class)) {
return $class;
}
return 'w-2/12';
}
protected function getTextStartedAt($type, $textStartedAt)
{
if (! empty($textStartedAt)) {
return $textStartedAt;
}
$translation = $this->getTextFromConfig($type, 'started_at', 'started_date');
if (! empty($translation)) {
return $translation;
}
return 'general.start_date';
}
protected function getTextEndedAt($type, $textEndedAt)
{
if (! empty($textEndedAt)) {
return $textEndedAt;
}
$translation = $this->getTextFromConfig($type, 'ended_at', 'ended_date');
if (! empty($translation)) {
return $translation;
}
return 'recurring.last_issued';
}
protected function getClassStatus($type, $classStatus)
{
if (! empty($classStatus)) {
@ -621,6 +727,21 @@ abstract class Index extends Component
return 'w-3/12 table-title hidden sm:table-cell';
}
protected function getTextCategory($type, $textCategory)
{
if (!empty($textCategory)) {
return $textCategory;
}
$translation = $this->getTextFromConfig($type, 'categories', 'categories', 'trans_choice');
if (!empty($translation)) {
return $translation;
}
return 'general.categories';
}
protected function getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber)
{
if (! empty($classContactNameAndDocumentNumber)) {

View File

@ -7,56 +7,116 @@
</x-table.th>
@endif
<x-table.th class="w-4/12 sm:w-3/12">
@stack('stated_at_and_ended_at_th_start')
@if (! $hideStartedAt || ! $hideEndedAt)
<x-table.th class="{{ $classStartedAtAndEndedAt }}">
@stack('stated_at_th_start')
@if (! $hideStartedAt)
<x-slot name="first">
<x-sortablelink column="recurring.started_at" title="{{ trans('general.start_date') }}" />
</x-slot>
@endif
@stack('stated_at_th_end')
@stack('ended_at_th_start')
@if (! $hideEndedAt)
<x-slot name="second">
{{ trans('recurring.last_issued') }}
</x-slot>
@endif
@stack('ended_at_th_end')
</x-table.th>
@endif
@stack('stated_at_and_ended_at_th_end')
@stack('contact_name_and_category_th_start')
@if (! $hideContactName || ! $hideCategory)
<x-table.th class="w-2/12 ltr:pr-6 rtl:pl-6 py-3 ltr:text-left rtl:text-right text-xs font-medium text-black tracking-wider" hidden-mobile>
@stack('contact_name_th_start')
@if (! $hideContactName)
<x-slot name="first">
<x-sortablelink column="contact_name" title="{{ trans_choice($textContactName, 1) }}" />
</x-slot>
@endif
@stack('contact_name_th_end')
@stack('category_th_start')
@if (! $hideCategory)
<x-slot name="second">
<x-sortablelink column="category.name" title="{{ trans_choice('general.categories', 1) }}" />
<x-sortablelink column="category.name" title="{{ trans_choice($textCategory, 1) }}" />
</x-slot>
@endif
@stack('category_th_end')
</x-table.th>
@endif
@stack('contact_name_and_category_th_end')
<x-table.th class="w-4/12 sm:w-3/12">
@stack('status_th_start')
@if (! $hideStatus)
<x-table.th class="{{ $classStatus }}">
@stack('status_th_inside_start')
<x-sortablelink column="recurring.status" title="{{ trans_choice('general.statuses', 1) }}" />
@stack('status_th_inside_end')
</x-table.th>
@endif
@stack('status_th_end')
<x-table.th class="w-2/12" hidden-mobile>
@stack('frequency_and_duration_th_start')
@if (! $hideFrequency || ! $hideDuration)
<x-table.th class="{{ $classFrequencyAndDuration }}" hidden-mobile>
@stack('frequency_th_start')
@if (! $hideFrequency)
<x-slot name="first">
{{ trans('recurring.frequency') }}
</x-slot>
@endif
@stack('frequency_th_end')
@stack('duration_th_start')
@if (! $hideDuration)
<x-slot name="second">
{{ trans('recurring.duration') }}
</x-slot>
@endif
@stack('duration_th_end')
</x-table.th>
@endif
@stack('frequency_and_duration_th_end')
<x-table.th class="w-4/12 sm:w-2/12" kind="amount">
@stack('amount_th_start')
@if (! $hideAmount)
<x-table.th class="{{ $classAmount }}" kind="amount">
@stack('amount_th_inside_start')
<x-sortablelink column="amount" title="{{ trans('general.amount') }}" />
@stack('amount_th_inside_end')
</x-table.th>
@endif
@stack('amount_th_end')
</x-table.tr>
</x-table.thead>
<x-table.tbody>
@foreach($documents as $item)
<x-table.tr href="{{ route($showRoute, $item->id) }}">
@if (! $hideBulkAction)
@if (! $hideBulkAction)
<x-table.td class="ltr:pr-6 rtl:pl-6" hidden-mobile override="class">
<x-index.bulkaction.single id="{{ $item->id }}" name="{{ $item->contact->name }}" />
</x-table.td>
@endif
@endif
<x-table.td class="w-4/12 sm:w-3/12">
@stack('stated_at_and_ended_at_td_start')
@if (! $hideStartedAt || ! $hideEndedAt)
<x-table.td class="{{ $classStartedAtAndEndedAt }}">
@stack('stated_at_td_start')
@if (! $hideStartedAt)
<x-slot name="first" class="font-bold">
<x-date date="{{ $item->recurring->started_at }}" />
</x-slot>
@endif
@stack('stated_at_td_end')
@stack('ended_at_td_start')
@if (! $hideEndedAt)
<x-slot name="second">
@if ($item->recurring->status == 'ended')
@if ($last = $item->recurring->documents->last()?->issued_at)
@ -70,24 +130,55 @@
@endif
@endif
</x-slot>
@endif
@stack('ended_at_td_end')
</x-table.td>
@endif
@stack('stated_at_and_ended_at_td_end')
@stack('contact_name_and_category_td_start')
@if (! $hideContactName || ! $hideCategory)
<x-table.td class="w-2/12" hidden-mobile>
@stack('contact_name_td_start')
@if (! $hideContactName)
<x-slot name="first">
{{ $item->contact_name }}
</x-slot>
@endif
@stack('contact_name_td_end')
@stack('category_td_start')
@if (! $hideCategory)
<x-slot name="second">
<div class="flex items-center">
<x-index.category :model="$item->category" />
</div>
</x-slot>
@endif
@stack('category_td_end')
</x-table.td>
@endif
@stack('contact_name_and_category_td_end')
<x-table.td class="w-4/12 sm:w-3/12">
<x-index.status status="{{ $item->recurring->status }}" background-color="bg-{{ $item->recurring_status_label }}" text-color="text-text-{{ $item->recurring_status_label }}" />
</x-table.td>
@stack('status_td_start')
@if (!$hideStatus)
<x-table.td class="{{ $classStatus }}">
@stack('status_td_inside_start')
<x-show.status
status="{{ $item->recurring->status }}"
background-color="bg-{{ $item->recurring_status_label }}"
text-color="text-text-{{ $item->recurring_status_label }}"
/>
@stack('status_td_inside_end')
</x-table.td>
@endif
@stack('status_td_end')
<x-table.td class="w-2/12" hidden-mobile>
@stack('frequency_and_duration_td_start')
@if (! $hideFrequency || ! $hideDuration)
<x-table.td class="{{ $classFrequencyAndDuration }}" hidden-mobile>
@stack('frequency_td_start')
@if (! $hideFrequency)
<x-slot name="first">
@if ($item->recurring->interval > 1)
<x-tooltip
@ -104,6 +195,11 @@
{{ trans('recurring.' . $item->recurring->frequency) }}
@endif
</x-slot>
@endif
@stack('frequency_td_end')
@stack('duration_td_start')
@if (! $hideDuration)
<x-slot name="second">
@if ($item->recurring->limit_by == 'count')
@if ($item->recurring->limit_count == 0)
@ -115,11 +211,21 @@
{{ trans('recurring.ends_date', ['date' => company_date($item->recurring->limit_date)]) }}
@endif
</x-slot>
@endif
@stack('duration_td_end')
</x-table.td>
@endif
@stack('frequency_and_duration_td_end')
<x-table.td class="w-4/12 sm:w-2/12" kind="amount">
@stack('amount_td_start')
@if (! $hideAmount)
<x-table.td class="{{ $classAmount }}" kind="amount">
@stack('amount_td_inside_start')
<x-money :amount="$item->amount" :currency="$item->currency_code" />
@stack('amount_td_inside_end')
</x-table.td>
@endif
@stack('amount_td_end')
<x-table.td kind="action">
<x-table.actions :model="$item" />