dwyl / mvp

๐Ÿ“ฒ simplest version of the @dwyl app
https://mvp.fly.dev
GNU General Public License v2.0
84 stars 2 forks source link

Feat: `move_item_from_lista_to_listb/4` function for moving `items` between `lists` #427

Closed nelsonic closed 1 year ago

nelsonic commented 1 year ago

To aid with _moving _an item from one list to another, we need a little function.

Todo

Note: this only applies if the list is not "All" which we should not remove items from; That's the whole point of the "All" list ...

Thankfully we already have two helper functions we can call for this:

https://github.com/dwyl/mvp/blob/15af0f1158b00bc059bd7b2fc9c118ae4313fcbf/lib/app/list.ex#L171-L176

and:

https://github.com/dwyl/mvp/blob/15af0f1158b00bc059bd7b2fc9c118ae4313fcbf/lib/app/list.ex#L189-L199

So this should be relatively straightforward. ๐Ÿ’ญ

nelsonic commented 1 year ago

This is the function:

  def move_item_from_lista_to_listb(item_cid, lista_cid, listb_cid, person_id) do
    # Remove from List A:
    remove_item_from_list(item_cid, lista_cid, person_id)
    # Add to List B:
    add_item_to_list(item_cid, listb_cid, person_id)
  end

Like I said above, it's simple. Because we already had the two precursor functions thanks to #422

But I'm now thinking that from an Interface perspective what we actually want to do is update the whole list.seq from the client so that we preserve the sequence of the items ... ๐Ÿ’ญ

nelsonic commented 1 year ago

Included in #165 :shipit: If we decide not to use it, easy to remove. ๐Ÿ‘Œ