Fixes for default sort order in Client Portal

This commit is contained in:
David Bomba 2025-03-31 11:04:51 +11:00
parent 7fa7d5349a
commit 2d562b0d6e
5 changed files with 20 additions and 3 deletions

View File

@ -34,6 +34,12 @@ class CreditsTable extends Component
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
$this->sort_field = 'date';
}
public function render()

View File

@ -55,7 +55,7 @@ class InvoicesTable extends Component
$q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc'));
})
->when($this->sort_field != 'number', function ($q){
$q->orderBy($this->sort_field, ($this->sort_asc ? 'desc' : 'asc'));
$q->orderBy($this->sort_field, ($this->sort_asc ? 'asc' : 'desc'));
});
// ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc');

View File

@ -33,6 +33,10 @@ class PaymentsTable extends Component
public function mount()
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
$this->sort_field = 'date';
}
public function render()

View File

@ -37,6 +37,10 @@ class QuotesTable extends Component
public function mount()
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
$this->sort_field = 'date';
}
@ -55,10 +59,10 @@ class QuotesTable extends Component
->with('client.contacts', 'company')
// ->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc');
->when($this->sort == 'number', function ($q){
$q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc'));
$q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'asc' : 'desc'));
})
->when($this->sort != 'number', function ($q){
$q->orderBy($this->sort, ($this->sort_asc ? 'desc' : 'asc'));
$q->orderBy($this->sort, ($this->sort_asc ? 'asc' : 'desc'));
});

View File

@ -32,6 +32,9 @@ class TasksTable extends Component
public function mount()
{
MultiDB::setDb($this->db);
$this->sort_asc = false;
}
public function render()