Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,27 @@ class SomeModel extends Eloquent implements Sortable
}
```

### Hiding reorder buttons

If you want to hide the ChevronUp and ChevronDown buttons (move to start/end) and only show the drag handle, you can use the `nova_hide_reorder_buttons` flag:

```diff
class SomeModel extends Eloquent implements Sortable
{
use SortableTrait;

public $sortable = [
'order_column_name' => 'sort_order',
'sort_when_creating' => true,
+ 'nova_hide_reorder_buttons' => true,
];

...
}
```

This is useful if you prefer a cleaner interface with only drag-and-drop sorting enabled.

## Sorting on HasMany relationship

**NB!** The resource can only be sorted on **either** the Index view **or** the HasMany list view, but not both!
Expand Down
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion resources/js/components/ReorderButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="o1-flex o1-items-center">
<slot></slot>
<div class="o1-flex o1-items-center o1-ml-4" v-tooltip="reorderDisabledTooltip" v-if="canSeeReorderButtons">
<div class="o1-flex o1-flex-col">
<div class="o1-flex o1-flex-col" v-if="!hideReorderButtons">
<ChevronUpIcon
@click.stop="!reorderDisabled && $emit('moveToStart')"
:custom-class="{
Expand Down Expand Up @@ -49,6 +49,10 @@ export default {
return canSortResource(this.resource, this.relationshipType);
},

hideReorderButtons() {
return this.resource.nova_hide_reorder_buttons || false;
},

// Returns reason string why reordering is disabled
reorderDisabled() {
if (this.resource.sort_not_allowed) {
Expand Down
1 change: 1 addition & 0 deletions src/Traits/HasSortableRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function serializeForIndex(NovaRequest $request, $fields = null)
'sort_on_index' => $sortability->sortable && ! $sortability->sortOnHasMany,
'sort_on_has_many' => $sortability->sortable && $sortability->sortOnHasMany,
'sort_on_belongs_to' => $sortability->sortable && $sortability->sortOnBelongsTo,
'nova_hide_reorder_buttons' => $sortability->sortable['nova_hide_reorder_buttons'] ?? false,
] : ['sort_not_allowed' => ! ($sortability->canSort ?? true)]);

return array_merge(parent::serializeForIndex($request, $fields), $sortabilityData);
Expand Down