Skip to content

Commit a97a2ae

Browse files
authored
Merge pull request #238 from phanirithvij/pagination-on-top
style(ui): in Options page show pagination on both top and bottom
2 parents fb029e7 + 382c29a commit a97a2ae

File tree

1 file changed

+64
-42
lines changed

1 file changed

+64
-42
lines changed

ui/src/Main/View/Page/Recipe.elm

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main.View.Page.Recipe exposing (..)
22

3-
import Html exposing (Html, a, code, div, h5, span, text)
4-
import Html.Attributes exposing (attribute, class, href, id, style, title)
3+
import Html exposing (Html, a, button, code, div, h5, span, text)
4+
import Html.Attributes exposing (attribute, class, disabled, href, id, style, title)
55
import Main.Config exposing (..)
66
import Main.Config.App exposing (..)
77
import Main.Helpers.AppUrl exposing (..)
@@ -18,50 +18,13 @@ import Main.View.Page.App exposing (..)
1818

1919
viewPageRecipeOptions : Model -> PageRecipeOptions -> Html Update
2020
viewPageRecipeOptions model pageRecipeOptions =
21-
let
22-
routeRecipeOptions =
23-
pageRecipeOptions.pageRecipeOptions_route
24-
25-
routePagePrev =
26-
Route_RecipeOptions
27-
{ routeRecipeOptions
28-
| routeRecipeOptions_page = Just (pageRecipeOptions.pageRecipeOptions_page - 1)
29-
}
30-
31-
routePageNext =
32-
Route_RecipeOptions
33-
{ routeRecipeOptions
34-
| routeRecipeOptions_page = Just (pageRecipeOptions.pageRecipeOptions_page + 1)
35-
}
36-
in
3721
div []
38-
[ div [ class "list-group" ]
22+
[ viewPageRecipePageNavigators pageRecipeOptions
23+
, div [ class "list-group" ]
3924
(model.model_RecipeOptions.modelRecipeOptions_filtered
4025
|> List.map (viewPageRecipeOption model pageRecipeOptions)
4126
)
42-
, div [ class "d-flex justify-content-center align-items-center" ]
43-
[ if 1 < pageRecipeOptions.pageRecipeOptions_page then
44-
Html.button
45-
[ class "btn"
46-
, onClick (Update_Route routePagePrev)
47-
]
48-
[ text "Prev" ]
49-
50-
else
51-
text ""
52-
, text (pageRecipeOptions.pageRecipeOptions_page |> String.fromInt)
53-
, text " / "
54-
, text (pageRecipeOptions.pageRecipeOptions_LastPage |> String.fromInt)
55-
, if pageRecipeOptions.pageRecipeOptions_page < pageRecipeOptions.pageRecipeOptions_LastPage then
56-
Html.button
57-
[ class "btn"
58-
, onClick (Update_Route routePageNext)
59-
]
60-
[ text "Next" ]
61-
62-
else
63-
text ""
64-
]
27+
, viewPageRecipePageNavigators pageRecipeOptions
6528
]
6629

6730

@@ -122,3 +85,62 @@ viewRecipeOptionsLink =
12285
, onClick (Update_Route onClickRoute)
12386
]
12487
[ text "Options" ]
88+
89+
90+
viewPageRecipePageNavigators : PageRecipeOptions -> Html Update
91+
viewPageRecipePageNavigators pageRecipeOptions =
92+
let
93+
routeRecipeOptions =
94+
pageRecipeOptions.pageRecipeOptions_route
95+
96+
routePagePrev =
97+
Route_RecipeOptions
98+
{ routeRecipeOptions
99+
| routeRecipeOptions_page = Just (pageRecipeOptions.pageRecipeOptions_page - 1)
100+
}
101+
102+
routePageNext =
103+
Route_RecipeOptions
104+
{ routeRecipeOptions
105+
| routeRecipeOptions_page = Just (pageRecipeOptions.pageRecipeOptions_page + 1)
106+
}
107+
in
108+
div [ class "d-flex justify-content-center align-items-center my-2" ]
109+
[ if 1 < pageRecipeOptions.pageRecipeOptions_page then
110+
button
111+
[ class "btn me-2 focus-ring"
112+
, onClick (Update_Route routePagePrev)
113+
]
114+
[ text "Prev" ]
115+
116+
else
117+
button
118+
[ class "btn me-2 border-0"
119+
, disabled True
120+
]
121+
[ text "Prev" ]
122+
, span
123+
[ style "width" "2rem"
124+
, style "text-align" "center"
125+
]
126+
[ text (pageRecipeOptions.pageRecipeOptions_page |> String.fromInt) ]
127+
, text "/"
128+
, span
129+
[ style "width" "2rem"
130+
, style "text-align" "center"
131+
]
132+
[ text (pageRecipeOptions.pageRecipeOptions_LastPage |> String.fromInt) ]
133+
, if pageRecipeOptions.pageRecipeOptions_page < pageRecipeOptions.pageRecipeOptions_LastPage then
134+
button
135+
[ class "btn ms-2 focus-ring"
136+
, onClick (Update_Route routePageNext)
137+
]
138+
[ text "Next" ]
139+
140+
else
141+
button
142+
[ class "btn ms-2 border-0"
143+
, disabled True
144+
]
145+
[ text "Next" ]
146+
]

0 commit comments

Comments
 (0)