Idea/brainstorm (search, add, repeat)

  • buildingintoddle-1319816965845684255

    alain

    4 months ago

    Hello team,

    Does anyone have any ideas on how I could achieve a functionality that goes like this:

    1. Search backend table of an exercise database via an input field
    2. Press enter to select
    3. The entered exercise gets added to repeating div formatted nicely like a card with a bunch of info.
    4. Can add and delete them
    1319816966374162473-image.png
  • tomthebigtree-1320046129303388160

    Tom Ireland

    4 months ago

    Yes, Alain. Do you have a database you're using already for this e.g. Supabase, Xano, etc.?
  • buildingintoddle-1320195525953458259

    alain

    4 months ago

    hey tom! im using Xano currently
  • nothing really in it right now all i have is authentication
  • buildingintoddle-1320195817956577291

    alain

    4 months ago

    im watching the shopping cart tutorial right now, it seems like theres some similar logic I could learn there
    👍1
  • Tod-1320195823077818439

    Tod

    4 months ago

    Great energy @alain! Your continuous contribution to the toddle Community just made you advance to Community Level 2!
  • tomthebigtree-1320277180390969517

    Tom Ireland

    4 months ago

    It’s worth having a think about the data model, for example would you search by muscle like tricep, bicep, etc. What could you filter specifically using a category vs wildcard search. You could do both of course.

    A few of the backend appreciation month live videos the toddle crew did feature search a lot and you could use debounce to prevent hammering your API.
    ❤️1
  • tomthebigtree-1320278054848827423

    Tom Ireland

    4 months ago

    I’m doing something similar at the moment for a couple of dropdown options but instead of refetching API results, I’m doing one call and then filtering on the front end.
    ❤️1
  • buildingintoddle-1320437478200442931

    alain

    4 months ago

    Would the benefit of doing it that way save on resources so you wouldn’t have to do so many API calls?
  • buildingintoddle-1320437873446490132

    alain

    4 months ago

    This is the type of functionality I’m trying to recreate with a better UI
    1320437873211867159-IMG_7655.png
  • buildingintoddle-1320438437844881499

    alain

    4 months ago

    From what I see there is:

    1. An array that dynamically populates for every set of an exercise (which has inputs for lbs reps weight etc )
    2. A cumulative array that keeps tracks of the entire workout
  • buildingintoddle-1320440389144154123

    alain

    4 months ago

    So far I was able to make a simple to do list type function that appends an array,

    Right now I’m trying to figure out how to make that to do list function he able to have 3 inputs sets reps weight instead of just one string input
  • tomthebigtree-1320452934047236127

    Tom Ireland

    4 months ago

    Yeah, the main benefit is to prevent hitting your API so much but it depends on the use case.

    If I was approaching this scenario, I'd do everything from the front end (maybe store in local storage to prevent accidental loss of data if you refresh the page) and send everything to the db once done.

    I'd maybe have a formula, which takes some inputs like reps, weight, etc., assuming inputs remain consistent and use it as a way to capture a set, as an example. I'd then have a workflow, which would take similar inputs to pass to the formula and then append your set to the array. Do you follow?
  • buildingintoddle-1320457127118114856

    alain

    4 months ago

    ah i see
  • i think im following a bit
  • my issue right now is that im setting inputs to a variable which is not dynamic
  • buildingintoddle-1320457546686926959

    alain

    4 months ago

    if you see the workout tracker currently, right now it will append reps and weight inputs to an array, but those values just copy over, versus being able to change the values on the next append
  • buildingintoddle-1320458373178720337

    alain

    4 months ago

  • tomthebigtree-1320462186732327004

    Tom Ireland

    4 months ago

    I see the issue. I knocked up a quick example for you. Give me a few mins...
    ❤️1
  • buildingintoddle-1320464312476631102

    alain

    4 months ago

    i think im catching onto the concept youre talking about. Using a formula to capture inputs and then running the workflow to capture and append that current state
  • since the variable will only store the current input.
  • buildingintoddle-1320464500641497178

    alain

    4 months ago

    i appreciate your help!
  • buildingintoddle-1320467600488136827

    alain

    4 months ago

    getting there!
  • tomthebigtree-1320467886430621788

    Tom Ireland

    4 months ago

    Here you go, @alain ! Hope it's useful. 🙂

    https://www.tella.tv/video/alain-and-his-exercises-hfdw
  • buildingintoddle-1320468164743532575

    alain

    4 months ago

    sick thanks man gonna check this out and gather some questions!
    👍1
  • buildingintoddle-1320469154007875604

    alain

    4 months ago

    damn this is crazy hahah gonna rewatch this a bunch of times to fully grasp whats happening
    👍1
  • Tod-1320469155773812760

    Tod

    4 months ago

    Great energy @alain! Your continuous contribution to the toddle Community just made you advance to Community Level 3!
  • buildingintoddle-1320469233943056406

    alain

    4 months ago

    really appreciate it
    👍1
  • tomthebigtree-1320617878239842366

    Tom Ireland

    4 months ago

    @alain - Remembered the other approach for updating a specific object in an array by index. See https://www.tella.tv/video/alain-and-his-exercises-v2-5474
    ❤️1
  • buildingintoddle-1321013383662801027

    alain

    4 months ago

    thanks again for this update tom!
  • I think im starting to get it
  • Im trying to understand why parameters are significant in this case
  • buildingintoddle-1321014374005211246

    alain

    4 months ago

    I'm thinking it's because the parameters will allow us to dynamically choose which input field to modify based on the repeat item's index.

    I'm a bit confused on the concept of workflows taking parameters and formula's taking inputs.
  • tomthebigtree-1321024972726206465

    Tom Ireland

    4 months ago

    Yes, you’re right - it makes things a lot more flexible and consistent. It can also make things more complicated as well. 😂

    Formulas always evaluate to something consistent. For example, if you pass in two numbers and the formula adds them together, you’re going to get a consistent answer. Workflows can alter variables, call APIs, etc., so you’re modifying state, which can cause you to smash your head repeatedly on the desk. 🤣
  • tomthebigtree-1321025425216114708

    Tom Ireland

    4 months ago

    The good thing about workflows and formula is if you use them to perform repeat actions, you know where you need to go when solving a problem you might have introduced.
  • tomthebigtree-1321026105905512479

    Tom Ireland

    4 months ago

    In your example, the set creation formula is always going to create an empty object for you and the add set workflow will always append an empty one to the array. This inspires confidence your logic is doing what it should. The update set workflow is the most complex part just now.
  • buildingintoddle-1321156478014460126

    alain

    4 months ago

  • buildingintoddle-1321156857716277308

    alain

    4 months ago

    had to flip back and forth between both videos to make it make sense haha but i got it to work heres a demo
  • buildingintoddle-1321157785890853005

    alain

    4 months ago

    now i want to add another layer of complexity basically wrapping this function within an exercise so

    add exercise [bench press]
    then this set workflow pops up.

    then can add another exercise with its own sets

    so basically what you'd end up with is the entire workout that would look something like

    Exercise 1: Bench press
    set 1: 10 reps, 100 lbs
    set 2: 10 reps, 100 lbs
    set 3: 10 reps, 100 lbs
    [add set]

    Exercise 2: Squat
    set 1: 10 reps, 100 lbs
    set 2: 10 reps, 100 lbs
    set 3: 10 reps, 100 lbs
    [add set]

    [add exercise]
  • buildingintoddle-1321167836445540362

    alain

    4 months ago

  • the challenge here is that there's no data flowing from the component to the parent 😂
  • tomthebigtree-1321186996336459796

    Tom Ireland

    4 months ago

    Nice work, Alain! 💪