You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I started to play with this, and I stumbled on missing filter and group support.
Filter is not so needed, I was for my case able to solve that.
For moving items between lists I need the group attribute however.
Is it possible to add that? I can create PR, but have no experience with ts, so I don't know how to test it end everything..
Thanks for reply, and thanks for these controllers!
In case someone needs this functionaly, it's possible to implement with something like this:
exportdefaultclassextendsSortable{initialize(){super.initialize()this.onAdd=this.onAdd.bind(this)}connect(){super.connect()console.log("SortableController connected")}getoptions(){letoptions=super.optionsoptions["group"]=this.element.dataset.sortableGroupValueoptions["onAdd"]=this.onAddoptions["onRemove"]=this.onRemovereturnoptions}asynconAdd(event){// For now, as I only use this for recipes in DailyPlans, this calls "move".const{ item, newIndex }=eventconstlistId=this.element.dataset.sortableListIdconstmoveUrl=item.dataset.sortableMoveUrlconstparam=this.resourceNameValue ? `${this.resourceNameValue}[${this.paramNameValue}]` : this.paramNameValueconstdata=newFormData()data.append(param,newIndex+1)data.append("daily_plan_id",listId)returnawaitpatch(moveUrl,{body: data,responseKind: this.responseKindValue})}}
onAdd and onRemove are Sortable functions for moving items between lists.
I used most of code from onUpdate for this, with few changes:
I need id of the list item is moved to, so I just add that to ul element. It could be generalized more, but I didn't do that.
In my case, I don't need separate add/remove actions, I can call move endpoint that just changes element attribute. So I only define data-sortable-move-url on my <li> item, as I'm basically PATCHing this resource.
The text was updated successfully, but these errors were encountered:
Hi, I started to play with this, and I stumbled on missing
filter
andgroup
support.Filter is not so needed, I was for my case able to solve that.
For moving items between lists I need the
group
attribute however.Is it possible to add that? I can create PR, but have no experience with
ts
, so I don't know how to test it end everything..Thanks for reply, and thanks for these controllers!
In case someone needs this functionaly, it's possible to implement with something like this:
onAdd
andonRemove
are Sortable functions for moving items between lists.I used most of code from
onUpdate
for this, with few changes:ul
element. It could be generalized more, but I didn't do that.move
endpoint that just changes element attribute. So I only definedata-sortable-move-url
on my<li>
item, as I'm basically PATCHing this resource.The text was updated successfully, but these errors were encountered: