Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #82 from distantnative/patch-1
Browse files Browse the repository at this point in the history
Kirby 3.7. compatibility
  • Loading branch information
sylvainjule authored Aug 3, 2022
2 parents c31b134 + 62c2458 commit 5999d8e
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 111 deletions.
22 changes: 13 additions & 9 deletions lib/pagetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
}
),
'computed' => array(
'columns' => function () {
return $this->columns;
},
'translations' => function() {
$translations = $this->translations;
$keys = array_keys($translations);
Expand Down Expand Up @@ -112,7 +115,6 @@
if ($this->sortBy) {
$pages = $pages->sortBy(...Str::split($this->sortBy, ' '));
}

return $pages;
},
'total' => function () {
Expand Down Expand Up @@ -148,7 +150,7 @@
};

// loop through the user display choices
foreach($this->columns as $key => $column) {
foreach($this->columns() as $key => $column) {
$sortable = $column['sortable'] ?? true;
$searchable = $column['searchable'] ?? true;
$mobile = $column['mobile'] ?? false;
Expand Down Expand Up @@ -215,6 +217,7 @@
$optionsClass = 'pagetable-options-one';
}


// last column is always the options
$data['columns'][] = array(
'label' => '',
Expand All @@ -228,25 +231,24 @@

foreach ($this->pages as $item) {
$permissions = $item->permissions();
$blueprint = $item->blueprint();
$image = $item->panelImage($this->image ?? []);
$panel = $item->panel();
$image = $panel->image($this->image ?? []);
$url = false;
if($this->url == 'panel') {
$url = $item->panel()->url(true);
$url = $panel->url(true);
}
if($this->url == 'preview') {
$url = $item->previewUrl();
}

$baseOptions = [
'id' => $item->id(),
'dragText' => $item->dragText('auto', $this->dragTextType),
'dragText' => $panel->dragText('auto', $this->dragTextType),
'text' => $item->toString($this->text),
'info' => $item->toString($this->info ?? false),
'parent' => $item->parentId(),
'icon' => $item->panelIcon($image),
'image' => $image,
'link' => $item->panel()->url(true),
'link' => $panel->url(true),
'rowLink' => $url,
'status' => $item->status(),
'permissions' => [
Expand All @@ -257,14 +259,16 @@

$userOptions = [];
// loop through the user display choices
foreach($this->columns as $key => $column) {
foreach($this->columns() as $key => $column) {
$userOptions[$key] = $item->toString($column['text']);
}

$options = array_merge_recursive($baseOptions, $userOptions);

$data['rows'][] = $options;
}


return $data;
},
),
Expand Down
Loading

0 comments on commit 5999d8e

Please sign in to comment.