-
Notifications
You must be signed in to change notification settings - Fork 897
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
allow configurable page headings using tokens #5566
Open
pxpm
wants to merge
1
commit into
main
Choose a base branch
from
config-operation-title-tokens
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
This file contains 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 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 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 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,29 @@ | ||
<h1 | ||
class="text-capitalize mb-0" | ||
bp-section="page-heading"> | ||
{!! $crud->getHeading() ?? trans('backpack::crud.page_heading', [ | ||
'singular' => $singular, | ||
'plural' => $plural, | ||
'action' => $action | ||
]) | ||
!!} | ||
</h1> | ||
<p | ||
class="ms-2 ml-2 mb-0" | ||
bp-section="page-subheading"> | ||
{!! $crud->getSubheading() ?? trans('backpack::crud.page_subheading', [ | ||
'singular' => $singular, | ||
'plural' => $plural, | ||
'action' => $action | ||
]) | ||
!!} | ||
</p> | ||
@if ($backButton ?? true && $crud->hasAccess('list')) | ||
<p class="mb-0 ms-2 ml-2" bp-section="page-subheading-back-button"> | ||
<small> | ||
<a href="{{ url($crud->route) }}" class="d-print-none font-sm"> | ||
<span><i class="la la-angle-double-{{ config('backpack.base.html_direction') == 'rtl' ? 'right' : 'left' }}"></i> {{ trans('backpack::crud.back_to_all') }} <span>{{ $crud->entity_name_plural }}</span></span> | ||
</a> | ||
</small> | ||
</p> | ||
@endif |
This file contains 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the empty strings here intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only reason why this PR is not merged yet I think I wouldn't have called for your judgment if it wasn't for this use case.
This triggers my "spidey" sense too, so it's super you have noticed the same. (I would have talked you about this anyway).
So the reason this happens is because in ListOperation we don't show any "action" (Create, Update, Preview etc..), and also we don't want to show any "singular", mean
Monster
.Translating this to placeholders means we would show the
Monsters
(:plural) in the heading, and two empty strings in the sub heading (where usually we haveCreate Monster
(:action : singular))Ideally
singular, plural, action
placeholders should always have value, filled from crud variables, without caring in what operation they are used. To achieve this, we need to remove theheading
andsubheading
from lang files, and make them part of each operation.So that ListOperation can set
heading
to:plural
and nothing insubheading
, whileCreateOperation
setheading
to:plural
and subheading to:action :singular
.We can still keep the defaults for backwards compatibility, and set the
operation.heading
to null or something and we keep the same translations/behavior we currently have. But developer can setupoperation.heading
in their Controller and it would overwrite our defaults. I think this is way more resilient that this placeholder approach.What you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you forgot to add parent div, its broken when I tried :) and the same for reorder, show, create edit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @siberfx thanks for the heads up.
What div are you referring to ? From the code changes I didn't remove any div, I just moved the
<h1>
and the<p>
to a new file.Also I cannot find the mentioned div in the
main
branch of CRUD:CRUD/src/resources/views/crud/create.blade.php
Line 14 in dee2eec
Maybe that's a custom change you made to your views ?
Cheers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I saw between your @section codes, maybe I am the one who uses the outdated versions of these blades.. but if in updated version also contains the same structure, than I might be right :) just I applied these changes on my existing environment on local and saw them broken. so I decided to let you know :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @siberfx appreciated 🙏
Thing is that if you have those files overwritten in your local
resources/views
folder, you won't get the updated versions when/if we release them, so we can't break your app. 👍This is still kind of POC, because I am still not happy with all the mumbo-jumbo setting "empty" stuff etc in some operations. I may have time to gives this a "fresh" look in the next month or so I hope 🙏
Cheers