Conditionnal interactions ELSE_IF overpassing conditions


#1

Hello,
I’m trying to achieve a calendar cell selection, considering event on single or several days (in order to further create an event on the selected portion)
I’ve done it using a single master, instanciated for each corresponding timeslot in the timesheet.
Here are the template in RP8 & RP9
TimeSlotSelection.rp (71.6 KB)
TimeSlotSelection-rp9.rp (69.2 KB)

The mouseDown on a cell represent the start of the selection while the mouseUp reflect the end of the selection and I store X;Y position of thoses two cells.
Then comparing each cell’s X;Y against the first and last selected ones, i can select cell of the interval.

I’m near the end but i have a problem and a question…

The problem : While everything works fine for multiDay selection (from past to futur, and also reverse :D), on a singleday selection, why does the entire day is selected (whereas only the selected portion should be) ?
I used ELSEIF conditions in order to avoid further selection, but it does not seems to be taken in consideration, or that i’ve made a mistake in my conception but i can’t find it…
To investigate i’ve added some text within interaction of each selected cell to indicate associeted. That shows illegitimate trailing selection by the endDay condition, and leading one by the startDay condition.
Any clue ?

The question : I couldn’t find a better way of updating every single celle on the timeSheet than reloading the whole page… Does anyone see a better way ? On the overall concept, is there a simpler approach of doing so ?

Thank you very much for reading my problem, and thank you many more if you can provide any help.

Sincerly
Lionel B.


#2

Hi Lionel,

I think the attached does what you’re looking for. I added a few cases to handle single select and made the logic specific with all IFs. I left your logic in place that puts the text in - you can see that some cells are selected multiple times. If you want to clean this up you can look to see where the logic overlaps.

Regarding a better way to do this - you might be able to user a repeater, but honestly I thought the way you handled it was pretty clever. Since it’s master driven your logic is maintained one place. I guess the only bummer is having to refresh the page. You could use a moveBy 0,0, but that would have to be fired on every widget.

TimeSlotSelection.rp (73.6 KB)


#3

Hi @UXProtoTyper
Thank you so much for your reply and attachement. It looks perfect to me :slight_smile:
I did just noticed a small bug (exiting since my own version) when selecting slot from day D at position y1 ending on D+1 on y2 where y2 < y1 (ending the day after at a time before the start on the previous day)
If you have an advice i would appreciate…

Anymway, a HUGE thank you for what you’ve already replied.

Cheers,
Lionel


#4

Hey there - yep, I missed the scenarios where the start was greater than the end. I had to add three extra cases to account for those scenarios.

There is probably a way to simplify the logic - which i’ll take a look when I have more time, but int the short term, I think this covers everything now.

TimeSlotSelection.rp (76.4 KB)


#5

Hi @UXProtoTyper,
Once again… THANK YOU !
You managed to do exactlly what i was trying to achieve.

If someone ever visit this post and has an idea of doing so without having to reload the page it would be awsome !!
Anyway, at this point, the purpose is reached… thank you @UXProtoTyper.

sincerly,
Lionel


closed #6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.