Skip to content

Commit

Permalink
feat(textile): implement trims. (#873)
Browse files Browse the repository at this point in the history
Reuse the Object UI component, logic and code api to add and quantify
them in the Textile UI as well. Introduce new API endpoint and parameter
to allow defining garment trims.
  • Loading branch information
n1k0 authored Jan 2, 2025
1 parent e28ad14 commit c9f3b20
Show file tree
Hide file tree
Showing 36 changed files with 2,649 additions and 2,098 deletions.
1 change: 1 addition & 0 deletions bin/build-db
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const elmWithFixtures = elmTemplate
"id",
),
)
.replace("%textileComponentsJson%", parseAndValidate("public/data/textile/components.json", "id"))
.replace(
"%textileProductExamplesJson%",
parseAndValidate("public/data/textile/examples.json", "id"),
Expand Down
66 changes: 66 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ paths:
- $ref: "#/components/parameters/traceabilityParam"
- $ref: "#/components/parameters/upcycledParam"
- $ref: "#/components/parameters/physicalDurabilityParam"
- $ref: "#/components/parameters/trimsParam"
responses:
200:
description: Opération réussie
Expand Down Expand Up @@ -178,6 +179,7 @@ paths:
- $ref: "#/components/parameters/traceabilityParam"
- $ref: "#/components/parameters/upcycledParam"
- $ref: "#/components/parameters/physicalDurabilityParam"
- $ref: "#/components/parameters/trimsParam"
responses:
200:
description: successful operation
Expand Down Expand Up @@ -253,6 +255,7 @@ paths:
- $ref: "#/components/parameters/traceabilityParam"
- $ref: "#/components/parameters/upcycledParam"
- $ref: "#/components/parameters/physicalDurabilityParam"
- $ref: "#/components/parameters/trimsParam"
responses:
200:
description: Opération réussie
Expand Down Expand Up @@ -295,6 +298,18 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/InvalidParametersError"
/textile/trims:
get:
tags:
- Textile
summary: Liste des accessoires pour vêtements
responses:
200:
description: Opération réussie
content:
application/json:
schema:
$ref: "#/components/schemas/TrimListResponse"
/food/countries:
get:
tags:
Expand Down Expand Up @@ -1112,6 +1127,33 @@ components:
type: number
minimum: 0.67
maximum: 1.45
trimsParam:
name: "trims[]"
in: query
description: |
Liste des accessoires du vêtement (boutons, zip, etc). La chaîne est composée d'une quantité
et d'un identifiant d'accessoire, séparés par un point-virgule (`;`). Par exemple:
- `1;0e8ea799-9b06-490c-a925-37564746c454` pour une fermeture éclair
- `4;0c903fc7-279b-4375-8cfa-ca8133b8e973` pour quatre boutons en acier
La liste des accessoires disponibles est accessible sur le point d'entrée `/textile/trims`.
required: false
style: form
schema:
type: array
items:
type: string
examples:
zip:
summary: "Une fermeture éclair"
value: ["1;0e8ea799-9b06-490c-a925-37564746c454"]
fourButtons:
summary: "4 boutons en métal"
value: ["4;0c903fc7-279b-4375-8cfa-ca8133b8e973"]
oneButtonAndOneZip:
summary: "Un bouton en métal et une fermeture éclair"
value: ["1;0c903fc7-279b-4375-8cfa-ca8133b8e973", "1;0e8ea799-9b06-490c-a925-37564746c454"]
schemas:
Impacts:
type: object
Expand Down Expand Up @@ -1301,6 +1343,20 @@ components:
type: number
minimum: 0.67
maximum: 1.45
trims:
description: |
Liste des accessoires du vêtement (boutons, zip, etc).
La liste des accessoires disponibles est accessible sur le point d'entrée `/textile/trims`.
type: array
items:
type: object
properties:
id:
type: string
format: uuid
quantity:
type: integer
minimum: 0
TextileQueryMaterial:
type: object
additionalProperties: false
Expand Down Expand Up @@ -1445,6 +1501,16 @@ components:
type: string
name:
type: string
TrimListResponse:
type: array
description: Liste des accessoires pour vêtements
items:
type: object
properties:
id:
type: string
name:
type: string
RecipeResultsResponse:
type: object
description: |
Expand Down
2 changes: 1 addition & 1 deletion public/data/textile/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]
},
{
"id": "0e8ea799-9b06-490c-a925-37564746c454",
"id": "d56bb0d5-7999-4b8b-b076-94d79099b56a",
"name": "Bouton en plastique",
"processes": [
{
Expand Down
6 changes: 5 additions & 1 deletion public/data/textile/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@
"fading": true,
"marketingDuration": 65,
"numberOfReferences": 100000,
"price": 20
"price": 20,
"trims": [
{ "quantity": 1, "id": "0c903fc7-279b-4375-8cfa-ca8133b8e973" },
{ "quantity": 1, "id": "0e8ea799-9b06-490c-a925-37564746c454" }
]
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions public/data/textile/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3042,7 +3042,7 @@
{
"id": "8b91651b-9651-46fc-8bc2-37a141494086",
"name": "steel, low-alloyed//[GLO] market for steel, low-alloyed",
"displayName": "",
"displayName": "Acier",
"unit": "kg",
"source": "Ecoinvent 3.9.1",
"sourceId": "MTE00149000081182209121",
Expand Down Expand Up @@ -3080,7 +3080,7 @@
{
"id": "2e217ad8-05fa-4a9d-a18d-272fc969848c",
"name": "brass//[RoW] market for brass",
"displayName": "",
"displayName": "Laiton",
"unit": "kg",
"source": "Ecoinvent 3.9.1",
"sourceId": "MTE00149000081182218676",
Expand Down
Loading

0 comments on commit c9f3b20

Please sign in to comment.