mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Merge pull request #644 from eikek/show-item-position
Show item position in detail view
This commit is contained in:
commit
66922263ac
@ -85,6 +85,19 @@ menuBar inav settings model =
|
|||||||
[ title ("Previous item." ++ keyDescr "Ctrl-,")
|
[ 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
|
, B.genericButton
|
||||||
{ label = ""
|
{ label = ""
|
||||||
, icon = "fa fa-caret-right"
|
, 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 =
|
type alias ItemNav =
|
||||||
{ prev : Maybe String
|
{ prev : Maybe String
|
||||||
, next : 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 : String -> Model -> ItemNav
|
||||||
itemNav id model =
|
itemNav id model =
|
||||||
let
|
Data.ItemNav.fromList model.itemListModel.results id
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
doSearchCmd : SearchParam -> Model -> Cmd Msg
|
doSearchCmd : SearchParam -> Model -> Cmd Msg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user