mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-03 18:00:11 +00:00 
			
		
		
		
	Merge pull request #644 from eikek/show-item-position
Show item position in detail view
This commit is contained in:
		@@ -85,6 +85,19 @@ menuBar inav settings model =
 | 
			
		||||
                            [ title ("Previous item." ++ keyDescr "Ctrl-,")
 | 
			
		||||
                            ]
 | 
			
		||||
                        }
 | 
			
		||||
                    , div
 | 
			
		||||
                        [ classList [ ( "hidden", inav.index == Nothing ) ]
 | 
			
		||||
                        , class S.secondaryBasicButtonMain
 | 
			
		||||
                        , class " px-4 py-2 border-t border-b border-r opacity-75"
 | 
			
		||||
                        ]
 | 
			
		||||
                        [ Maybe.map ((+) 1) inav.index
 | 
			
		||||
                            |> Maybe.map String.fromInt
 | 
			
		||||
                            |> Maybe.withDefault ""
 | 
			
		||||
                            |> text
 | 
			
		||||
                        , text " / "
 | 
			
		||||
                        , String.fromInt inav.length
 | 
			
		||||
                            |> text
 | 
			
		||||
                        ]
 | 
			
		||||
                    , B.genericButton
 | 
			
		||||
                        { label = ""
 | 
			
		||||
                        , icon = "fa fa-caret-right"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,43 @@
 | 
			
		||||
module Data.ItemNav exposing (ItemNav)
 | 
			
		||||
module Data.ItemNav exposing (ItemNav, fromList)
 | 
			
		||||
 | 
			
		||||
import Api.Model.ItemLight exposing (ItemLight)
 | 
			
		||||
import Api.Model.ItemLightList exposing (ItemLightList)
 | 
			
		||||
import Util.List
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
type alias ItemNav =
 | 
			
		||||
    { prev : Maybe String
 | 
			
		||||
    , next : Maybe String
 | 
			
		||||
    , index : Maybe Int
 | 
			
		||||
    , length : Int
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fromList : ItemLightList -> String -> ItemNav
 | 
			
		||||
fromList list id =
 | 
			
		||||
    let
 | 
			
		||||
        all : List ItemLight
 | 
			
		||||
        all =
 | 
			
		||||
            List.concatMap .items list.groups
 | 
			
		||||
 | 
			
		||||
        next =
 | 
			
		||||
            Util.List.findNext (\i -> i.id == id) all
 | 
			
		||||
                |> Maybe.map .id
 | 
			
		||||
 | 
			
		||||
        prev =
 | 
			
		||||
            Util.List.findPrev (\i -> i.id == id) all
 | 
			
		||||
                |> Maybe.map .id
 | 
			
		||||
 | 
			
		||||
        len =
 | 
			
		||||
            List.length all
 | 
			
		||||
 | 
			
		||||
        index : Maybe Int
 | 
			
		||||
        index =
 | 
			
		||||
            Util.List.findIndexed (.id >> (==) id) all
 | 
			
		||||
                |> Maybe.map Tuple.second
 | 
			
		||||
    in
 | 
			
		||||
    { prev = prev
 | 
			
		||||
    , next = next
 | 
			
		||||
    , index = index
 | 
			
		||||
    , length = len
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -227,16 +227,7 @@ searchTypeString st =
 | 
			
		||||
 | 
			
		||||
itemNav : String -> Model -> ItemNav
 | 
			
		||||
itemNav id model =
 | 
			
		||||
    let
 | 
			
		||||
        prev =
 | 
			
		||||
            Comp.ItemCardList.prevItem model.itemListModel id
 | 
			
		||||
 | 
			
		||||
        next =
 | 
			
		||||
            Comp.ItemCardList.nextItem model.itemListModel id
 | 
			
		||||
    in
 | 
			
		||||
    { prev = Maybe.map .id prev
 | 
			
		||||
    , next = Maybe.map .id next
 | 
			
		||||
    }
 | 
			
		||||
    Data.ItemNav.fromList model.itemListModel.results id
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
doSearchCmd : SearchParam -> Model -> Cmd Msg
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user