Skip to content

Commit

Permalink
feat: moved layoutbar to editor (#193)
Browse files Browse the repository at this point in the history
* feat: moved layoutbar to editor

* style: formatting

* chore: remove unused methods

---------

Co-authored-by: Rene <[email protected]>
  • Loading branch information
keeama13 and 64knl authored Feb 1, 2024
1 parent 0725069 commit 977377f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
19 changes: 2 additions & 17 deletions src/Http/Controllers/Assets/TableOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use NotFound\Framework\Services\Assets\TableQueryService;
use NotFound\Framework\Services\Assets\TableService;
use NotFound\Layout\Elements\LayoutBar;
use NotFound\Layout\Elements\LayoutBarButton;
use NotFound\Layout\Elements\LayoutPage;
use NotFound\Layout\Elements\LayoutPager;
use NotFound\Layout\Elements\LayoutSearchBox;
Expand Down Expand Up @@ -76,22 +75,8 @@ public function index(Request $request, Table $table)

$page->addBreadCrumb($editor->getBreadCrumbs());

$bar = new LayoutBar();
$bottomBar = new LayoutBar();
$bottomBar->noBackground();

if ($table->allow_create) {
$addNew = new LayoutBarButton('Nieuw');
$addNew->setIcon('plus');
$url = '/table/'.$table->url.'/0';
if ($params = $editor->filterToParams());

$url .= '?'.ltrim($params, '&');

$addNew->setLink($url);
$bar->addBarButton($addNew);
$bottomBar->addBarButton($addNew);
}
$bar = $editor->getBar();
$bottomBar = $editor->getBottomBar();

$pager = new LayoutPager(totalItems: $siteTableRowsPaginator->total(), itemsPerPage: request()->query('pitems') ?? $table->properties->itemsPerPage ?? 25);
$bar->addPager($pager);
Expand Down
45 changes: 24 additions & 21 deletions src/Models/Editor/AbstractEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace NotFound\Framework\Models\Editor;

use NotFound\Framework\Services\Assets\TableService;
use NotFound\Layout\Elements\LayoutBar;
use NotFound\Layout\Elements\LayoutBarButton;
use NotFound\Layout\Elements\LayoutBreadcrumb;

abstract class AbstractEditor
Expand All @@ -12,39 +14,40 @@ public function __construct(protected TableService $ts)

}

/**
* preOverview
*
* Runs before the overview is rendered
*/
public function preOverview(): void
public function getBar(): LayoutBar
{
$bar = new LayoutBar();

}

public function postOverview(): void
{

}

public function preEdit(): void
{

}
$table = $this->ts->getAssetModel();

public function postEdit(): void
{
if ($table->allow_create) {
$addNew = $this->getNewButton();
$bar->addBarButton($addNew);
}

return $bar;
}

public function preCreate(): void
public function getBottomBar(): LayoutBar
{
$bottomBar = $this->getBar();
$bottomBar->noBackground();

return $bottomBar;
}

public function postCreate(): void
public function getNewButton(): LayoutBarButton
{
$addNew = new LayoutBarButton('Nieuw');
$table = $this->ts->getAssetModel();
$addNew->setIcon('plus');
$url = '/table/'.$table->url.'/0';
if ($params = $this->filterToParams()) {
$url .= '?'.ltrim($params, '&');
}
$addNew->setLink($url);

return $addNew;
}

public function getBreadCrumbs(): LayoutBreadCrumb
Expand Down

0 comments on commit 977377f

Please sign in to comment.