close #3215 Enhancement: Transaction list page add default tab feature
This commit is contained in:
parent
bd0521a5c3
commit
cd3ed95bcf
|
|
@ -136,4 +136,21 @@ abstract class Controller extends BaseController
|
|||
request()->offsetSet('list_records', 'all');
|
||||
}
|
||||
}
|
||||
|
||||
public function setActiveTabForTransactions(): void
|
||||
{
|
||||
// Added this method to set the active tab for transactions
|
||||
if (! request()->has('list_records') && ! request()->has('search')) {
|
||||
$tab_pins = setting('favorites.tab.' . user()->id, []);
|
||||
$tab_pins = json_decode($tab_pins, true);
|
||||
|
||||
if (! empty($tab_pins) && ! empty($tab_pins['transactions'])) {
|
||||
$data = config('type.transaction.transactions.route.params.' . $tab_pins['transactions']);
|
||||
|
||||
if (! empty($data)) {
|
||||
request()->merge($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ abstract class Index extends Component
|
|||
/** @var string */
|
||||
public $classBulkAction;
|
||||
|
||||
/** @var string */
|
||||
public $tabActive;
|
||||
|
||||
/** @var string */
|
||||
public $tabSuffix;
|
||||
|
||||
public $hidePaymentMethod;
|
||||
|
||||
public $hidePaidAt;
|
||||
|
|
@ -174,6 +180,7 @@ abstract class Index extends Component
|
|||
bool $hideSummary = false, array $summaryItems = [],
|
||||
bool $hideSearchString = false, bool $hideBulkAction = false,
|
||||
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '', string $classBulkAction = '',
|
||||
string $tabActive = '', string $tabSuffix = '',
|
||||
bool $hidePaymentMethod = false,
|
||||
bool $hidePaidAt = false, bool $hideNumber = false, string $classPaidAtAndNumber = '', string $textPaidAt = '', string $textNumber = '',
|
||||
bool $hideStartedAt = false, bool $hideEndedAt = false, string $classStartedAtAndEndedAt = '', string $textStartedAt = '', string $textEndedAt = '',
|
||||
|
|
@ -240,9 +247,11 @@ abstract class Index extends Component
|
|||
|
||||
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
|
||||
|
||||
$this->tabSuffix = $this->getTabSuffix($type, $tabSuffix);
|
||||
$this->tabActive = $this->getTabActive($type, $tabActive);
|
||||
|
||||
$this->hidePaymentMethod = $hidePaymentMethod;
|
||||
|
||||
|
||||
/* Document Start */
|
||||
$this->hidePaidAt = $hidePaidAt;
|
||||
$this->hideNumber = $hideNumber;
|
||||
|
|
@ -443,6 +452,42 @@ abstract class Index extends Component
|
|||
return [];
|
||||
}
|
||||
|
||||
public function getTabActive($type, $tabActive)
|
||||
{
|
||||
if (! empty($tabActive)) {
|
||||
return $tabActive;
|
||||
}
|
||||
|
||||
$search_type = $type == 'income-recurring' ? 'recurring-transactions' : search_string_value('type');
|
||||
|
||||
return ($this->tabSuffix) ? 'transactions-' . $this->tabSuffix : $search_type;
|
||||
}
|
||||
|
||||
public function getTabSuffix($type, $tabSuffix)
|
||||
{
|
||||
if (! empty($tabSuffix)) {
|
||||
return $tabSuffix;
|
||||
}
|
||||
|
||||
$search_type = $type == 'income-recurring' ? 'recurring-transactions' : search_string_value('type');
|
||||
|
||||
if ($search_type == 'income') {
|
||||
return 'income';
|
||||
}
|
||||
|
||||
if ($search_type == 'expense') {
|
||||
return 'expense';
|
||||
}
|
||||
|
||||
$suffix = $this->getTabActiveFromSetting($type);
|
||||
|
||||
if (! empty($suffix)) {
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
return 'all';
|
||||
}
|
||||
|
||||
protected function getClassPaidAtAndNumber($type, $classPaidAtAndNumber)
|
||||
{
|
||||
if (! empty($classPaidAtAndNumber)) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ class Transactions extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->setActiveTabForTransactions();
|
||||
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$total_transactions = Transaction::count();
|
||||
|
|
|
|||
|
|
@ -318,6 +318,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -344,6 +349,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -370,6 +380,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -396,6 +411,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -421,6 +441,11 @@ return [
|
|||
'prefix' => 'recurring-transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'recurring_transaction', // banking/recurring-transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -449,6 +474,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -474,6 +504,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -499,6 +534,11 @@ return [
|
|||
'prefix' => 'transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'transaction', // banking/transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
@ -523,6 +563,11 @@ return [
|
|||
'prefix' => 'recurring-transactions', // core use with group + prefix, module ex. estimates
|
||||
'parameter' => 'recurring_transaction', // banking/recurring-transactions/{parameter}/edit
|
||||
//'create' => 'transactions.create', // if you change route, you can write full path
|
||||
'params' => [
|
||||
'income' => ['search' => 'type:income'],
|
||||
'expense' => ['search' => 'type:expense'],
|
||||
'all' => ['list_records' => 'all'],
|
||||
],
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'transactions',
|
||||
|
|
|
|||
|
|
@ -32,24 +32,57 @@
|
|||
$active_tab = empty($search_type) ? 'transactions' : (($search_type == 'income') ? 'transactions-income' : (($search_type == 'expense') ? 'transactions-expense' : 'recurring-templates'));
|
||||
@endphp
|
||||
|
||||
<x-tabs active="{{ $active_tab }}">
|
||||
<x-tabs active="{{ $tabActive }}">
|
||||
<x-slot name="navs">
|
||||
@if ($search_type == 'income')
|
||||
<x-tabs.nav id="transactions-income" name="{{ trans_choice('general.incomes', 1) }}" active />
|
||||
@if ($tabActive == $type . '-income')
|
||||
<x-tabs.nav-pin
|
||||
id="transactions-income"
|
||||
name="{{ trans_choice('general.incomes', 1) }}"
|
||||
type="transactions"
|
||||
tab="income"
|
||||
/>
|
||||
@else
|
||||
<x-tabs.nav-link id="transactions-income" name="{{ trans_choice('general.incomes', 1) }}" href="{{ route('transactions.index', ['search' => 'type:income']) }}" />
|
||||
<x-tabs.nav-pin
|
||||
id="transactions-income"
|
||||
href="{{ route('transactions.index', ['search' => 'type:income']) }}"
|
||||
name="{{ trans_choice('general.incomes', 1) }}"
|
||||
type="transactions"
|
||||
tab="income"
|
||||
/>
|
||||
@endif
|
||||
|
||||
@if ($search_type == 'expense')
|
||||
<x-tabs.nav id="transactions-expense" name="{{ trans_choice('general.expenses', 1) }}" active />
|
||||
@if ($tabActive == $type . '-expense')
|
||||
<x-tabs.nav-pin
|
||||
id="transactions-expense"
|
||||
name="{{ trans_choice('general.expenses', 1) }}"
|
||||
type="transactions"
|
||||
tab="expense"
|
||||
/>
|
||||
@else
|
||||
<x-tabs.nav-link id="transactions-expense" name="{{ trans_choice('general.expenses', 1) }}" href="{{ route('transactions.index', ['search' => 'type:expense']) }}" />
|
||||
<x-tabs.nav-pin
|
||||
id="transactions-expense"
|
||||
href="{{ route('transactions.index', ['search' => 'type:expense']) }}"
|
||||
name="{{ trans_choice('general.expenses', 1) }}"
|
||||
type="transactions"
|
||||
tab="expense"
|
||||
/>
|
||||
@endif
|
||||
|
||||
@if (empty($search_type))
|
||||
<x-tabs.nav id="transactions" name="{{ trans('general.all_type', ['type' => trans_choice('general.transactions', 2)]) }}" active />
|
||||
@if ($tabActive == $type . '-all')
|
||||
<x-tabs.nav-pin
|
||||
id="transactions"
|
||||
name="{{ trans('general.all_type', ['type' => trans_choice('general.transactions', 2)]) }}"
|
||||
type="transactions"
|
||||
tab="all"
|
||||
/>
|
||||
@else
|
||||
<x-tabs.nav-link id="transactions" name="{{ trans('general.all_type', ['type' => trans_choice('general.transactions', 2)]) }}" href="{{ route('transactions.index') }}" />
|
||||
<x-tabs.nav-pin
|
||||
id="transactions"
|
||||
href="{{ route('transactions.index', ['list_records' => 'all']) }}"
|
||||
name="{{ trans('general.all_type', ['type' => trans_choice('general.transactions', 2)]) }}"
|
||||
type="transactions"
|
||||
tab="all"
|
||||
/>
|
||||
@endif
|
||||
|
||||
<x-tabs.nav-link id="recurring-templates" name="{{ trans_choice('general.recurring_templates', 2) }}" href="{{ route('recurring-transactions.index') }}" />
|
||||
|
|
@ -77,8 +110,8 @@
|
|||
/>
|
||||
@endif
|
||||
|
||||
@if ($active_tab != 'recurring-templates')
|
||||
<x-tabs.tab id="{{ $active_tab }}">
|
||||
@if ($tabActive != 'recurring-templates')
|
||||
<x-tabs.tab id="{{ $tabActive }}">
|
||||
<x-transactions.index.transaction :type="$type" :transactions="$transactions" />
|
||||
</x-tabs.tab>
|
||||
@else
|
||||
|
|
|
|||
Loading…
Reference in New Issue