Unit displays architecture refactor proposal (February 2023)

Unit displays architecture refactor proposal (February 2023)

Author: @Sayaka Ono

 

What are Unit displays?

Please see the introduction in https://lite-farm.atlassian.net/l/cp/rCoihsHd.
The frontend has a component named “Unit” which handles unit displays (/packages/webapp/src/components/Form/Unit/index.jsx).


User’s farm unit system preference
Users can set Unit system(metric/imperial) in the /farm page.

How does the Unit component look on the app?

simple usage

system generated(pre-populated)

system generated(pre-populated)

Unit is fixed

disabled

“hide label”

inputs do not have a unit inside

automatic conversion

Ways users will interact with value-unit-pairs with examples

https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Ways-users-will-interact-with-value-unit-pairs

When

When the value is(was) pre-populated by the system

When a value is NOT pre-populated by the system or was user created

When

When the value is(was) pre-populated by the system

When a value is NOT pre-populated by the system or was user created

creating

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should determine the value / unit combination

 

In this case, if the total area is equal to or less than 10,890 sqft, it is displayed in ft2.

the user set unit preference should be used

What is the “user set unit preference”? Is it a record-to-record unit(a record has not been created on a creation view) or user’s farm unit system preference (metric/imperial)?

read-only

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should be used
Once pre-populated value is modified, is it considered as a “user created” value? Currently, even if I change the unit to “ft2” and save, “ac” is still shown. Is it a bug?

the user set unit preference should be used






editing

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should be used

the user set unit preference should be used

  • automatic conversion - we will go with easier solution.
    We do not need to see automatic conversion at all for now? (how about the total area?)

 

Instances of unit displays

 

(This is not 100 percent accurate)

 

Path
&
file (29)
(/packages/webapp/src/components)

Number of unique <Unit /> (59)

&

Views

Type
(pre-populated / user input)

Operation
(Create/Read/Edit)

automatic conversion

Note

 

Path
&
file (29)
(/packages/webapp/src/components)

Number of unique <Unit /> (59)

&

Views

Type
(pre-populated / user input)

Operation
(Create/Read/Edit)

automatic conversion

Note

1

crop/:cropId(?)add_management_plan/bed_method

 

file:
/Crop/BedPlan/PureBedForm.jsx

4

 

user input

create

NO

Currently, raw data(what the user has inputted) is stored in the DB.

  • After switching unit system(User’s farm unit system preference), data conversion does not happen.

2

/tasks/:taskId?/read_only

 

file:
/Crop/BedPlan/PurePlanGuidanceForm.jsx

3

-

read

-

 

3

/crop/:cropId?/add_management_plan/broadcast_method

 

file:
/Crop/BroadcastPlan/PureBroadcastForm.jsx

3

  • area used & Estimated seed required: pre-populated

  • user input

create

NO

  • “estimated seed required is calculated by inputting “seeding rate”, but it does not take the unit into account.

The location size does not need a unit?

4

/crop/:cropId?/management_plan/:planId?/edit

 

file:
/Crop/ManagementDetail/EditManagementPlanDetail.jsx

1

user input

edit

NO

 

5

/crop/:cropId?/management_plan/:planId?/details

 

file:
/Crop/ManagementDetail/ManagementPlanDetail.jsx

 

1

-

read

-

 

6

/crop/:cropId?/add_management_plan/planted_already

 

file:
/Crop/PlantedAlready/index.jsx

2

user input

create

NO

 

7

/crop/:cropId?/add_management_plan/container_method

 

file:
/Crop/PlantInContainer/PureContainerForm.jsx

5 (4)

 

These should be combined

user input

create

NO

  1. # of plants → “1”. Estimated seed required input is displayed.
    # of plants → “10”
    the input disappears. ?

  2. after switching a unit for the calculated input, the calculation does not change.


8

/crop/:cropId?/add_management_plan/plant_date

 

condition:
already_in_ground && is_wild && !needs_transplant

 

file:
/Crop/PlantingDate/NextHarvest.jsx

1

user input

create

NO

 

9

/crop/:cropId?/add_management_plan/plant_date

 

condition:
!(already_in_ground && is_wild && !needs_transplant)

 

file:
/Crop/PlantingDate/PurePlantingDate.jsx

1

user input

create

NO

 

10

/crop/:cropId?/add_management_plan/final_planting_method

condition:

is_planting_method_known === false && showIsPlantingMethodKnown && isFinalPlantingMethod

 

file:
/Crop/PlantingMethod/PureManagementPlanPlantingMethod.jsx

1

user input

create

NO

 

11

/crop/:cropId?/add_management_plan/row_method

 

the component is used for #2

 

file:
/Crop/RowMethod/PureRowForm.jsx

5

user input

create

NO

Estimated seed 20lb (not “stored as” unit) was saved in the DB

12

/finances/estimated_revenue/plan/:planId

 

file:
/Finances/UpdateEstimatedCropRevenue/index.jsx

2

user input

create/edit?

NO

the first unit should be $/kg or $/mt? “Estimated annual revenue” does not change by changing units.

13

/add_sale

/edit_sale

 

file:
/Inputs/CropVarietySale/index.jsx

2

user input

create

edit

-

the style for the quantity input is different from others

 

  • <Unit /> does not need to be used for $…

14

/create_location/ceremonial_area etc.

 

file:
/LocationDetailLayout/AreaDetails/AreaDetails.jsx

2

pre-populated

create

NO

 

15

/create_location/buffer_zone

/buffer_zone/:bufferId?/details

 

file:
/LocationDetailLayout/LineDetails/BufferZone/index.jsx

2

pre-populated

create

read

edit

NO

 

16

/create_location/fence

 

file:
/LocationDetailLayout/LineDetails/Fence/index.jsx

1

pre-populated

create

NO

 

17

/create_location/watercourse

/watercourse/84cb7da8-abe9-11ed-8b70-e66db4bef551/details

 

file:
/LocationDetailLayout/LineDetails/Watercourse/index.jsx

4

pre-populated / user input

create

read

edit

NO

 

18

/sensor/:sensorId?/details

 

file:
/LocationDetailLayout/PointDetails/Sensor/index.jsx

1

-

read

-

0.87cm???

After adding sensors with “150cm” and “200cm”, they were shown as “1.5m” and “2cm”.

19

/create_location/water_valve

 

file:
/LocationDetailLayout/PointDetails/WaterValve/index.jsx

1

user input

create

NO

 

20

/map
(location - watercourse)

 

file:
/Map/LineMapBoxes/index.jsx

2

pre-populated

create

-

 

21

/add_task/task_details

 

file:
/Modals/WaterUsageCalculatorModal/index.jsx

6

volume
depth

user input

create

YES

 

22

/sensor/:sensorId?/edit

 

file:
/Sensor/EditSensor.jsx

1

pre-populated (reading the data in DB)

edit

NO

 

23

/add_task/task_details

 

file:
/Task/AddProduct/index.jsx

1

soil amendment

user input

create

NO

 

24

/add_task/task_details

 

file:
/Task/CleaningTask/index.jsx

1

user input

create

NO

 

25

/add_task/task_details

 

file:/Task/HarvestingTask/index.jsx