Open timbertens opened 3 years ago
I agree! This is something that @promatik mentioned he would love too. There's already some work done in this direction by @izica in https://github.com/Laravel-Backpack/CRUD/pull/2752, which he even turned into a Backpack add-on - https://github.com/izica/relations-widgets-for-backpack
It basically allows the dev to add a Widget to any operation, that includes a table similar to the one inside the ListOperation (but without the DataTables JS).
Just as an addition on how this might look like
That looks amazing @timbertens 😮 Having tabs to manage multiple tables/relations is a good idea.
It would be great if we could provide the table on List operation (using DataTables) as a widget, so anyone could use. It's another "idea" on the list.
Wow, that would be great @timbertens I've been looking to do this for some time as well: Customer with tab: contact, ticket, configuration ...
I used https://github.com/izica/relations-widgets-for-backpack, but no Tab support, and adding a record does not pass the master view key.
An evolution in this kind of Backpack would be a real plus.
@timbertens, your screenshot is fake or works, because interested in knowing how you are doing
@burotica49 it is a screenshot of a working page, but the page is fully custom so I'm not using the real power of backpack here. I've fiddling around to see if I could make into a real component, but I'm lacking time so that's why I posted it as idea ;-)
Good news everyone! We've been gathering feedback regarding what people want out of v6, and this feature stood out as one of the "most wanted", so we're going to make it a priority in v6 🎉 Not sure if before launch or after launch... but yes, we'll be doing this.
One he's done with his current herculean task 😅, I'm going to ask @pxpm to take a look if we can do this with the current tech (small non-breaking changes in the list blade view to allow it to be loaded in other views (I highly doubt this). If not... I'm going to create a few prototypes myself, using Livewire. What we want is to do this in a very future-proof way. In a way that we can maintain for years to come, and a way that doesn't duplicate our code in a considerable manner.
Until then, I believe https://github.com/izica/relations-widgets-for-backpack is a very good solution, that you can use right now!
Bad news: we haven't been able to cram this into v6.0. We do plan to do this in v6, as a non-breaking change. But since this won't be an easy task, we'd rather take our time and do it right.
That's a shame, I am just testing v6.0 and wondered if this had made it to the beta stages. I think this will take Backpack to the next level and is something I have found needing in all my Backpack projects.
I wanted to be able to print any backpack crud column given to the relation_table from izica/relations-widgets-for-backpack, but to effectively do that without hard coding too much I needed a variant of CRUD::getFirstFieldView, but for columns, so i've adjusted the templates from the suggested package in the following way.
@php
// This ensures we have a 'type' & other expect column keys set.
$field = CRUD::makeSureColumnHasNeededAttributes($field);
$viewNamespace = 'crud';
// Based of CRUD::getFirstFieldView
$getFirstColumnView = function($viewPath) {
$paths = array_map(function ($item) use ($viewPath) {
return $item.'.'.$viewPath;
}, ViewNamespaces::getFor('columns'));
foreach ($paths as $path) {
if (view()->exists($path)) {
return $path;
}
}
// if no view exists, in any of the directories above... no bueno
if (! backpack_pro()) {
throw new BackpackProRequiredException('Cannot find the column view: '.$viewPath.'. Please check for typos.'.(backpack_pro() ? '' : ' If you are trying to use a PRO column, please first purchase and install the backpack/pro addon from backpackforlaravel.com'), 1);
}
abort(500, "Cannot find '{$viewPath}' field view in any of the regular locations.");
};
$view = $getFirstColumnView($field['type']);
$viewData = [
'entry' => $entry_relation,
'column' => $field,
];
@endphp
<tr>
<th>
<strong>{{$field['label'] ?? ''}}:</strong>
</th>
<td>
@include($view, $viewData)
</td>
</tr>
If we get equivalents of getFirstColumnView i'd be allot easier to re-use existing parts of backpack crud in widgets.
This really need to be a default functionality in backpack !
would be great to see this feature as part of backpack pro!
A common case when having more complex applications is to have a master / details view on certain models.
eg. Customers with Contacts, Orders, Invoices, Complaints
It would be very handy if we could recuperate different functionalities in one screen