-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Merged
Merged
Behaviour default views #1312
Changes from all 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 f3706b8
Added default view files for forms and lists behaviours
jaxwilko 67ef0eb
Added --stubs option to create controller command
jaxwilko 22d04ef
Added code styling fixes
jaxwilko 3feecb6
Added fix for hardcoded link
jaxwilko 8b65ce0
Update modules/backend/behaviors/listcontroller/_list_toolbar.php
LukeTowers 41f1fb5
Added support for default reorder views
jaxwilko 4a2760b
Merge branch 'wip/behaviour-default-views' of github.com:wintercms/wi…
jaxwilko 8f216a2
Added support for import export behaviour defaults
jaxwilko fe85e22
Added default value for bodyClass
jaxwilko b77d283
Added self generating breadcrumb partial
jaxwilko b0bbed0
Added default partials for behaviours
jaxwilko 0807dd4
Added self generating breadcumb for controller stubs
jaxwilko cae7704
Added import export lang keys
jaxwilko 2a13527
Added fix for code styling
jaxwilko 2f616e0
Added fixes for reorder partials
jaxwilko 5102170
Move controllerbehavior default views to /views
LukeTowers 606fe64
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers 3fe07ef
Update modules/backend/behaviors/reordercontroller/views/reorder.php
LukeTowers 41f643b
Switch to new prependViewPath() method
LukeTowers 5d0b9ca
Automatically set BackendMenu context from controller path
LukeTowers e0e6cb9
Tweaks to the default views based on migrating Winter.Blog
LukeTowers d6449e8
Improve breadcrumb generation logic to take into account settings con…
LukeTowers b4c66d6
Update the changemonitor status after the AJAX requests complete
LukeTowers 143dfe4
Add top padding to form buttons container & remove buttons from the s…
LukeTowers fced797
Remove unnecessary backend controller views
LukeTowers ce48714
Add localized "or" string
LukeTowers 8689e40
Add data-browser-validate to all form saving buttons
LukeTowers 5de7bd7
add missing delete button to sidebar layout update view
mjauvin bc7e493
no need for two links with the same url
mjauvin 3d77eaf
Merge branch 'develop' into wip/behaviour-default-views
mjauvin 077d4c4
do not show "delete selected" button if the list does not show the re…
mjauvin acc69e8
add cancel button in default fancy toolbar
mjauvin e7032e8
remove extra space after closing parenthesis
mjauvin fe0abe7
Update modules/backend/behaviors/listcontroller/views/_list_toolbar.php
LukeTowers 0512f13
Merge branch 'develop' into wip/behaviour-default-views
mjauvin f511992
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers 8ec2466
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers a36b3e0
Extract create/update form buttons into their own partials (#1352)
mjauvin 451f4f9
Use toolbar partial
LukeTowers 22ab21e
Update update.stub
LukeTowers 3732260
Update create.stub
LukeTowers 76b833c
Update update.stub
LukeTowers 9bbdfa5
add reorder button on default list toolbar
mjauvin 33e1d3b
fix icon class
mjauvin 3cff2dc
only add create button if FormController is used
mjauvin 777a556
use more appropriate reorder icon
mjauvin 0776b98
use arrows-up-down icon for reorder action
mjauvin ee943fd
Merge branch 'develop' into wip/behaviour-default-views
mjauvin a735dce
Merge branch 'develop' into wip/behaviour-default-views
mjauvin 606bf14
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers c5fc31b
Add buttons for import export behavior to list default toolbar when b…
LukeTowers 0d7e874
Add support for abort(403) in the backend
LukeTowers e24f395
Improve abort(404) handling in the backend
LukeTowers 8eb44e9
Add icons to the default form buttons
LukeTowers 4993443
Merge branch 'develop' into wip/behaviour-default-views
LukeTowers fe10d42
Add missing buttons and icons to the form fancy toolbars
LukeTowers 8d6bd7b
Fix disabled styling for outside tab fields in the fancy form layout
LukeTowers ddf26db
Improve handling of layouts in the controller scaffolding command
LukeTowers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
modules/backend/behaviors/formcontroller/partials/_toolbar.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php | ||
| $modelName = $formConfig->name ?? ''; | ||
| ?> | ||
| <?php if ($formContext === 'create'): ?> | ||
| <div class="loading-indicator-container"> | ||
| <button | ||
| type="submit" | ||
| data-request="onSave" | ||
| data-request-data="new:1" | ||
| data-browser-validate | ||
| data-hotkey="ctrl+shift+s, cmd+shift+s" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating_name', ['name' => trans($modelName)])); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-primary wn-icon-plus"> | ||
| <?= e(trans('backend::lang.form.create_and_new')); ?> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-hotkey="ctrl+s, cmd+s" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating_name', ['name' => trans($modelName)])); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-primary wn-icon-save"> | ||
| <?= e(trans('backend::lang.form.create')); ?> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-request-data="close:1" | ||
| data-hotkey="ctrl+enter, cmd+enter" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating_name', ['name' => trans($modelName)])); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-default wn-icon-check"> | ||
| <?= e(trans('backend::lang.form.create_and_close')); ?> | ||
| </button> | ||
| <span class="btn-text"> | ||
| <?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans('backend::lang.form.cancel')); ?></a> | ||
| </span> | ||
| </div> | ||
| <?php elseif ($formContext === 'update'): ?> | ||
| <div class="loading-indicator-container"> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| data-request-data="redirect:0" | ||
| data-hotkey="ctrl+s, cmd+s" | ||
| class="btn btn-primary wn-icon-save" | ||
| > | ||
| <?= e(trans('backend::lang.form.save')); ?> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-request-data="close:1" | ||
| data-hotkey="ctrl+enter, cmd+enter" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.saving')); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-default wn-icon-check" | ||
| > | ||
| <?= 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> | ||
| <span class="btn-text"> | ||
| <?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url($formConfig->defaultRedirect) ?>"><?= e(trans('backend::lang.form.cancel')); ?></a> | ||
| </span> | ||
| </div> | ||
| <?php endif ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| // Decide which layout we should be rendering | ||
| $layout = $this->formLayout ?? $formConfig->formLayout ?? null; | ||
| if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { | ||
| $layout = 'standard'; | ||
| } | ||
|
|
||
| // If required, set the appropriate body classes | ||
| $this->bodyClass = match ($layout) { | ||
| 'fancy' => 'fancy-layout compact-container breadcrumb-flush breadcrumb-fancy', | ||
| 'sidebar' => 'compact-container', | ||
| default => '', | ||
| }; | ||
|
|
||
| // Define layout mode view path for inclusion | ||
| $this->appendViewPath(sprintf('%s/create/%s', __DIR__, $layout)); | ||
|
|
||
| // Render the form layout | ||
| echo $this->makePartial(sprintf('create/%s.php', $layout)); |
20 changes: 20 additions & 0 deletions
20
modules/backend/behaviors/formcontroller/views/create/_fancy.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php Block::put('breadcrumb') ?> | ||
| <?= $this->makeLayoutPartial('breadcrumb') ?> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php if (!$this->fatalError): ?> | ||
| <div class="layout fancy-layout"> | ||
| <?= Form::open([ | ||
| 'class' => 'layout', | ||
| 'data-change-monitor' => 'true', | ||
| 'data-window-close-confirm' => 'true', | ||
| ]) ?> | ||
| <div class="layout-row"> | ||
| <?= $this->formRender() ?> | ||
| </div> | ||
| <?= Form::close() ?> | ||
| </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 ?> |
40 changes: 40 additions & 0 deletions
40
modules/backend/behaviors/formcontroller/views/create/_sidebar.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php Block::put('breadcrumb') ?> | ||
| <?= $this->makeLayoutPartial('breadcrumb') ?> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php if (!$this->fatalError): ?> | ||
| <?php Block::put('form-contents') ?> | ||
| <div class="layout"> | ||
| <div class="layout-row"> | ||
| <?= $this->formRenderOutsideFields() ?> | ||
| <?= $this->formRenderPrimaryTabs() ?> | ||
| </div> | ||
|
|
||
| <div class="form-buttons p-t"> | ||
| <?= $this->formMakePartial('toolbar') ?> | ||
| </div> | ||
| </div> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php Block::put('form-sidebar') ?> | ||
| <div class="hide-tabs"><?= $this->formRenderSecondaryTabs() ?></div> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php Block::put('body') ?> | ||
| <?= Form::open([ | ||
| 'class' => 'layout stretch', | ||
| 'data-change-monitor' => 'true', | ||
| 'data-window-close-confirm' => 'true', | ||
| ]) ?> | ||
| <?= $this->makeLayout('form-with-sidebar') ?> | ||
| <?= Form::close() ?> | ||
| <?php Block::endPut() ?> | ||
| <?php else: ?> | ||
| <div class="control-breadcrumb"> | ||
| <?= Block::placeholder('breadcrumb') ?> | ||
| </div> | ||
| <div class="padded-container"> | ||
| <p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p> | ||
| <p><a href="<?= Backend::url($formConfig->defaultRedirect) ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')); ?></a></p> | ||
| </div> | ||
| <?php endif ?> |
22 changes: 22 additions & 0 deletions
22
modules/backend/behaviors/formcontroller/views/create/_standard.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php Block::put('breadcrumb') ?> | ||
| <?= $this->makeLayoutPartial('breadcrumb') ?> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php if (!$this->fatalError): ?> | ||
| <?= Form::open([ | ||
| 'class' => 'layout', | ||
| 'data-change-monitor' => 'true', | ||
| 'data-window-close-confirm' => 'true', | ||
| ]) ?> | ||
| <div class="layout-row"> | ||
| <?= $this->formRender() ?> | ||
| </div> | ||
|
|
||
| <div class="form-buttons p-t"> | ||
| <?= $this->formMakePartial('toolbar') ?> | ||
| </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 ?> |
36 changes: 36 additions & 0 deletions
36
modules/backend/behaviors/formcontroller/views/create/fancy/_toolbar.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <div class="form-buttons loading-indicator-container"> | ||
| <button | ||
| type="submit" | ||
| data-request="onSave" | ||
| data-request-data="new:1" | ||
| data-browser-validate | ||
| data-hotkey="ctrl+shift+s, cmd+shift+s" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating')); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-primary wn-icon-plus"> | ||
| <?= e(trans('backend::lang.form.create_and_new')); ?> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-hotkey="ctrl+s, cmd+s" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating')); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-primary wn-icon-save"> | ||
| <?= e(trans('backend::lang.form.create')); ?> | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-request="onSave" | ||
| data-browser-validate | ||
| data-request-data="close:1" | ||
| data-hotkey="ctrl+enter, cmd+enter" | ||
| data-load-indicator="<?= e(trans('backend::lang.form.creating')); ?>" | ||
| data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | ||
| class="btn btn-default wn-icon-check"> | ||
| <?= e(trans('backend::lang.form.create_and_close')); ?> | ||
| </button> | ||
|
|
||
| <a class="btn btn-default wn-icon-ban" href="<?= $this->actionUrl('') ?>"><?= e(trans('backend::lang.form.cancel')); ?></a> | ||
| </div> |
21 changes: 21 additions & 0 deletions
21
modules/backend/behaviors/formcontroller/views/preview.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
|
|
||
| // Decide which layout we should be rendering | ||
| $layout = $this->formLayout ?? $formConfig->formLayout ?? null; | ||
| if (!in_array($layout, ['standard', 'sidebar', 'fancy'])) { | ||
| $layout = 'standard'; | ||
| } | ||
|
|
||
| // If required, set the appropriate body classes | ||
| $this->bodyClass = match ($layout) { | ||
| 'fancy' => 'fancy-layout compact-container breadcrumb-flush breadcrumb-fancy', | ||
| 'sidebar' => 'compact-container', | ||
| default => '', | ||
| }; | ||
|
|
||
| // Define layout mode view path for inclusion | ||
| $this->appendViewPath(sprintf('%s/preview/%s', __DIR__, $layout)); | ||
|
|
||
| // Render the form layout | ||
| echo $this->makePartial(sprintf('preview/%s.php', $layout)); |
14 changes: 14 additions & 0 deletions
14
modules/backend/behaviors/formcontroller/views/preview/_fancy.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php Block::put('breadcrumb') ?> | ||
| <?= $this->makeLayoutPartial('breadcrumb') ?> | ||
| <?php Block::endPut() ?> | ||
|
|
||
| <?php if (!$this->fatalError): ?> | ||
| <?= Form::open(['class' => 'layout']) ?> | ||
| <div class="layout-row form-preview"> | ||
| <?= $this->formRenderPreview() ?> | ||
| </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 ?> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.