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

Move navigation to settings #77

Merged
merged 1 commit into from
Feb 6, 2020
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
41 changes: 10 additions & 31 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,6 @@ public function boot()
$this->app->register(ServiceProvider::class);
}

/**
* @return array
*/
public function registerNavigation()
{
return [
'dynamicpdf' => [
'label' => 'renatio.dynamicpdf::lang.menu.label',
'url' => Backend::url('renatio/dynamicpdf/templates'),
'icon' => 'icon-file-pdf-o',
'permissions' => ['renatio.dynamicpdf.*'],
'order' => 500,
'sideMenu' => [
'templates' => [
'label' => 'renatio.dynamicpdf::lang.templates.templates',
'icon' => 'icon-file-text-o',
'url' => Backend::url('renatio/dynamicpdf/templates'),
'permissions' => ['renatio.dynamicpdf.manage_templates'],
],
'layouts' => [
'label' => 'renatio.dynamicpdf::lang.templates.layouts',
'icon' => 'icon-th-large',
'url' => Backend::url('renatio/dynamicpdf/layouts'),
'permissions' => ['renatio.dynamicpdf.manage_layouts'],
]
]
]
];
}

/**
* @return array
*/
Expand Down Expand Up @@ -105,7 +75,16 @@ public function registerMarkupTags()
*/
public function registerSettings()
{
return [];
return [
'templates' => [
'category' => 'renatio.dynamicpdf::lang.menu.label',
'label' => 'renatio.dynamicpdf::lang.templates.templates',
'icon' => 'icon-file-text-o',
'url' => Backend::url('renatio/dynamicpdf/templates'),
'description' => '',
'permissions' => ['renatio.dynamicpdf.manage_templates'],
],
];
}

}
4 changes: 3 additions & 1 deletion controllers/Layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Backend\Facades\BackendMenu;
use October\Rain\Exception\ApplicationException;
use Renatio\DynamicPDF\Classes\PDF;
use System\Classes\SettingsManager;

/**
* Class Layouts
Expand Down Expand Up @@ -46,7 +47,8 @@ public function __construct()
{
parent::__construct();

BackendMenu::setContext('Renatio.DynamicPDF', 'dynamicpdf', 'layouts');
BackendMenu::setContext('October.System', 'system', 'settings');
SettingsManager::setContext('Renatio.DynamicPDF', 'layouts');
}

/**
Expand Down
18 changes: 16 additions & 2 deletions controllers/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Backend\Facades\BackendMenu;
use October\Rain\Exception\ApplicationException;
use Renatio\DynamicPDF\Classes\PDF;
use System\Classes\SettingsManager;

/**
* Class Templates
Expand Down Expand Up @@ -35,13 +36,26 @@ class Templates extends Controller
/**
* @var string
*/
public $listConfig = 'config_list.yaml';
//public $listConfig = 'config_list.yaml';

public $listConfig = [
'templates' => 'config_list.yaml',
'layouts' => '$/renatio/dynamicpdf/controllers/layouts/config_list.yaml',
];

public function __construct()
{
parent::__construct();

BackendMenu::setContext('Renatio.DynamicPDF', 'dynamicpdf', 'templates');
BackendMenu::setContext('October.System', 'system', 'settings');
SettingsManager::setContext('Renatio.DynamicPDF', 'templates');
}

public function index($tab = null)
{
$this->asExtension('ListController')->index();
$this->bodyClass = 'compact-container';
$this->vars['activeTab'] = $tab ?: 'templates';
}

/**
Expand Down
8 changes: 4 additions & 4 deletions controllers/layouts/config_form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ form: $/renatio/dynamicpdf/models/layout/fields.yaml
modelClass: Renatio\DynamicPDF\Models\Layout

# Default redirect location
defaultRedirect: renatio/dynamicpdf/layouts
defaultRedirect: renatio/dynamicpdf/index/layouts

# Create page
create:
title: renatio.dynamicpdf::lang.layout.create_layout
redirect: renatio/dynamicpdf/layouts/update/:id
redirectClose: renatio/dynamicpdf/layouts
redirectClose: renatio/dynamicpdf/index/layouts

# Update page
update:
title: renatio.dynamicpdf::lang.layout.edit_layout
redirect: renatio/dynamicpdf/layouts
redirectClose: renatio/dynamicpdf/layouts
redirect: renatio/dynamicpdf/index/layouts
redirectClose: renatio/dynamicpdf/index/layouts

# Preview page
preview:
Expand Down
6 changes: 3 additions & 3 deletions controllers/layouts/update.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<ul>
<li>
<a href="<?= Backend::url('renatio/dynamicpdf/layouts') ?>">
<a href="<?= Backend::url('renatio/dynamicpdf/index/layouts') ?>">
<?= e(trans('renatio.dynamicpdf::lang.layouts.label')) ?>
</a>
</li>
Expand Down Expand Up @@ -62,7 +62,7 @@

<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?>
<a href="<?= Backend::url('renatio/dynamicpdf/layouts') ?>">
<a href="<?= Backend::url('renatio/dynamicpdf/index/layouts') ?>">
<?= e(trans('backend::lang.form.cancel')) ?>
</a>
</span>
Expand All @@ -85,7 +85,7 @@

<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<p>
<a href="<?= Backend::url('renatio/dynamicpdf/layouts') ?>"
<a href="<?= Backend::url('renatio/dynamicpdf/index/layouts') ?>"
class="btn btn-default">
<?= e(trans('renatio.dynamicpdf::lang.layouts.return')) ?>
</a>
Expand Down
23 changes: 22 additions & 1 deletion controllers/templates/index.htm
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
<?= $this->listRender() ?>
<div class="control-tabs content-tabs tabs-flush" data-control="tab">
<ul class="nav nav-tabs">
<li class="<?= $activeTab == 'templates' ? 'active' : '' ?>">
<a href="#templates" data-tab-url="<?= Backend::url('renatio/dynamicpdf/index/templates') ?>">
<?= e(trans('renatio.dynamicpdf::lang.templates.templates')) ?>
</a>
</li>
<li class="<?= $activeTab == 'layouts' ? 'active' : '' ?>">
<a href="#layouts" data-tab-url="<?= Backend::url('renatio/dynamicpdf/index/layouts') ?>">
<?= e(trans('renatio.dynamicpdf::lang.templates.layouts')) ?>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane <?= $activeTab == 'templates' ? 'active' : '' ?>">
<?= $this->listRender('templates') ?>
</div>
<div class="tab-pane <?= $activeTab == 'layouts' ? 'active' : '' ?>">
<?= $this->listRender('layouts') ?>
</div>
</div>
</div>