-
Notifications
You must be signed in to change notification settings - Fork 920
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] Show view #226
Comments
Hi @welcoMattic , Yes, it was planned all along, it's just been postponed because of more pressing features. I'm very happy to help you out if you want to get started before I find the time. There are a few issues that need to be addressed. Here are my thoughts: 1. How it would work
2. How it would be used
$this->crud->addShowColumn(); // add one column, at the end of the stack
$this->crud->addShowColumns(); // add multiple columns, at the end of the stack
$this->crud->removeShowColumn('column_name'); // remove a column from the stack
$this->crud->removeShowColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack
$this->crud->setShowColumnDetails('column_name', ['attribute' => 'value']);
$this->crud->setShowColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);
3. How it would be coded
4. Possible problems
@welcoMattic , what do you think? If you do want to work on this, after we pen down the solution I could create a feature branch for you, so we can collaborate there. Cheers! |
@tabacitu Woh such a reply! Indeed you've been working on it, I'm ok to continue this work on a separate feature branch. For now, in my application, I just patch the feature with some Blade tricks in the show view, only. But it could be nice to make properly in CRUD feature. Go on! |
@tabacitu @welcoMattic hows this coming along? |
Is there any update on this? |
Hi @skatika @OwenMelbz @tabacitu! Last weeks were very full of work, I didn't have much time to work on it. With Xmas period coming I don't know if I could work a lot on this feature. But trust me, in January I'll plan some evenings to work on BackPack, especially on show view ;) |
@tabacitu @OwenMelbz @skatika PR is open 🎉 |
@welcoMattic @tabacitu @OwenMelbz If you guys don't mind, I'd like to take a crack at implementing this based on the specs detailed in #226 (comment). I have a pressing need and would prefer to implement it in a style that's compatible with the current infrastructure. This would probably not use much from the pending PR. Basically the approach would be to render a 2-column bootstrap table in the show view using the existing column-type names and views, taking a single row and rendering it vertically -- column one containing the headers and column 2 containing the row data. I would name the elements 'showRow' instead of 'showColumn' and autopopulate using the same selection process as fields rather than restrict show to the column limitations. If this works for everybody I'd be happy to discuss further, including how you would like me to coordinate the work. I'm probably going to need to implement something in the next few weeks. |
I don't know exactly how this is going along, I just wanted to share my approach I just implemented in one of my projects. Basic overview of what I did:
It takes all the fields specified for editing and disables them (it also works for select2 inputs). I'm not saying it's the most beautiful thing under the Sun, but it's still better than Possible drawbacks:
Maybe this'll help someone, at least until the new approach is implemented. |
Hi guys, I'm sorry for months of silence. I've really no time to work on this feature. Actually I'm working on Symfony projects. If someone is interested to take this issue, he/she is welcome ;) |
Hi @welcoMattic , Thanks a lot for the update! No worries, I'll pick it up in Backpack 3.4. Cheers! |
In other REST implementations I've seen, to view a resource, you would use something like /tags/1 where 1 is the id of the resource. So,
If I understand correctly, you're saying you would have something like /tags/1/show or /tags/show/1? |
Here's how this could turn up iteratively:
And suddenly you've got an odd looking but workable preview. Then:
I'll call this the "bike shedding" step :) |
@mmickelson - the route is already there, it's exactly as you suggested, RESTful ( @lloy0076 - I thought about showing everything in fields too, but it definitely won't look good by default :-) Another problem here - you might show some fields on CREATE, others on UPDATE. Which ones would be visible on SHOW? Plus, you'd have things like ID that you might want visible on SHOW, but not on CREATE or UPDATE... It's tricky... |
@tabacitu I'm still willing to take this on as an assigned task, implemented the way you have specified, as I described in my previous #226 (comment). There shouldn't be any breaking changes. |
@tabacitu - aye, I agree it wouldn't look particularly pretty; I was more thinking that a stepping stone towards making it look pretty would be an almost copy/paste of the @jonphipps - if I'm reading #226 (comment) correctly, then I think we might be saying the same thing in different ways :) |
@lloy0076 re: "I think we might be saying the same thing in different ways :)" Not exactly. I'm talking about copying the column default definitions and views, intact, and simply defining a 'show' view of a Db row as a single row from the 'list' view, rather than redisplaying the create/update definitions. The column definitions are much more appropriate for showing a single row from the list columns and the current column API is a better fit. |
@jonphipps - ah, yes, that would work. However, consider:
In addition, if one were to "steal" the code for Really, where we differ might be:
That said, I'm sure everyone would appreciate a PR based on what you've suggested. |
@lloy0076 I'm going by the requirements defined in this set of specs from @tabacitu and reiterated here:
$this->crud->addShowRow(); instead of $this->crud->addShowColumn();
<table id="crudTable" class="table table-bordered table-striped display">
<thead><tr><td>Field</td<td>Value></td></tr></thead>
<tbody>
<tr>
<td>{{ $showRow['label']}}<td>
{{-- load the view from the application if it exists, otherwise load the one in the package --}}
@foreach ($crud->showrows as $showRow)
@if (!isset($showRow['type']))
@include('crud::columns.text')
@else
@if(view()->exists('vendor.backpack.crud.columns.'.$showRow['type']))
@include('vendor.backpack.crud.columns.'.$showRow['type'])
@else
@if(view()->exists('crud::columns.'.$showRow['type']))
@include('crud::columns.'.$showRow['type'])
@else
@include('crud::columns.text')
@endif
@endif
@endif
@endforeach
</tr>
</tbody>
<tfoot><tr>
@if ( $crud->buttons->where('stack', 'line')->count() )
<th>{{ trans('backpack::crud.actions') }}</th>
@endif
</tr></tfoot>
</table>
Nice to have:
re: "That said, I'm sure everyone would appreciate a PR based on what you've suggested." @tabacitu had suggested: "If you do want to work on this, after we pen down the solution I could create a feature branch for you, so we can collaborate there." ...and I was looking for that sort of explicit 'Yes, make it so' permission to help with it -- a little more formal and structured than just submitting an out-of-the-blue pull request. |
#226 (comment) all sounds good to me. |
#991 is a PR for this. |
Thanks to @AbbyJanke this is now ready to use. Cheers! |
At the moment, in the show view file, there's only a
dump()
of the Model.May we consider to improve this to display user-friendly data of Models?
I'm ok to start it! ;)
The text was updated successfully, but these errors were encountered: