Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Feature Request] Table Widget (aka `ListOperation` inside `ShowOperation`) aka. multiple existing list views in a show view #100

Open timbertens opened 3 years ago

timbertens commented 3 years ago

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

tabacitu commented 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).

timbertens commented 3 years ago

Just as an addition on how this might look like

Screenshot 2021-03-26 at 11 25 59
promatik commented 3 years ago

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.

burotica49 commented 3 years ago

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

timbertens commented 3 years ago

@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 ;-)

tabacitu commented 1 year ago

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!

tabacitu commented 1 year ago

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.

ale1981 commented 1 year ago

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.

StefanPrintezis commented 9 months ago

https://github.com/izica/relations-widgets-for-backpack

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.

Astriel commented 8 months ago

This really need to be a default functionality in backpack !

kyleheading commented 3 weeks ago

would be great to see this feature as part of backpack pro!