Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Allow reversed initial sort #9

Open
tim-bezhashvyly opened this issue Nov 17, 2016 · 7 comments
Open

Allow reversed initial sort #9

tim-bezhashvyly opened this issue Nov 17, 2016 · 7 comments

Comments

@tim-bezhashvyly
Copy link
Contributor

tim-bezhashvyly commented Nov 17, 2016

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

@tim-bezhashvyly
Copy link
Contributor Author

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.

@2hu12
Copy link

2hu12 commented Sep 5, 2017

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
  ...
  }

@ericgj
Copy link

ericgj commented Sep 6, 2017

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

@knuton
Copy link

knuton commented Jan 4, 2018

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.

gaul added a commit to gaul/elm-sortable-table that referenced this issue Mar 6, 2018
gaul added a commit to gaul/elm-sortable-table that referenced this issue Mar 6, 2018
@BinaryHexer
Copy link

Is there any workaround for enabling this?

@gaul
Copy link

gaul commented Jun 10, 2018

@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.

@BinaryHexer
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants