Skip to content

Commit

Permalink
feat: render detailed impacts for staff users.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Jan 6, 2025
1 parent f6abe4c commit 5b5f79c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Page/Explore/Processes.elm
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
module Page.Explore.Processes exposing (table)

import Data.Dataset as Dataset
import Data.Impact as Impact
import Data.Impact.Definition as Definition
import Data.Process as Process exposing (Process)
import Data.Process.Category as ProcessCategory
import Data.Scope exposing (Scope)
import Data.Session as Session exposing (Session)
import Data.Unit as Unit
import Html exposing (..)
import Page.Explore.Table as Table exposing (Column, Table)
import Route
import Views.Format as Format


table : Session -> { detailed : Bool, scope : Scope } -> Table Process String msg
Expand Down Expand Up @@ -76,17 +80,20 @@ baseColumns detailed scope =
]


impactsColumns : Session -> List (Column data comparable msg)
impactsColumns { store } =
impactsColumns : Session -> List (Column Process String msg)
impactsColumns { db, store } =
case store.auth of
Session.Authenticated { staff } ->
if staff then
-- Detailed impacts
[ { label = "Details des impacts"
, toValue = Table.NoValue
, toCell = always (text "ok")
}
]
-- User is admin: add columns for detailed impacts
Definition.trigrams
|> List.map
(\trigram ->
{ label = Definition.toString trigram
, toValue = Table.FloatValue <| .impacts >> Impact.getImpact trigram >> Unit.impactToFloat
, toCell = .impacts >> Format.formatImpact (Definition.get trigram db.definitions)
}
)

else
[]
Expand Down

0 comments on commit 5b5f79c

Please sign in to comment.