Skip to content

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

@nelsonic

Description

@nelsonic

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

Todo

  • Create the tests: item.cid should be removed from lista and added to listb. πŸ§ͺ
  • Write the function. πŸ§‘β€πŸ’»
  • Ship!! :shipit:

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:

mvp/lib/app/list.ex

Lines 171 to 176 in 15af0f1

def add_item_to_list(item_cid, list_cid, person_id) do
list = get_list_by_cid!(list_cid)
prev_seq = get_list_seq(list)
seq = [item_cid | prev_seq] |> Enum.join(",")
update_list(list, %{seq: seq, person_id: person_id})
end

and:

mvp/lib/app/list.ex

Lines 189 to 199 in 15af0f1

def remove_item_from_list(item_cid, list_cid, person_id) do
list = get_list_by_cid!(list_cid)
# get existing list.seq
seq =
get_list_seq(list)
# remove the item_cid from the list.seq:
|> Useful.remove_item_from_list(item_cid)
|> Enum.join(",")
update_list(list, %{seq: seq, person_id: person_id})
end

So this should be relatively straightforward. πŸ’­

Metadata

Metadata

Assignees

Labels

T25mTime Estimate 25 MinutesdiscussShare your constructive thoughts on how to make progress with this issueelixirPull requests that update Elixir codeenhancementNew feature or enhancement of existing functionalityhelp wantedIf you can help make progress with this issue, please comment!priority-2Second highest priority, should be worked on as soon as the Priority-1 issues are finishedtechnicalA technical issue that requires understanding of the code, infrastructure or dependencies

Type

No type

Projects

Status

βœ… Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions