Indicia-Team / media

Shared library of JavaScript code,
0 stars 2 forks source link

Fix problem where linked lists no longer seem to work. #24

Closed andrewvanbreda closed 4 years ago

andrewvanbreda commented 4 years ago
  1. The query parameter was causing problems as the query has parameter names in it.

So we ended up with something like &query=square_id=

removed query= so we get something like

&square_id=

  1. Also I don't understand why the replacement for '%22val22%' was present, the new replacement seems to work and is based on this line from data_entry_helper inilinkedlists

$query = $options['filterField'] . '="+$(this).val()+"';

johnvanbreda commented 4 years ago

I don't think this pull request is right I'm afraid. The problem is that the tidy up of linked list code a few months back works for the normal scenario where the selects are populated directly from data services, but not in this scenario where you are using a report for population. If you look at data_entry_helper::initLinkedLists and compare how the $query variable is being created for reports vs data services, you'll see the reports method is not encoded in the same way at all.

In indiciaFunctions.js, the parent select's value is replaced for %22val%22, which is url encoded "val". So I think you just need to revert this change and change data entry helper in initLinkedLists:

$query = $options['filterField'] . '="+$(this).val()+"';

should be

$query = urlencode(json_encode(array('where'=>array($options['filterField'], '"val"'))));

That's untested, but as you have a test scenario available can you try it out please and commit if OK?

andrewvanbreda commented 4 years ago

Am trying to get this to work. I think the '%22val22%' will be ok. However I still have issues with the query. If you put the filterField inside the query the system will always request the parameter, doesn't that need to be outside the query as per the way I had it working. I think that query gets used if it is populated from a view.

johnvanbreda commented 4 years ago

Ok, yes, I see. In indiciaFunctions.js, line 467 should not hard code the parameter name query this doesn't work for reports. So, this should remove the query= from the '&query=' leaving just the ampersand. Instead, in data_entry_helper::initLinkedLists, the $query variable should be set to

$query = $options['filterField'] . '=' . urlencode('"val"');

Also, the data services version just below needs changing to include the query paramer by adding 'query=' . just before the urlencode so the parameter name is included in the string.

andrewvanbreda commented 4 years ago

@johnvanbreda Am still having some issues with this, is it possible to Skype sometime might be quicker to talk? Thanks