Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
titleResources
Tour
render-no-hits-as-blanktrue
render-as-definition-listtrue
marker-column-property-nameTitle
replace-title-with-nametrue
TitleShort Description
<form id="filterForm${uniqueid}" action="">
  select:
  <input id="filterSelect${uniqueid}" size="50" type="text" list="selects${uniqueid}" name="select" >
  ${datalistselects}
  where:
  <input id="filterWhere${uniqueid}" size="50" type="text" list="wheres${uniqueid}" name="where">
  ${datalistwhere}
  <input type="submit" value="Submit">
  <input type="reset" value="Reset">
</form>
<script>
AJS.toInit(function() {
	var urlParams = new URLSearchParams(window.location.search);

	var originalSelect = urlParams.get('${tableid}:select');
	var originalWhere = urlParams.get('${tableid}customWhere');

    $("#filterSelect${uniqueid}").val(originalSelect);
    $("#filterWhere${uniqueid}").val(originalWhere);

	 function appendToQueryString( queryString, queryParam ) {
       if(queryString.trim())
       {
		 queryString=queryString + "&" + queryParam;
       }
	   else
       {
		 queryString="?"+queryParam;
       }
       return queryString;		    
	 };
	 $('#filterForm${uniqueid}').submit(function(evt) {
	  evt.preventDefault();

      var tableId = "${tableid}";
      var $initialWhere = "${initialwhere}"
	  var $select = $('#filterSelect${uniqueid}').val();
	  var $where = $('#filterWhere${uniqueid}').val();
	  console.debug($select);
	  console.debug($where);

	  var $queryString="";
	  if ($select.trim())
	  {
	   var $encodedSelect = encodeURI($select);
       var $selectQueryParam = tableId + ":"+"select"+"="+$encodedSelect;
       $queryString=appendToQueryString($queryString, $selectQueryParam);
	  }

	  if ($where.trim())
	  {
	   var $encodedCustomWhere = encodeURI($where);
       var $customWhereQueryParam = "${tableid}customWhere"+"="+$encodedCustomWhere;
	   var $encodedWhere = encodeURI($initialWhere + " AND " + $where);
       var $whereQueryParam = tableId + ":"+"where"+"="+$encodedWhere;
       $queryString = appendToQueryString($queryString, $whereQueryParam);
       $queryString = appendToQueryString($queryString, $customWhereQueryParam );
	  }
	  $action = window.location.href.split('?')[0] + $queryString;
	  $('#filterForm').attr('action', $action);
	  console.debug($action);
      window.location.href=$action;
 });
});
</script>