farmOS / field-kit

A modular, offline-first companion app to farmOS.
https://farmOS.org
GNU General Public License v3.0
62 stars 39 forks source link

Generate log type buttons in TasksWidget programatically. #340

Open jgaehring opened 4 years ago

jgaehring commented 4 years ago

In the MyLogsWidget, I'm only including Activity, Observation, Input and Harvest buttons, which are all hard-coded. It would be fairly easy to generate buttons for every type of log, programatically, except I couldn't think of a good way of generating a unique and consistent color for each type. That consistency is critical, imo, from a UX perspective. I'm sure there's a way, but I need more time to think about it, which I don't really have as I need to complete the Spraying module ASAP.

This is mostly a matter of enhancing the current feature, but it could become a bug if someone has any of those 4 hardcoded log types disabled.

jgaehring commented 3 years ago

except I couldn't think of a good way of generating a unique and consistent color for each type.

I got bored a few weeks ago and tried implementing a solution to this using a basic hashing algorithm, based on the machine name for the log type. It's on my branch, jgaehring/farmOS-client@d656b89. Works pretty well, based on my test. It's a low priority, but I'm dropping it into the general release milestone for consideration, at least, since the really tricky part seems to be resolved.