Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
069f31d
Added support for pre/post appending view paths
jaxwilko Feb 17, 2025
f3706b8
Added default view files for forms and lists behaviours
jaxwilko Feb 17, 2025
67ef0eb
Added --stubs option to create controller command
jaxwilko Feb 17, 2025
22d04ef
Added code styling fixes
jaxwilko Feb 17, 2025
3feecb6
Added fix for hardcoded link
jaxwilko Feb 17, 2025
8b65ce0
Update modules/backend/behaviors/listcontroller/_list_toolbar.php
LukeTowers Feb 17, 2025
41f1fb5
Added support for default reorder views
jaxwilko Feb 17, 2025
4a2760b
Merge branch 'wip/behaviour-default-views' of github.com:wintercms/wi…
jaxwilko Feb 17, 2025
8f216a2
Added support for import export behaviour defaults
jaxwilko Feb 18, 2025
fe85e22
Added default value for bodyClass
jaxwilko Feb 18, 2025
b77d283
Added self generating breadcrumb partial
jaxwilko Feb 18, 2025
b0bbed0
Added default partials for behaviours
jaxwilko Feb 18, 2025
0807dd4
Added self generating breadcumb for controller stubs
jaxwilko Feb 18, 2025
cae7704
Added import export lang keys
jaxwilko Feb 18, 2025
2a13527
Added fix for code styling
jaxwilko Feb 18, 2025
2f616e0
Added fixes for reorder partials
jaxwilko Feb 18, 2025
5102170
Move controllerbehavior default views to /views
LukeTowers Feb 21, 2025
606fe64
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers Feb 26, 2025
3fe07ef
Update modules/backend/behaviors/reordercontroller/views/reorder.php
LukeTowers Feb 26, 2025
41f643b
Switch to new prependViewPath() method
LukeTowers Feb 26, 2025
5d0b9ca
Automatically set BackendMenu context from controller path
LukeTowers Feb 26, 2025
e0e6cb9
Tweaks to the default views based on migrating Winter.Blog
LukeTowers Feb 27, 2025
d6449e8
Improve breadcrumb generation logic to take into account settings con…
LukeTowers Mar 5, 2025
b4c66d6
Update the changemonitor status after the AJAX requests complete
LukeTowers Mar 5, 2025
143dfe4
Add top padding to form buttons container & remove buttons from the s…
LukeTowers Mar 5, 2025
fced797
Remove unnecessary backend controller views
LukeTowers Mar 5, 2025
ce48714
Add localized "or" string
LukeTowers Mar 5, 2025
8689e40
Add data-browser-validate to all form saving buttons
LukeTowers Mar 5, 2025
5de7bd7
add missing delete button to sidebar layout update view
mjauvin Mar 15, 2025
bc7e493
no need for two links with the same url
mjauvin Mar 15, 2025
3d77eaf
Merge branch 'develop' into wip/behaviour-default-views
mjauvin May 1, 2025
077d4c4
do not show "delete selected" button if the list does not show the re…
mjauvin May 6, 2025
acc69e8
add cancel button in default fancy toolbar
mjauvin May 6, 2025
e7032e8
remove extra space after closing parenthesis
mjauvin May 6, 2025
fe0abe7
Update modules/backend/behaviors/listcontroller/views/_list_toolbar.php
LukeTowers May 6, 2025
0512f13
Merge branch 'develop' into wip/behaviour-default-views
mjauvin May 9, 2025
f511992
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers May 9, 2025
8ec2466
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers May 10, 2025
a36b3e0
Extract create/update form buttons into their own partials (#1352)
mjauvin May 10, 2025
451f4f9
Use toolbar partial
LukeTowers May 10, 2025
22ab21e
Update update.stub
LukeTowers May 10, 2025
3732260
Update create.stub
LukeTowers May 10, 2025
76b833c
Update update.stub
LukeTowers May 10, 2025
9bbdfa5
add reorder button on default list toolbar
mjauvin May 10, 2025
33e1d3b
fix icon class
mjauvin May 10, 2025
3cff2dc
only add create button if FormController is used
mjauvin May 10, 2025
777a556
use more appropriate reorder icon
mjauvin May 10, 2025
0776b98
use arrows-up-down icon for reorder action
mjauvin May 10, 2025
ee943fd
Merge branch 'develop' into wip/behaviour-default-views
mjauvin May 19, 2025
a735dce
Merge branch 'develop' into wip/behaviour-default-views
mjauvin May 19, 2025
606bf14
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers May 28, 2025
c5fc31b
Add buttons for import export behavior to list default toolbar when b…
LukeTowers May 28, 2025
0d7e874
Add support for abort(403) in the backend
LukeTowers May 28, 2025
e24f395
Improve abort(404) handling in the backend
LukeTowers May 28, 2025
8eb44e9
Add icons to the default form buttons
LukeTowers Jun 18, 2025
4993443
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers Jun 18, 2025
fe10d42
Add missing buttons and icons to the form fancy toolbars
LukeTowers Jun 18, 2025
8d6bd7b
Fix disabled styling for outside tab fields in the fancy form layout
LukeTowers Jun 18, 2025
ddf26db
Improve handling of layouts in the controller scaffolding command
LukeTowers Jun 18, 2025
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
5 changes: 5 additions & 0 deletions modules/backend/behaviors/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public function __construct($controller)
*/
$this->config = $this->makeConfig($controller->formConfig ?: $this->formConfig, $this->requiredConfig);
$this->config->modelClass = Str::normalizeClassName($this->config->modelClass);

/*
* Set default view path
*/
$this->controller->appendViewPath($this->guessViewPath());
}

/**
Expand Down
5 changes: 5 additions & 0 deletions modules/backend/behaviors/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public function __construct($controller)
* Build configuration
*/
$this->setConfig($this->listDefinitions[$this->primaryDefinition], $this->requiredConfig);

/*
* Set default view path
*/
$this->controller->appendViewPath($this->guessViewPath());
}

/**
Expand Down
47 changes: 47 additions & 0 deletions modules/backend/behaviors/formcontroller/create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
$formController = $this->getClassExtension(\Backend\Behaviors\FormController::class);
$formConfig = $formController->getConfig();
?>

<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans($formConfig->name . '_plural')); ?></a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>

<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>

<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="button"
data-request="onSave"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.creating_name', ['name' => trans($formConfig->name)])); ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.create')); ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.creating_name', ['name' => trans($formConfig->name)])); ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.create_and_close')); ?>
</button>
<span class="btn-text">
or <a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans('backend::lang.form.cancel')); ?></a>
</span>
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<p><a href="<?= Backend::url($formConfig->defaultRedirect) ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')); ?></a></p>
<?php endif ?>
20 changes: 20 additions & 0 deletions modules/backend/behaviors/formcontroller/preview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
$formController = $this->getClassExtension(\Backend\Behaviors\FormController::class);
$formConfig = $formController->getConfig();
?>

<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans($formConfig->name . '_plural')); ?></a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>

<?php if (!$this->fatalError): ?>
<div class="form-preview">
<?= $this->formRenderPreview() ?>
</div>
<?php else: ?>
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<p><a href="<?= Backend::url($formConfig->defaultRedirect) ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')); ?></a></p>
<?php endif ?>
55 changes: 55 additions & 0 deletions modules/backend/behaviors/formcontroller/update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
$formController = $this->getClassExtension(\Backend\Behaviors\FormController::class);
$formConfig = $formController->getConfig();
?>

<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans($formConfig->name . '_plural')); ?></a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>

<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>

<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="button"
data-request="onSave"
data-request-data="redirect:0"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.saving_name', ['name' => trans($formConfig->name)])); ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.save')); ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.saving_name', ['name' => trans($formConfig->name)])); ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.save_and_close')); ?>
</button>
<button
type="button"
class="wn-icon-trash-o btn-icon danger pull-right"
data-request="onDelete"
data-load-indicator="<?= e(trans('backend::lang.form.deleting_name', ['name' => trans($formConfig->name)])); ?>"
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')); ?>">
</button>
<span class="btn-text">
or <a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans('backend::lang.form.cancel')); ?></a>
</span>
Comment thread
LukeTowers marked this conversation as resolved.
Outdated
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<p><a href="<?= Backend::url($formConfig->defaultRedirect) ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')); ?></a></p>
<?php endif ?>
26 changes: 26 additions & 0 deletions modules/backend/behaviors/listcontroller/_list_toolbar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
$listController = $this->getClassExtension(\Backend\Behaviors\ListController::class);
$listConfig = $listController->getConfig();
?>

<div data-control="toolbar">
<a
href="<?= url()->current() . '/create' ?>"
Comment thread
LukeTowers marked this conversation as resolved.
Outdated
class="btn btn-primary wn-icon-plus">
<?= e(trans('backend::lang.form.create_title', ['name' => trans(\Winter\Storm\Support\Str::before($listConfig->title, '_plural'))])); ?>
</a>

<button
class="btn btn-danger wn-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', { checked: $('.control-list').listWidget('getChecked') })"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')); ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', 'disabled')"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')); ?>
</button>
Comment thread
LukeTowers marked this conversation as resolved.
Outdated
</div>
1 change: 1 addition & 0 deletions modules/backend/behaviors/listcontroller/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?= $this->listRender() ?>
16 changes: 10 additions & 6 deletions modules/backend/console/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CreateController extends BaseScaffoldCommand
protected $signature = 'create:controller
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{controller : The name of the controller to generate. <info>(eg: Posts)</info>}
{--stubs : Create view files for local overwrites.}
{--force : Overwrite existing files with generated files.}
{--model= : Defines the model name to use. If not provided, the singular name of the controller is used.}
{--sidebar : Create stubs for form-with-sidebar layout}
Expand All @@ -45,10 +46,8 @@ class CreateController extends BaseScaffoldCommand
* @var array A mapping of stub to generated file.
*/
protected $stubs = [
'scaffold/controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.php',
'scaffold/controller/config_form.stub' => 'controllers/{{lower_name}}/config_form.yaml',
'scaffold/controller/config_list.stub' => 'controllers/{{lower_name}}/config_list.yaml',
'scaffold/controller/index.stub' => 'controllers/{{lower_name}}/index.php',
'scaffold/controller/controller.stub' => 'controllers/{{studly_name}}.php',
];

Expand All @@ -69,11 +68,16 @@ protected function prepareVars(): array
$vars['model'] = $model;
$vars['sidebar'] = $this->option('sidebar');

$layout = $this->option('sidebar') ? 'sidebar' : 'standard';
if ($this->option('stubs')) {
$this->stubs['scaffold/controller/index.stub'] = 'controllers/{{lower_name}}/index.php';
$this->stubs['scaffold/controller/_list_toolbar.stub'] = 'controllers/{{lower_name}}/_list_toolbar.php';

$this->stubs["scaffold/controller/{$layout}/create.stub"] = 'controllers/{{lower_name}}/create.php';
$this->stubs["scaffold/controller/{$layout}/update.stub"] = 'controllers/{{lower_name}}/update.php';
$this->stubs["scaffold/controller/{$layout}/preview.stub"] = 'controllers/{{lower_name}}/preview.php';
$layout = $this->option('sidebar') ? 'sidebar' : 'standard';
Comment thread
jaxwilko marked this conversation as resolved.
Outdated

$this->stubs["scaffold/controller/{$layout}/create.stub"] = 'controllers/{{lower_name}}/create.php';
$this->stubs["scaffold/controller/{$layout}/update.stub"] = 'controllers/{{lower_name}}/update.php';
$this->stubs["scaffold/controller/{$layout}/preview.stub"] = 'controllers/{{lower_name}}/preview.php';
}

return $vars;
}
Expand Down
32 changes: 31 additions & 1 deletion modules/system/traits/ViewMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ trait ViewMaker

/**
* Prepends a path on the available view path locations.
*
* @param array|string $path
* @return void
*/
public function addViewPath(string|array $path): void
public function prependViewPath(array|string $path): void
{
$this->viewPath = (array) $this->viewPath;

Expand All @@ -55,6 +58,33 @@ public function addViewPath(string|array $path): void
}
}

/**
* Append a path on the available view path locations.
*
* @param array|string $path
* @return void
*/
public function appendViewPath(array|string $path): void
{
$this->viewPath = (array) $this->viewPath;

if (is_array($path)) {
$this->viewPath = array_merge($this->viewPath, $path);
} else {
$this->viewPath[] = $path;
}
}

/**
* Prepends a path on the available view path locations.
*
* @deprecated Use prependViewPath()
*/
public function addViewPath(string|array $path): void
{
$this->prependViewPath($path);
}

/**
* Returns the active view path locations.
*/
Expand Down