diff options
author | Yorhel <git@yorhel.nl> | 2021-06-04 09:38:19 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-06-04 09:38:21 +0200 |
commit | 7ff0f4b68b402155b92097f7a53e52a5d51ff3db (patch) | |
tree | 3f2e2bdd78d28ce71cbbe4fa6707a20da2ee3781 /elm | |
parent | 5443cbeb23d9c6a3b63aafaff4898377d33165f4 (diff) |
VN listing: Add table options + developer and raw average columns
With additional VN cache columns for the new developers and average
table columns. The developers cache is also used by the AdvSearch to
potentially speed up some queries (and slow down others).
I also changed the popularity and rating caches to smallint. Doesn't
save anything with the current padding, but there's not much point in
using a floating point type when the values get rounded anyway.
Diffstat (limited to 'elm')
-rw-r--r-- | elm/TableOpts.elm | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/elm/TableOpts.elm b/elm/TableOpts.elm index 7dcfec2a..6ecf0aa9 100644 --- a/elm/TableOpts.elm +++ b/elm/TableOpts.elm @@ -50,6 +50,8 @@ type Msg = Open Bool | View Int Bool | Results Int Bool + | Sort Int Bool Bool + | Cols Int Bool | Save | Saved GApi.Response @@ -60,6 +62,8 @@ update msg model = Open b -> ({ model | saved = False, dd = DD.toggle model.dd b }, Cmd.none) View n _ -> ({ model | saved = False, view = n }, Cmd.none) Results n _ -> ({ model | saved = False, results = n }, Cmd.none) + Sort n b _ -> ({ model | saved = False, sort = n, asc = b }, Cmd.none) + Cols n b -> ({ model | cols = if b then B.or model.cols (B.shiftLeftBy n 1) else B.and model.cols (B.xor (B.complement 0) (B.shiftLeftBy n 1)) }, Cmd.none) Save -> ( { model | saved = False, state = Api.Loading } , GTO.send { save = Maybe.withDefault "" model.opts.save , value = if encInt model == model.opts.default then Nothing else Just (encInt model) @@ -90,11 +94,25 @@ view model = div [] , DD.view model.dd Api.Normal (text "display options") (\_ -> [ table [ style "min-width" "300px" ] - [ tr [] [ td [] [ text "Format" ], td [] -- TODO: Icons, or some sort of preview? - [ linkRadio (model.view == 0) (View 0) [ text "Rows" ], text " / " - , linkRadio (model.view == 1) (View 1) [ text "Cards" ], text " / " - , linkRadio (model.view == 2) (View 2) [ text "Grid" ] - ] ] + + -- TODO: Format icons, or some sort of preview? + [ if List.isEmpty model.opts.views then text "" else + tr [] [ td [] [ text "Format" ], td [] <| List.intersperse (text " / ") <| List.map (\o -> + linkRadio (model.view == o) (View o) [ text (if o == 0 then "Rows" else if o == 1 then "Cards" else "Grid") ] + ) model.opts.views ] + + , if List.isEmpty model.opts.sorts then text "" else + tr [] [ td [] [ text "Order by" ], td [] <| List.intersperse (br [] []) <| List.map (\o -> + linkRadio (model.sort == o.id) (Sort o.id (if model.sort == o.id then not model.asc else True)) + [ text o.name + , text <| if model.sort /= o.id then "" else if model.asc then " ▴" else " ▾" ] + ) model.opts.sorts ] + + , if List.isEmpty model.opts.vis then text "" else + tr [] [ td [] [ text "Visible", br [] [], text "columns" ], td [] <| List.intersperse (br [] []) <| List.map (\o -> + linkRadio (B.and model.cols (B.shiftLeftBy o.id 1) > 0) (Cols o.id) [ text o.name ] + ) model.opts.vis ] + , tr [] [ td [] [ text "Results" ], td [] [ linkRadio (model.results == 1) (Results 1) [ text "10" ], text " / " , linkRadio (model.results == 2) (Results 2) [ text "25" ], text " / " @@ -102,6 +120,7 @@ view model = div [] , linkRadio (model.results == 3) (Results 3) [ text "100" ], text " / " , linkRadio (model.results == 4) (Results 4) [ text "200" ] ] ] + , tr [] [ td [] [], td [] [ input [ type_ "submit", class "submit", value "Update" ] [] , case (model.opts.save, model.saved) of |