-
-
Notifications
You must be signed in to change notification settings - Fork 227
Behaviour default views #1312
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
Behaviour default views #1312
Conversation
|
I've been wanting to do this for ages... Great work! |
Co-authored-by: Marc Jauvin <marc.jauvin@gmail.com>
…nter into wip/behaviour-default-views
|
@LukeTowers @mjauvin any thoughts on my changes to |
I like it @jaxwilko, as long as it doesn't introduce BC issues, which it shouldn't. |
|
@jaxwilko @LukeTowers I'd like to add the possibility to not show the Trash (delete) button in the What do you guys think ? diff --git a/modules/backend/behaviors/formcontroller/partials/_toolbar.php b/modules/backend/behaviors/formcontroller/partials/_toolbar.php
index d4929319f..f07addfa4 100644
--- a/modules/backend/behaviors/formcontroller/partials/_toolbar.php
+++ b/modules/backend/behaviors/formcontroller/partials/_toolbar.php
@@ -65,15 +65,17 @@ class="btn btn-default"
>
<?= e(trans('backend::lang.form.save_and_close')); ?>
</button>
- <button
- type="button"
- data-request="onDelete"
- data-load-indicator="<?= e(trans('backend::lang.form.deleting_name', ['name' => trans($modelName)])); ?>"
- data-request-before-update="$el.trigger('unchange.oc.changeMonitor')"
- data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')); ?>"
- class="wn-icon-trash-o btn-icon danger pull-right"
- >
- </button>
+ <?php if (!$this->hideTrashButton): ?>
+ <button
+ type="button"
+ data-request="onDelete"
+ data-load-indicator="<?= e(trans('backend::lang.form.deleting_name', ['name' => trans($modelName)])); ?>"
+ data-request-before-update="$el.trigger('unchange.oc.changeMonitor')"
+ data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')); ?>"
+ class="wn-icon-trash-o btn-icon danger pull-right"
+ >
+ </button>
+ <?php endif ?>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans('backend::lang.form.cancel')); ?></a>
</span> |
|
@mjauvin if we make it configurable then it should probably be through the form config and it should also disable the Ajax handler. Could we change the delete button to make it more obvious what it does instead? |
Can we do both ? <?php if (!isset($formConfig->hideTrashButton)): ?>
<button
type="button"
data-request="onDelete"
data-load-indicator="<?= e(trans('backend::lang.form.deleting_name', ['name' => trans($modelName)])); ?>"
data-request-before-update="$el.trigger('unchange.oc.changeMonitor')"
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')); ?>"
class="wn-icon-trash-o btn-icon danger pull-right"
>
</button>
<?php endif ?> |
|
@mjauvin why do you want to disable the button / the handler separately from each other? We might also want to take inspiration from the RelationController's approach to managing the available buttons (see |
Also recompiled the other less assets since the dependency update to the less compiler.
This PR adds default views for the following backend controller behaviors:
Backend\Classes\ControllerBehaviorwill now automatically append theirviewsfolder to the controller's view paths allowing them to provide fallbacks for any views required by the behavior.The
create:controllercommand will now no longer generate the views by default unless--stubsis also passed and the--sidebarflag is replaced with a--layout=(standard|sidebar|fancy)option to choose the form layout to use.Also:
appendViewPath()andprependViewPath()to theSystem\Traits\ViewMaker.addViewPathis renamed toprependViewPath()and is for paths that have higher priority than the existing paths whileappendViewPath()is for paths that should have lower priority than the existing paths (i.e. fallbacks).Author.Pluginas the author,$pluginNameas the main menu code, and$controllerNameas the side menu code. This means that you can remove calls toBackendMenu::setContext()and constructor overrides in your controllers if they follow that convention.new: trueas a parameter in the request body toonSave()calls that will return a redirect to thecreateactionformMakePartial(string $partial, array $params = [])to theFormControllerbehavior that will render a partial through the controller'smakePartialusing the following priority list of contextual names:form_$context_$partial,form_$partial,$partial).abort(403)to return the access denied view in the backendabort(404)in the backendTo Review: