File tree Expand file tree Collapse file tree 4 files changed +37
-2
lines changed
resources/views/components Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,25 @@ Just add a `group` string prop to a `laravel-blade-sortable::sortable` component
237237
238238![ drag-drop] ( https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/drag-drop.gif )
239239
240+ ### Enable/Disable sorting and/or drop
241+
242+ Use ` :allow-sort=true|false ` and ` :allow-drop=true|false ` to ` x-laravel-blade-sortable::sortable ` components
243+ to enable/disable sorting and/or drop of elements.
244+
245+ Both defaults to ` true ` .
246+
247+ ``` blade
248+ <x-laravel-blade-sortable::sortable
249+ group="people"
250+ :allow-sort="false"
251+ :allow-drop="false"
252+ >
253+ {{-- Items here --}}
254+ </x-laravel-blade-sortable::sortable>
255+ ```
256+
257+ ![ disable-sort-drop] ( https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/disable-sort-drop.gif )
258+
240259### Testing
241260
242261``` bash
Original file line number Diff line number Diff line change 77 ghostClass: ' ' ,
88 dragHandle: null ,
99 group: null ,
10+ allowSort: true ,
11+ allowDrop: true ,
1012
1113 wireComponent: null ,
1214 wireOnSortOrderChange: null ,
1820 handle: this .dragHandle ,
1921 animation: this .animation ,
2022 ghostClass: this .ghostClass ,
21- group: this .group ,
23+ group: {
24+ name: this .group ,
25+ put: this .allowDrop ,
26+ },
27+ sort: this .allowSort ,
2228 onSort : evt => {
2329 const previousSortOrder = [... this .sortOrder ]
2430 this .sortOrder = this .computeSortOrderFromChildren ()
Original file line number Diff line number Diff line change @@ -22,13 +22,19 @@ class Sortable extends Component
2222
2323 public $ group ;
2424
25+ public $ allowDrop ;
26+
27+ public $ allowSort ;
28+
2529 public function __construct ($ as = null ,
2630 $ component = null ,
2731 $ name = null ,
2832 $ animation = 150 ,
2933 $ ghostClass = '' ,
3034 $ dragHandle = null ,
31- $ group = null )
35+ $ group = null ,
36+ $ allowSort = true ,
37+ $ allowDrop = true )
3238 {
3339 $ this ->as = $ as ;
3440 $ this ->component = $ component ;
@@ -37,6 +43,8 @@ public function __construct($as = null,
3743 $ this ->ghostClass = $ ghostClass ;
3844 $ this ->dragHandle = $ dragHandle ;
3945 $ this ->group = $ group ;
46+ $ this ->allowDrop = $ allowDrop ;
47+ $ this ->allowSort = $ allowSort ;
4048 }
4149
4250 public function xInit ()
@@ -57,6 +65,8 @@ public function xInit()
5765 ->push ($ hasGroup ? "group = ' {$ this ->group }' " : null )
5866 ->push ($ hasWireOnSortOrderChangeDirective ? 'wireComponent = $wire ' : null )
5967 ->push ($ hasWireOnSortOrderChangeDirective ? "wireOnSortOrderChange = ' $ wireOnSortOrderChange' " : null )
68+ ->push ($ this ->allowSort ? 'allowSort = true ' : 'allowSort = false ' )
69+ ->push ($ this ->allowDrop ? 'allowDrop = true ' : 'allowDrop = false ' )
6070 ->push ('init() ' )
6171 ->filter (function ($ line ) {
6272 return $ line !== null ;
You can’t perform that action at this time.
0 commit comments