-
Notifications
You must be signed in to change notification settings - Fork 898
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
[Feature Request] details row to accept widgets by default #5347
Comments
Hi guys, Any news about this? |
Hey @susanu I've been working on other stuff and didn't bring this to team attention yet so I am not sure if we are going to pursue this direction. What I mean is that I think there are separated tasks here: Regarding 1) and 2), I think the code you provided is pretty much the required thing. 3) is where things start to get interesting. Analyzing the current and possible future direction, can we come up with a way to have those tabs, rows, columns but not making them "columns" ? [
'type' => 'div',
'class' => 'row',
'content' => [ // widgets
[ 'type' => 'tabs', 'content' => [
'tab1' => [
'title' => 'My Tab 1'
'content' => ['type' => 'card' ... ],
],
'tab2' => [
'title' => 'My Tab 1',
'content' => ['type' => 'card' ... ],
],
]
]
] What do you think ? |
So, for me, Another idea that crossed my mind is, instead of treating I often need to display information about the current entry and the relationships in the edit page of the crud. |
What you mean is static ? You have // details_row.blade.php
@php
Widget::add([
'type' => 'div',
'class' => 'row',
'section' => 'details_row',
'content' => [ // widgets
[ 'type' => 'card', 'content' => ['body' => $entry->id, 'header' => 'ID'], 'class' => 'col-md-6' ],
[ 'type' => 'card', 'content' => ['body' => $entry->text, 'header' => 'TITLE'], 'class' => 'col-md-6' ],
]
])
@endphp
<div class="m-t-10 m-b-10 p-l-10 p-r-10 p-t-10 p-b-10" bp-section="crud-details-row">
<div class="row">
<div class="col-md-12">
@include(backpack_view('inc.widgets'), ['widgets' => app('widgets')->where('section', 'details_row')->toArray()])
</div>
</div>
</div>
<div class="clearfix"></div> So doing 1) that you proposed would be quite easy and open a lot of opportunities. What I am thinking now is also an easy solution where you could write your widgets definition without having to create the blade file yourself. Note: one thing I noticed is that we probably need to accept an array of stacks instead of a single string, so that the same widget definition can be reused in multiple operations that use different stacks. I think doing "just" this would allow you to achieve the desired results creating a couple of additional widgets (for eg. "tabs widget", "column widget", "table widget" etc .., that is something we can do), instead of "one function columns", or introducing some kind of new concept in crud to build specific stuff with tabs. What do you think ? |
Hmm, your example is not good i think because you setup the widget inside the details_row.blade.php
Then you can add widgets from Maybe creating some simple components which can be configured from the controller.
What do you think? |
That was an example and exactly why I said "a new method Those components you are talking about make sense if we were building an "UI library" to use with Backpack. It would be awesome, but it's out of scope for the issue we are discussing here. So, to sum up my idea more clearly on "how we can make details row accept widgets by default":
That method can also return the html/view to render in addition to the widgets. public function setupDetailsRow($entry)
{
Widget::add() ...
return view('my-view'); // or no return at all if you setup the details row exclusively using widgets ?
// this will render this view "inside" the default backpack details row view.
} So we modify the current public function showDetailsRow($id)
{
$this->crud->hasAccessOrFail('list');
// get entry ID from Request (makes sure its the last ID for nested resources)
$id = $this->crud->getCurrentEntryId() ?? $id;
$this->data['entry'] = $this->crud->getEntry($id);
$this->data['crud'] = $this->crud;
+ $this->data['html'] = $this->setupDetailsRow($entry); // we setup widgets and can return some html here
// load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
return view($this->crud->getDetailsRowView(), $this->data);
} // the default backpack details row become something like this
<div class="m-t-10 m-b-10 p-l-10 p-r-10 p-t-10 p-b-10" bp-section="crud-details-row">
<div class="row">
<div class="col-md-12">
@include(backpack_view('inc.widgets'), ['widgets' => app('widgets')->where('section', 'details_row')->toArray()])
</div>
</div>
</div>
<div class="clearfix"></div>
{!! $html !!} Does this make sense ? |
Yes, looks good. |
I come to you with a different matter. For example. Normal look:
Widget look (yes, yes, you hate the column widget type but for me it does the job):
|
Hey @susanu thanks for the example. 100% using it as a widget looks way way cleaner. Naaa I don't hate your I just don't think it's savvy to push everything at the same time, making this a huuuuge feature, when we can do this incrementally and getting benefits on each iteration. It's easier for us to test, iterate on the UI/UX of small bits to make sure we think about edges, how people can use this outside "our" use case etc. So yeah, totally agree with making details row composable with widgets, it was an excellent idea if you ask me. Then work on widgets that will make that experience even better (the table, the column if needed etc). Widgets are in nature re-usable, so it's expectable that the same table you use in a detail row, you could re-use in the show view. This is just a scope management on my side, you gave us great ideas and examples and everything, that's way way more than we asked or expect when people request features, so we are very grateful for your time and effort, I just try to keep those ideas on their own place and manageable from our side 🙏 Cheers, keep it up 👍 |
Hi, I saw this feature request and it inspired me to try adding a Livewire component inside the details_row. While the component renders correctly, I'm encountering an issue where the actions don't work. I've tried a simple example from the Livewire documentation using the Counter component. Although there are no errors on the page, the buttons do not work. Has anyone successfully integrated Livewire with details_row, or does anyone have suggestions on how to troubleshoot this? Thanks in advance for any assistance! |
Most likely you are only adding livewire on the "ajax call" to details row, and you should probably need to have livewire already on page before that call is done and maybe try with: Never did that, but if you find the solution let us know 👍 In the meanwhile we merged this feature on https://github.com/Laravel-Backpack/CRUD/releases/tag/6.7.35 Cheers |
Feature Request
What's the feature you think Backpack should have?
I got this request/idea from a discussion in Laravel-Backpack/community-forum#712 where @susanu shared some code he's using in his project.
Basically the idea is to replace the empty details row blade template with a template that outputs widgets you can configure in your crud panels.
Have you already implemented a prototype solution, for your own project?
@susanu did implemented a prototype, it's in the linked discussion.
Do you see this as a core feature or an add-on?
I think we could do this change as a NON-BC in core.
The text was updated successfully, but these errors were encountered: