Allow to select multiple items for deletion and edit

This commit is contained in:
Eike Kettner
2020-10-23 20:57:19 +02:00
parent c2d8f2b438
commit 55cfc4c908
11 changed files with 1326 additions and 50 deletions

View File

@ -0,0 +1,32 @@
module Data.ItemSelection exposing
( ItemSelection(..)
, isActive
, isSelected
)
import Set exposing (Set)
type ItemSelection
= Inactive
| Active (Set String)
isSelected : String -> ItemSelection -> Bool
isSelected id set =
case set of
Inactive ->
False
Active ids ->
Set.member id ids
isActive : ItemSelection -> Bool
isActive sel =
case sel of
Active _ ->
True
Inactive ->
False

View File

@ -1,12 +1,14 @@
module Data.Items exposing
( concat
, first
, idSet
, length
)
import Api.Model.ItemLight exposing (ItemLight)
import Api.Model.ItemLightGroup exposing (ItemLightGroup)
import Api.Model.ItemLightList exposing (ItemLightList)
import Set exposing (Set)
import Util.List
@ -65,3 +67,15 @@ lastGroup : ItemLightList -> Maybe ItemLightGroup
lastGroup list =
List.reverse list.groups
|> List.head
idSet : ItemLightList -> Set String
idSet items =
List.map idSetGroup items.groups
|> List.foldl Set.union Set.empty
idSetGroup : ItemLightGroup -> Set String
idSetGroup group =
List.map .id group.items
|> Set.fromList