format href to link if it is a linker array
This commit is contained in:
@@ -82,9 +82,11 @@ class Listing
|
|||||||
|
|
||||||
// Set all actions for row
|
// Set all actions for row
|
||||||
if (isset($tabellisting['actions'])) {
|
if (isset($tabellisting['actions'])) {
|
||||||
|
$actions = self::setLinks($tabellisting['actions'], $item);
|
||||||
|
|
||||||
$rows[$key]['action'] = [
|
$rows[$key]['action'] = [
|
||||||
'type' => 'actions',
|
'type' => 'actions',
|
||||||
'data' => $tabellisting['actions'],
|
'data' => $actions
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +94,31 @@ class Listing
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function setLinks($actions, array $item)
|
||||||
|
{
|
||||||
|
$linker = UI::getLinker();
|
||||||
|
|
||||||
|
// Check each action for a href
|
||||||
|
foreach ($actions as $key => $action) {
|
||||||
|
// Set link if href is an array
|
||||||
|
if (isset($action['href']) && is_array($action['href'])) {
|
||||||
|
// Search for "columns" in our href array
|
||||||
|
foreach ($action['href'] as $href_key => $href_value) {
|
||||||
|
$length = strlen(':');
|
||||||
|
if (substr($href_value, 0, $length) === ':') {
|
||||||
|
$column = ltrim($href_value, ':');
|
||||||
|
$action['href'][$href_key] = $item[$column];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set actual link from linker
|
||||||
|
$actions[$key]['href'] = $linker->getLink($action['href']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getVisibleColumnsForListing($listing, $default_columns)
|
public static function getVisibleColumnsForListing($listing, $default_columns)
|
||||||
{
|
{
|
||||||
// Hier käme dann die Logik, die das aus der DB zieht ...
|
// Hier käme dann die Logik, die das aus der DB zieht ...
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Froxlor\UI\Panel;
|
namespace Froxlor\UI\Panel;
|
||||||
|
|
||||||
|
use Froxlor\UI\Linker;
|
||||||
|
|
||||||
class UI
|
class UI
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -217,7 +219,7 @@ class UI
|
|||||||
self::$linker = $linker;
|
self::$linker = $linker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLinker()
|
public static function getLinker(): Linker
|
||||||
{
|
{
|
||||||
return self::$linker;
|
return self::$linker;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,11 +66,21 @@ return [
|
|||||||
'actions' => [
|
'actions' => [
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'icon' => 'fa fa-trash',
|
'icon' => 'fa fa-trash',
|
||||||
'href' => '#',
|
'href' => [
|
||||||
|
'section' => 'admins',
|
||||||
|
'page' => 'admins',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':adminid'
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'edit' => [
|
'edit' => [
|
||||||
'text' => 'Edit',
|
'text' => 'Edit',
|
||||||
'href' => '#',
|
'href' => [
|
||||||
|
'section' => 'admins',
|
||||||
|
'page' => 'admins',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':adminid'
|
||||||
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'contextual_class' => [
|
'contextual_class' => [
|
||||||
|
|||||||
@@ -65,5 +65,25 @@ return [
|
|||||||
'c.diskspace',
|
'c.diskspace',
|
||||||
'c.traffic',
|
'c.traffic',
|
||||||
]),
|
]),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => [
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'customers',
|
||||||
|
'page' => 'customers',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':customerid'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'text' => 'Edit',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'customers',
|
||||||
|
'page' => 'customers',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':customerid'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -57,11 +57,37 @@ return [
|
|||||||
'actions' => [
|
'actions' => [
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'icon' => 'fa fa-trash',
|
'icon' => 'fa fa-trash',
|
||||||
'href' => '#',
|
'href' => [
|
||||||
|
'section' => 'domains',
|
||||||
|
'page' => 'domains',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'edit' => [
|
'edit' => [
|
||||||
'icon' => 'fa fa-edit',
|
'text' => 'Edit',
|
||||||
'href' => '#',
|
'href' => [
|
||||||
|
'section' => 'domains',
|
||||||
|
'page' => 'domains',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'logfiles' => [
|
||||||
|
'icon' => 'fa fa-file',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'domains',
|
||||||
|
'page' => 'logfiles',
|
||||||
|
'domain_id' => ':id'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'domaindnseditor' => [
|
||||||
|
'icon' => 'fa fa-globe',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'domains',
|
||||||
|
'page' => 'domaindnseditor',
|
||||||
|
'domain_id' => ':id'
|
||||||
|
],
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="row mb-1">
|
<div class="row mb-1">
|
||||||
<div class="col text-truncate">{{ lng(lngstr) }}</div>
|
<div class="col text-truncate">{{ lng(lngstr) }}</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<small>{% if formatbytes %}{{ used|formatBytes }}{% else %}{{ used }}{% endif %}/{% if available < 0 %}{{ lng('customer.unlimited') }}{% else %}{% if formatbytes %}{{ available|formatBytes }}{% else %}{{ available }}{% endif %}{% endif %}</small>
|
<small>{% if formatbytes %}{{ used|formatBytes }}{% else %}{{ used }}{% endif %}/{% if available < 0 %}{{ lng('panel.unlimited') }}{% else %}{% if formatbytes %}{{ available|formatBytes }}{% else %}{{ available }}{% endif %}{% endif %}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress progress-thin my-auto">
|
<div class="progress progress-thin my-auto">
|
||||||
|
|||||||
Reference in New Issue
Block a user