Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: moved layoutbar to editor #193

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading