Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Document Properties Marker
overridefalse
Short DescriptionModule to provide a filter for a display table macro.
Doctypedocmodulehide
NameFilter Module
Short Name
Parent
Parent Property
property-nameName
hide
Audience
Name List
doctyperole
render-no-hits-as-blanktrue
propertyAudience
empty-as-nonetrue

Subject
Name List
doctypesubject
propertySubject

Categories
Name List
doctypecategory
propertyCategories

Tags
Tag List
propertyTags

Flagshide
Iteration

Iteration
valuefinished


Type

Name List
doctypemodule-type
render-no-hits-as-blanktrue
propertyType


Sort Keyhide
projectdoc-transclusion-macro
documentFilter Module
idsHTML-CODE
projectdoc-section
titleDescription

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.

The javascript code uses the variable initialwhere which can be replaced using the transclusion variable replacement feature and be set to the initial where condition used in the display table macro.

Image Added


Section
hidetrue
titleHTML-CODE
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>

...