elm-sortable-table icon indicating copy to clipboard operation
elm-sortable-table copied to clipboard

Allow reversed initial sort

Open tim-bezhashvyly opened this issue 8 years ago • 7 comments

Currently initial sort can be only ascending but in some cases it is useful to have it reverse (e.g. price, date).

tim-bezhashvyly avatar Nov 17 '16 07:11 tim-bezhashvyly

Possible solutions are either adding 2nd argument to initialSort:

initialSort : String -> Bool -> State
initialSort header isReverse =
  State header isReverse

or if you want to avoid BC break adding a new initialReversedSort (or initialSortReversed):

initialReversedSort : String -> State
initialSort header =
  State header True

Please let me know what do you prefer and I will create a PR.

tim-bezhashvyly avatar Nov 17 '16 11:11 tim-bezhashvyly

Another possible solution is exposing the State type constructor, like

module Table exposing
  ( ...
  , State(State)
  ...
  )

And we could get the initial state by

model =
  { ...
  , tableState = Table.State "Header" True
  ...
  }

2hu12 avatar Sep 05 '17 11:09 2hu12

I think you can do this already by defining the column with the decreasingOrIncreasingBy sorter, no?

ericgj avatar Sep 06 '17 03:09 ericgj

I think you can do this already by defining the column with the decreasingOrIncreasingBy sorter, no?

Close, but not quite. The order will be as expected, but the descending/ascending state will be reversed and displayed incorrectly in the UI.

knuton avatar Jan 04 '18 10:01 knuton

Is there any workaround for enabling this?

BinaryHexer avatar Jun 06 '18 05:06 BinaryHexer

@BinaryHexer You can use a fork by adding the following to elm-package.json:

    "dependency-sources": {
        "evancz/elm-sortable-table": "http://github.com/determined-ai/elm-sortable-table.git"
    },

and the following to package.json in the dependencies stanza:

    "elm-github-install": "1.6.1",

Note that you will need to run yarn run elm-github-install before yarn run elm-make. Finally you should use your own GitHub fork instead of the example one.

gaul avatar Jun 10 '18 23:06 gaul

@gaul Thanks!

But maybe somebody should start maintaining an alternative version of this on elm-packages, because it seems many PRs are pending on this repository and maybe evanz is too busy (understandably so) to maintain this.

BinaryHexer avatar Jun 11 '18 00:06 BinaryHexer