add function to manage table columns
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Froxlor\Ajax;
|
||||
use Exception;
|
||||
use Froxlor\Http\HttpClient;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Listing;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
|
||||
@@ -107,6 +108,8 @@ class Ajax
|
||||
return $this->getUpdateCheck();
|
||||
case 'searchglobal':
|
||||
return $this->searchGlobal();
|
||||
case 'tablelisting':
|
||||
return $this->updateTablelisting();
|
||||
default:
|
||||
return $this->errorResponse('Action not found!');
|
||||
}
|
||||
@@ -236,4 +239,16 @@ class Ajax
|
||||
header("Content-type: application/json");
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
private function updateTablelisting()
|
||||
{
|
||||
$columns = [];
|
||||
foreach (Request::get('columns') as $requestedColumn => $value) {
|
||||
$columns[] = $requestedColumn;
|
||||
}
|
||||
|
||||
Listing::storeColumnListingForUser([Request::get('listing') => $columns]);
|
||||
|
||||
return json_encode($columns);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,13 @@ use Froxlor\CurrentUser;
|
||||
*/
|
||||
class Listing
|
||||
{
|
||||
public static function format(Collection $collection, array $tabellisting): array
|
||||
public static function format(Collection $collection, array $tabellisting, string $id): array
|
||||
{
|
||||
$tabellisting = $tabellisting[$id];
|
||||
$collection_data = $collection->get();
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'title' => $tabellisting['title'],
|
||||
'description' => $tabellisting['description'] ?? null,
|
||||
'icon' => $tabellisting['icon'] ?? null,
|
||||
@@ -186,7 +188,10 @@ class Listing
|
||||
$result = [];
|
||||
if (isset($tabellisting['columns'])) {
|
||||
foreach ($tabellisting['columns'] as $column => $coldata) {
|
||||
$result[$column] = $coldata['label'];
|
||||
$result[$column] = [
|
||||
'label' => $coldata['label'],
|
||||
'checked' => in_array($column, $tabellisting['visible_columns']),
|
||||
];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
@@ -29,6 +29,11 @@ return [
|
||||
'icon' => 'fa-solid fa-user',
|
||||
'self_overview' => ['section' => 'customers', 'page' => 'customers'],
|
||||
'columns' => [
|
||||
'c.customerid' => [
|
||||
'label' => 'ID',
|
||||
'field' => 'customerid',
|
||||
'sortable' => true,
|
||||
],
|
||||
'c.name' => [
|
||||
'label' => $lng['customer']['name'],
|
||||
'field' => 'name',
|
||||
|
||||
@@ -28,6 +28,11 @@ return [
|
||||
'empty_msg' => $lng['admin']['domain_nocustomeraddingavailable'],
|
||||
'self_overview' => ['section' => 'domains', 'page' => 'domains'],
|
||||
'columns' => [
|
||||
'd.id' => [
|
||||
'label' => 'ID',
|
||||
'field' => 'id',
|
||||
'sortable' => true,
|
||||
],
|
||||
'd.domain_ace' => [
|
||||
'label' => $lng['domains']['domainname'],
|
||||
'field' => 'domain_ace',
|
||||
|
||||
Reference in New Issue
Block a user