Hi @twain!
With regards to question #2, it sounds like you could simplify things by creating an option set for shirt colors, which would be fetched exclusively on page load and stored client-side. No need to keep querying the database for something as lightweight as a static list of several letters.
I’d create an option set called “Shirt Colors” with options “None”, “Red”, “Blue”, “Green”, “White” as the displays. Then create two additional attributes, called “Letter” (text) and “Order” (number).
For the four color options, the “Letter” attribute values would be text fields with “R”, “B”, “G”, and “W”. The value for “None” would be “-”.
For the “Order” attribute, assign each option a value of 1-5, in whatever order you want them to cycle (it sounds like “None” would be “1”).
Quick aside: you could get even fancier if you wanted and add a “Swatch” attribute (image) for each option, and upload an image (eg: a plain blue/red/green/white square) so your grid actually displays the colors themselves in addition to the letters (set the image dynamically as the background for a Group element inside each cell, and put the letter’s Text element inside that Group).
Set up a new field on whatever data type you’re displaying in the cells where the field type is the “Shirt Color” option set, and set the default value to “None”. Then create a group inside each cell where the data type is “Shirt Color” and the Data Source is “This Cell’s Thing’s Shirt Color”. Set the text (and image, if you’ve done that) inside the group to be Parent Group’s Shirt Color’s Letter, Parent Group’s Shirt Color’s Swatch, etc.
Then, you really just need two workflows, which involve far fewer conditionals and are much easier to manage:
- When clicked, if cell’s Thing’s Shirt Color’s “Order” value < 5, set that cell’s Things’ Shirt Color to the option whose “Order” value is the current Shirt Color’s Order value +1
- When clicked, if cell’s Thing’s Shirt Color’s “Order” value = 5, set that cell’s Things’ Shirt Color to the options whose “Order” value is “1”
Even if you have to use advanced filtering to make these workflows function, the set of options/data they’d be computing are so tiny that it’s very unlikely to cause any performance hiccups. It’s exactly the sort of lightweight data manipulation for which client-side processing is most performant.
Outcome is: the user clicks on a cell, the “Shirt Color” option set value associated with that cell’s Thing iterates by 1 to the next option (or resets to the first), and the cell’s contents inherit the attributes of that option.