1 Reply Latest reply on May 2, 2014 8:34 AM by philmodjunk

    Create time intervals dynamically.



      Create time intervals dynamically.



           I am building an app for GO that will allow coaches to create practice schedules.

           I would like for them to be able to enter practice times and have something like the wireframe image below created dynamically.  For example, they enter 7-9 as practice times.  I have created drill templates that have a duration time (5-10 minutes) As they choose the first button (row), it will open the templates in a portal to allow the coach to choose the drill.  When the coach chooses the drill, I would like it to be able to reference the duration of the dril and add it to the Button or Row.  For example, practice starts at 7:00 the coach choose a drill with the duration of 6 minutes.  It would populate the first Button (row) with 7:00 ~ 7:06 and then on the next button(row) it would have 7:06 ~ ?.  When the click on that the will be able again to choose another drill...hitting 10 minute duration.  At that time it would change 7:06 ~ ? to 7:06 ~ 7:16....and so on and so forth .

           I am only guessing, but I think that using portals rows for the times would make the most sense??  I am open to any suggestions.  Also, when the time is clicked, I plan on opening a popover that will then have a portal within it that will allow the coach to choose the drill..that will then populate the time and put the descripton of the drill with the time.


        • 1. Re: Create time intervals dynamically.

               A portal seems reasonable for this, but your popover button cannot be placed inside the portal row to show yet another portal. That violates the "no portal inside a portal" rule and won't work. But there are ways around that limitation by using some script triggers to open a popover located outside of the portal and still have it open to the correct set of records.

               But I suggest leaving that until you get your time intervals to work. There are two main steps to that:

          1.           Getting your portal to work so that when you pull up different records for your drills, you see the correct set of records in the portal. I'd need to know a lot more about your data model--the tables and relationships that you've set up, before I could assist you with that if you need that assistance.
          3.           Calculating the start and end times given a specified time requirement for the selected drill. This is something where I can provide some immediate assistance.

               Fields of type time store the time as an integer that counts the number of seconds since midnight. Thus, you can compute a new time by adding the needed time interval to it as long as that value is converted to seconds.

               If the time required for a given drill is stored as minutes in a number field, this expression will compute the end time from a given start time:

               StartTime + 60 * Drill_Interval

               If the time required for a given drill is stored as time in a field of type time, this expression becomes:

               StartTime + Drill_Interval

               So your script that is performed when you select the next drill, could update the last portal record by setting a field to either the Drill_Interval in minutes or as time (seconds) and your EndTime field can then use the above calculation with time selected as the result type to compute the end of the time interval. The same script can then copy this value to a variable, create a new related record in the portal's table and set the startTime field in it to the value from the variable.