Versions Compared

Key

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

...

Section
titleSummary

Section
titleContent

Below this text is the HTML-Code to be transcluded to provide a filter for a display table macro using the remote controlled feature.

Can be viewed only in edit mode.

Section
hidetrue
titleHTMLCODE
HTML
<form id="filterForm" action="">
  select:
  <input id="filterSelect" size="50" type="text" list="selects" name="select" >
  <datalist id="selects">
    <option value="Name">Name only</option>
    <option value="Name, Short Description">Name and Short Description</option>
    <option value="Name, Short Description, Iteration">With Iteration</option>
    <option value="Name, Short Description, Iteration, Creation Date">With Iteration and Creation Date</option>
  </datalist>
  where:
  <input id="filterWhere" size="50" type="text" list="wheres" name="where">
  <datalist id="wheres">
    <option value="$<Iteration>=[Facade]">Facade</option>
    <option value="$<Iteration>=[Filled]">Filled</option>
    <option value="$<Iteration>=[Finished]">Finished</option>
  </datalist>
  <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('filtered:select');
	var originalWhere = urlParams.get('customWhere');

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

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

      var tableId = "filtered";
      var $initialWhere = "${initialwhere}"
	  var $select = $('#filterSelect').val();
	  var $where = $('#filterWhere').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 = "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>

...