Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: small textile explorer improvements #773

Merged
merged 11 commits into from
Oct 3, 2024
40 changes: 1 addition & 39 deletions public/data/textile/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2583,44 +2583,6 @@
"waste": 0,
"alias": "passenger-car"
},
{
"name": "Mise en décharge de textiles, FR",
"displayName": "Mise en décharge de textiles, FR",
"info": "Traitement de fin de vie > Mise en décharge > Fractions de déchets",
"unit": "kg",
"source": "Ecobalyse",
"correctif": "Précalcul Ecobalyse à partir de Base Impacts",
"step_usage": "Utilisation",
"uuid": "9adaf403-4eda-4d9c-80c3-f231754644ca",
"impacts": {
"acd": 0,
"cch": 0,
"etf": 0,
"etf-c": 0,
"fru": 0,
"fwe": 0,
"htc": 0,
"htc-c": 0,
"htn": 0,
"htn-c": 0,
"ior": 0,
"ldu": 0,
"mru": 0,
"ozd": 0,
"pco": 0,
"pma": 0,
"swe": 0,
"tre": 0,
"wtu": 0,
"ecs": 66.8698252969278,
"pef": 68.14941102161761
},
"heat_MJ": 0,
"elec_pppm": 0,
"elec_MJ": 0,
"waste": 0,
"alias": null
},
{
"name": "Fin de vie hors voiture (transport en camion, incinération, mise en décharge)",
"displayName": "Fin de vie hors voiture (transport en camion, incinération, mise en décharge)",
Expand Down Expand Up @@ -2964,7 +2926,7 @@
"alias": "dyeing-cellulosic-fiber"
},
{
"name": "Blanchiment",
"name": "bleaching, textile//[RoW] bleaching, textile",
"displayName": "Blanchiment",
"info": "Textile > Ennoblissement > Blanchiment",
"unit": "kg",
Expand Down
6 changes: 5 additions & 1 deletion src/Data/Gitbook.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Path
| FoodTransformation -- Transformation des ingrédients
| FoodTransport -- Transport entre étapes
| FoodUse -- Consommation
| TextileCircularFootprintFormula -- Circular Footprint Formula (CFF)
| TextileComplementMicrofibers -- Complément textile microfibres
| TextileDistribution -- Distribution textile
| TextileDurability -- Durabilité textile
Expand Down Expand Up @@ -69,6 +70,9 @@ pathToString path =
FoodUse ->
"alimentaire/etapes-du-cycles-de-vie/consommation"

TextileCircularFootprintFormula ->
"textile/cycle-de-vie-des-produits-textiles/circular-footpring-formula-cff"

TextileComplementMicrofibers ->
"textile/complements-hors-acv/microfibres"

Expand Down Expand Up @@ -124,7 +128,7 @@ pathToString path =
"textile/etapes-du-cycle-de-vie/etape-1-matieres"

TextileSpinning ->
"textile/etapes-du-cycle-de-vie/etape-2-fabrication-du-fil-new"
"textile/cycle-de-vie-des-produits-textiles/etape-2-fabrication-du-fil"

TextileTransport ->
"textile/parametres-transverses/transport"
Expand Down
13 changes: 0 additions & 13 deletions src/Page/Explore/Common.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module Page.Explore.Common exposing
( boolText
, impactBarGraph
, scopesView
)

import Data.Scope as Scope exposing (Scope)
import Html exposing (..)
import Html.Attributes exposing (..)
import Views.Format as Format
Expand All @@ -19,17 +17,6 @@ boolText bool =
"non"


scopesView : { a | scopes : List Scope } -> Html msg
scopesView =
.scopes
>> List.map
(\scope ->
span [ class "badge badge-success" ]
[ text <| Scope.toLabel scope ]
)
>> div [ class "d-flex gap-1" ]


impactBarGraph : Bool -> Float -> Float -> Html msg
impactBarGraph detailed max score =
let
Expand Down
6 changes: 0 additions & 6 deletions src/Page/Explore/Countries.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Data.Transport as Transport
import Dict.Any as Dict
import Html exposing (..)
import Html.Attributes exposing (..)
import Page.Explore.Common as Common
import Page.Explore.Table as Table exposing (Table)
import Route
import Views.Format as Format
Expand Down Expand Up @@ -68,11 +67,6 @@ table distances countries { detailed, scope } =

else
Nothing
, Just
{ label = "Domaines"
, toValue = Table.StringValue <| .scopes >> List.map Scope.toLabel >> String.join "/"
, toCell = Common.scopesView
}
, if detailed then
Just
{ label = "Distances"
Expand Down
24 changes: 12 additions & 12 deletions src/Page/Explore/Impacts.elm
Original file line number Diff line number Diff line change
Expand Up @@ -41,45 +41,45 @@ table { detailed, scope } =
, toValue = Table.StringValue <| .unit
, toCell = \def -> code [] [ text def.unit ]
}
, { label = "Normalisation (PEF)"
, { label = "Normalisation (Coût Evt)"
, toValue =
Table.FloatValue <|
.pefData
.ecoscoreData
>> Maybe.map (.normalization >> Unit.impactToFloat)
>> Maybe.withDefault 0
, toCell =
\def ->
def.pefData
def.ecoscoreData
|> Maybe.map (.normalization >> Unit.impactToFloat >> Format.formatRichFloat 2 def.unit)
|> Maybe.withDefault (text "N/A")
}
, { label = "Pondération (PEF)"
, { label = "Pondération (Coût Evt)"
, toValue =
Table.FloatValue <|
.pefData
.ecoscoreData
>> Maybe.map (.weighting >> Split.toFloat)
>> Maybe.withDefault 0
, toCell = .pefData >> Maybe.map (.weighting >> Format.splitAsPercentage 2) >> Maybe.withDefault (text "N/A")
, toCell = .ecoscoreData >> Maybe.map (.weighting >> Format.splitAsPercentage 2) >> Maybe.withDefault (text "N/A")
}
, { label = "Normalisation (Sc. Imp.)"
, { label = "Normalisation (PEF)"
, toValue =
Table.FloatValue <|
.ecoscoreData
.pefData
>> Maybe.map (.normalization >> Unit.impactToFloat)
>> Maybe.withDefault 0
, toCell =
\def ->
def.ecoscoreData
def.pefData
|> Maybe.map (.normalization >> Unit.impactToFloat >> Format.formatRichFloat 2 def.unit)
|> Maybe.withDefault (text "N/A")
}
, { label = "Pondération (Sc. Imp.)"
, { label = "Pondération (PEF)"
, toValue =
Table.FloatValue <|
.ecoscoreData
.pefData
>> Maybe.map (.weighting >> Split.toFloat)
>> Maybe.withDefault 0
, toCell = .ecoscoreData >> Maybe.map (.weighting >> Format.splitAsPercentage 2) >> Maybe.withDefault (text "N/A")
, toCell = .pefData >> Maybe.map (.weighting >> Format.splitAsPercentage 2) >> Maybe.withDefault (text "N/A")
}
, { label = "Description"
, toValue = Table.StringValue .description
Expand Down
56 changes: 33 additions & 23 deletions src/Page/Explore/TextileMaterials.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Page.Explore.TextileMaterials exposing (table)

import Data.Country as Country
import Data.Dataset as Dataset
import Data.Gitbook as Gitbook
import Data.Scope exposing (Scope)
import Data.Split as Split
import Data.Textile.Material as Material exposing (Material)
Expand All @@ -14,6 +15,8 @@ import Route
import Static.Db exposing (Db)
import Views.Alert as Alert
import Views.Format as Format
import Views.Icon as Icon
import Views.Link as Link


recycledToString : Maybe Material.Id -> String
Expand All @@ -25,6 +28,12 @@ recycledToString maybeMaterialID =

table : Db -> { detailed : Bool, scope : Scope } -> Table Material String msg
table db { detailed, scope } =
let
withPill url content =
div
[ classList [ ( "text-center", not detailed ) ] ]
[ content, Link.smallPillExternal [ href (Gitbook.publicUrlFromPath url) ] [ Icon.question ] ]
in
{ filename = "materials"
, toId = .id >> Material.idToString
, toRoute = .id >> Just >> Dataset.TextileMaterials >> Route.Explore scope
Expand Down Expand Up @@ -64,16 +73,19 @@ table db { detailed, scope } =
, { label = "Complément Microfibres"
, toValue = Table.FloatValue <| .origin >> Origin.toMicrofibersComplement >> Unit.impactToFloat
, toCell =
\{ origin } ->
div [ classList [ ( "text-center", not detailed ) ] ]
[ Origin.toMicrofibersComplement origin
|> Unit.impactToFloat
|> Format.formatImpactFloat { unit = "\u{202F}Pts/kg", decimals = 2 }
]
.origin
>> Origin.toMicrofibersComplement
>> Unit.impactToFloat
>> Format.formatImpactFloat { unit = "\u{202F}Pts/kg", decimals = 2 }
>> withPill Gitbook.TextileComplementMicrofibers
}
, { label = "Procédé de fabrication du fil"
, toValue = Table.StringValue <| .origin >> Origin.threadProcess
, toCell = .origin >> Origin.threadProcess >> text
, toCell =
.origin
>> Origin.threadProcess
>> text
>> withPill Gitbook.TextileSpinning
}
, { label = "Procédé de recyclage"
, toValue = Table.StringValue <| .recycledProcess >> Maybe.map .name >> Maybe.withDefault "N/A"
Expand Down Expand Up @@ -112,14 +124,13 @@ table db { detailed, scope } =
>> Maybe.map (.manufacturerAllocation >> Split.toFloat)
>> Maybe.withDefault 0
, toCell =
\{ cffData } ->
case cffData of
Just { manufacturerAllocation } ->
manufacturerAllocation
|> Format.splitAsFloat 1

Nothing ->
text "N/A"
.cffData
>> Maybe.map
(.manufacturerAllocation
>> Format.splitAsFloat 1
>> withPill Gitbook.TextileCircularFootprintFormula
)
>> Maybe.withDefault (text "N/A")
}
, { label = "CFF: Rapport de qualité"
, toValue =
Expand All @@ -128,14 +139,13 @@ table db { detailed, scope } =
>> Maybe.map (.recycledQualityRatio >> Split.toFloat)
>> Maybe.withDefault 0
, toCell =
\{ cffData } ->
case cffData of
Just { recycledQualityRatio } ->
recycledQualityRatio
|> Format.splitAsFloat 1

Nothing ->
text "N/A"
.cffData
>> Maybe.map
(.recycledQualityRatio
>> Format.splitAsFloat 1
>> withPill Gitbook.TextileCircularFootprintFormula
)
>> Maybe.withDefault (text "N/A")
}
]
}