Commit d775f14c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[TREE] Sort nodes with id.

parent 855d0457
...@@ -5,7 +5,7 @@ import Prelude hiding (div) ...@@ -5,7 +5,7 @@ import Prelude hiding (div)
import Control.Monad.Cont.Trans (lift) import Control.Monad.Cont.Trans (lift)
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.:), (:=), (~>))
import Data.Array (filter) import Data.Array (filter, sortWith)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq) import Data.Generic.Rep.Eq (genericEq)
import Data.Generic.Rep.Show (genericShow) import Data.Generic.Rep.Show (genericShow)
...@@ -199,10 +199,13 @@ toHtml setReload setState@({tree: (NTree (LNode {id, name, nodeType}) ary)} /\ _ ...@@ -199,10 +199,13 @@ toHtml setReload setState@({tree: (NTree (LNode {id, name, nodeType}) ary)} /\ _
cpt props _ = do cpt props _ = do
folderOpen <- R.useState' true folderOpen <- R.useState' true
let withId (NTree (LNode {id}) _) = id
pure $ H.ul {} pure $ H.ul {}
[ H.li {} [ H.li {}
( [ nodeMainSpan pAction {id, name, nodeType, mCurrentRoute} folderOpen ] ( [ nodeMainSpan pAction {id, name, nodeType, mCurrentRoute} folderOpen ]
<> childNodes setReload folderOpen mCurrentRoute ary <> childNodes setReload folderOpen mCurrentRoute (sortWith withId ary)
) )
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment