laravel / nova-issues

553 stars 34 forks source link

Orderable resources #461

Closed molteber closed 5 years ago

molteber commented 6 years ago

A neat feature to add to Laravel Nova would be the ability to make a resource Orderable, and what that does is adding a drag-drop handler to the index view, giving you the option to set the order of the resource. This can give implications regarding setting fields sortable.

Say you have a resource of Best friends, ranked from 1 to infinity and beyond. This resource is orderable with a given column order. By default the list is sorted by the column order. You have also made the field Name sortable. When you sort by Name, the handler for ordering will disappear / get disabled. Until no sorting is applied or you have sorted on Order again (if that meta option is added).

When sorting on the order field, drag-n-drop moving the entries up and down should follow the direction of the sort. Ex: order sorted by asc and moving a row down should increase the order for that row. And by desc, decrease.

Inaztm commented 6 years ago

+++

hooch commented 6 years ago

@molteber does this package address your need?

https://novapackages.com/packages/naxon/nova-field-sortable

molteber commented 6 years ago

@hooch That sure looks like something that works. By the looks of it, it only works by moving up or down one step at a time instead of drag-n-dropping over multiple rows. I find drag-n-drop more convenient, but I will probably look into using this package in the meantime

hooch commented 6 years ago

@molteber drag and drop would definitely be preferable

hooch commented 6 years ago

@molteber here's how it's done by the SCPOrder WordPress plugin


    $('table.posts #the-list, table.pages #the-list').sortable({
        'items': 'tr',
        'axis': 'y',
        'helper': fixHelper,
        'update' : function(e, ui) {
            $.post( ajaxurl, {
                action: 'update-menu-order',
                order: $('#the-list').sortable('serialize'),
            });
        }
    });  
    $('table.tags #the-list').sortable({
        'items': 'tr',
        'axis': 'y',
        'helper': fixHelper,
        'update' : function(e, ui) {
            $.post( ajaxurl, {
                action: 'update-menu-order-tags',
                order: $('#the-list').sortable('serialize'),
            });
        }
    }); 
    var fixHelper = function(e, ui) {
        ui.children().children().each(function() {
            $(this).width($(this).width());
        });
        return ui;
    };

})(jQuery)```
davidhemphill commented 5 years ago

Hey there! In order to keep this repository focused on bug reports, we auto-close feature requests and requests for help. Feel free to post your feature requests so others can discuss and add reactions. We'll keep an eye on them for later planning.

NioTeX commented 5 years ago

We could also definitely use this feature, preferably with some sort of drag and drop.

desaintflorent commented 4 years ago

What about this one ? didn't tried it yet, but looks like what you need. https://novapackages.com/packages/optimistdigital/nova-sortable

molteber commented 4 years ago

@desaintflorent The gif demo looks very promising! I don't have use for it at the moment, but this is looks certainly like how i thought it would be. Thanks for the share :)

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.