Show Hide doing something strange

Not sure if this is a bug or just me being silly, hopefully someone can confirm.

<div class="text-right col-6"
    dmx-show="(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() < 4 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() > 0)"
    dmx-hide="(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 3 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() > 1)">...EXPLORE
</div>

If i remove either the show or the hide then it works, so maybe I can not use show and hide on the same element?

My query is returning a count of 1 for query_available_accom and 1 for query_available_act
So in my head the …EXPLORE word should be showing, or am I not seeing something silly here.

You should only use either show or hide not both

Ahh, ok, never realised that, will have to think about this condition a little more, could not quite get my head around doing it in one, will have a little think, im sure i will figure out a way.

Take both the conditions, put them in brackets so they act as a single condition then just prefix one with ! to signify NOT

1 Like

Smartypants, thank you

1 Like

I am still running into instances where the condition does not work out, so the condition is just getting longer and longer, there has to be a better way to do this.

What i has is this scenario

There is a space available for a user to choose
between 0, 1, 2, 3, 4 pieces of accommodation, and between 0, 1, 2, 3, 4 pieces of explore information.

If the user selects 4 of each then it looks like this

If the user selected 2 accommodations and 1 explore then it would look like this

Notice how the word EXPLORE has changed from position bottom left with the 3 dots EXPLORE… after the word to top right with … before the word, so …EXPLORE

I would like to find the most efficient method of showing or hiding the word EXPLORE considering how many possible outcomes there could be, and obviously never showing it in either position when there are 0 of them.

I have 2 divs with a show condition one for the top right and one for the bottom left and so far I have this silly looking idea in place.

<div class="text-right col-6" dmx-show="
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() != 0) ||
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 3 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() == 1) ||
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 2 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() == 2) ||
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 1 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() == 3)">
...EXPLORE
</div>

And I am still coming across situations where EPLORE shows in the wrong place. Can someone that has maybe slept a little in the past 30 hours have a quick look, I assume there is a far far shorter simpler solution than this.

EDIT: I had it far shorter earlier using <= and >= but it still had instances where it was there when i didnt want it.

I’m not sure if this will get you any further, but I think you could replace the last 3 lines with one line - by adding the two expression together and using ==4. Also, I would have thought the first expression makes the others redundant - should it perhaps go below the others?

Thanks Tom, I hadnt really thought about the order I am adding these expressions in, but that may actually be why its just not quite doing what i expect, going to try you suggestion of adding the 2 together but i do not really think it will work.

As an example the user could have 2 accommodations chosen and 3 explores, in which case it should show 2 accommodations on line 1, then leave 2 gaps because it can not fit all 3 in one go side by side, and therefore needs to drop the 3 explores down a line and hide the top EXPLORE wording and show the bottom EXPLORE wording.

Thats why this is causing me such a headache, there are just so many possibilities that could be made of 4 and 4 especially considering that in certain instances blank cards are added in as spacers to drop down a line as per my example above.

Here is a rough idea of what i mean

It’s probably not the order which is the issue, but won’t the first line, ending:
query_available_act.count() != 0
always be true if any of the following lines evaluate to true
?

I mentioned the ==4 as it so happens that each pair of conditions in the folowing lines adds up to 4 - so I think one line could replace the three.

What differentiates accommodation reoords from event records?

1 Like

Ok Tom, I think you fixed my confusion, and it is now working perfectly with this

<div class="text-right col-6" dmx-show="
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 3 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() == 1 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() != 0) ||
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 2 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() <= 2 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() != 0) ||
(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() == 1 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() <= 3 && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() != 0)">
...EXPLORE</div>

However I had also had a 6 hour sleep and so I was able to actually comprehend what you were saying regarding the ==4, and i realised you were quite right, because i was looking at the larger scenario I overlooked that this one word was actually only for the top row of 4, and it actually did not matter about the entire 8 issue, as that is dealt with as a combination of 2 elements each with their own conditions.
And now I feel stupid because this is what landed up working, although bracket placement almost threw me off.

<div class="text-right col-6" dmx-show="(scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_accom.count() + scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() <= 4) && scViewItinerariesDetail.data.repeat_records_accom_acts_in_days[$index].query_available_act.count() != 0">
...EXPLORE</div>

Perfect, thank you so much for taking the time to really look at this with me.

What did we do before this forum, honestly, stack exchange, get 100 insults and 1 decent answer (maybe).

1 Like

Great. I’m glad you managed to sort it out - and with just a single (very long) line of code.

1 Like