Widgets and Modules

DateSelectorFacet module

A module creating a <div> element into the provided element of his constructor, containing two text inputs with their labels, which implement the  Datepicker widget from JQuery UI framework. One input represents a 'From' value and the other one represents a 'To' value. The combination of both values allows the user to select a range of dates. The module then provides a method that returns the range of dates as a string that is formatted as a Solr query filter: (fieldname):[(fromValue) TO (toValue)]. The used fieldname used in the Solr query filter is based on the 'field' parameter provided to the module instance.

The created div looks like this:

Prerequisites

In order to retrieve a proper Solr query filter value from the method getFilter(), the 'field' parameter of the module instance must be set with a valid Solr field name which is of date type !

Variables

  • elm : the jquery element, or the id of the element in which the module will build his <div>
  • field : Solr field name that will be used to construct the Solr query filter in the getFilter() method
  • manager : the AjaxFranceLabs Manager instance that rules every widgets and modules. Must only be set if the module is used with the 'Go' button activated (var 'hideGo' set to false) !
  • id : the id of the module, must be obviously unic
  • save : used internally by the module to make a save of himself and re-use it on page load/reload. Must not be manually set !
  • hideGo : set it to true to hide the 'Go' button or to false to display it (default false). The 'Go' button is a button that appears next to the 'To' input and that triggers the search if the user clicks on it. It is mostly used when the module is implemented into a facet widget as it is the only way the user can notify Datafari that he wants to use the range of dates selected
  • displayError : (default: false) set it to true to display an error message at the end of the <div> when a user enters a wrong date format. If you enable this option, make sure the HTML element into which the module is attached, has enough width, because the error message is long.
  • oldFilter : used internally by the module to keep the last used filter. it is used to detect it in the query and replace it by the new one if it has changed. This variable is only used when the 'Go' button is not hidden (var 'hideGo' set to false). Must not be manually set !
  • fromInitValue : set this variable if you want to display the module with an initial fromValue. The accepted format is "YYYY-MM-DDT00:00:00Z", if this format is not respected, the value will stay empty.
  • toInitValue : set this variable if you want to display the module with an initial toValue. The accepted format is "YYYY-MM-DDT00:00:00Z", if this format is not respected, the value will stay empty.

Methods

  • execFacet: method that retrieves the current filter value thanks to the getFilter() self method, save the module before the widgets are refreshed thanks to the selfSave() method, remove the old filter in the manager.store to replace it by the new one and execute the request. This method is exclusively executed by the 'Go' button
  • selfSave: makes a save of the module div into the 'save' variable, using the jQuery detach function
  • cleanValues: resets every from/to values
  • getFromVal: returns the fromValue which is a string formated like "YYYY-MM-DDT00:00:00Z" or a wildcard if the value is empty
  • getToVal: returns the toValue which is a string formated like "YYYY-MM-DDT00:00:00Z" or a wildcard if the value is empty
  • getFilter: returns the range of dates as a string that is formatted as a Solr query filter: (fieldname):[(fromValue) TO (toValue)]. For example: last_modified:[2000-01-01T00:00:00Z TO *]
  • hideGoButton: hide the 'Go' button
  • showGoButton: show the 'Go' button
  • isValidDate: Validates that the input string is a valid date formatted as "dd/mm/yyyy". Technically, it checks that the date is well formatted but also that it is a real date, even that the day of the month exists (for example the 29th of february only exists if the year is a leap year)
  • checkAndUpdateFromInputs: triggered when the focus of the 'From' input element is lost and use the isValidDate() self method to check if the date is correct or not. Displays the error message if the date is not valid and the 'displayError' variable is set to true 
  • checkAndUpdateToInputs: triggered when the focus of the 'To' input element is lost and use the isValidDate() self method to check if the date is correct or not. Displays the error message if the date is not valid and the 'displayError' variable is set to true
  • createDateSelectorDiv: creates the <div> element (shown in the picture on top of this description)
  • convertAltDateFormatToDateFormat: converts a string date formated like "YYYY-MM-DDT00:00:00Z" into a string formated like "DD/MM/YYYY". If this format is not respected, the value will stay empty
  • beforeRequest: triggers the selfSave() self method
  • afterRequest: triggers the createDateSelectorDiv() self method




SearchBar widget

A widget displaying a search bar and search options.

It contains a link useful to switch to advanced search (if that widget is activated): : in this case a default query is performed and the inputs and URL reset.

Variables

  • autocomplete: can take 3 values:
    • false(default): no autocomplete.
    • true: autocomplete automaticaly created.
    • AutocomepleteWidget: an autocomplete widget.
  • autocompleteOptions: options for the autocomplete widget if autocomplete set to true. Check the code to see the default structure.
  • removeContentButton: if set to true, creates a button which appears when there is text in the search bar in order to remove it and execute a request (default: false).
  • noRequest: if true, inhibits the request to be sent to Solr (default: false).
  • updateBrowserAddressBar: if true, the address bar URL is updated with the query parameter,
    e.g. ?searchType=AllWords&query=datafari (default: true).
  • removeContentButton: if true, adds a button that clears the search bar (default: false).


Methods

  • buildWidget: an implementation of the parent class method. It contains the onClick event handler for the advanced search link.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method; closes the autocomplete menu.
  • reset: an implementation of the parent class method: it resets the inputs of the widget (useful when switching between basic and advanced search).
  • updateAddressBar: updates the address bar URL with the search term, e.g. ?searchType=AllWords&query=datafari
  • clean: resets the pagination and the fq and start parameters of the manager's store.
  • makeRequest: if the noRequest variable is false, cleans the results area and facets, updates the address bar and performs the search request.

Note that the Autocomplete widget is also an extension of the Autocomplete plugin from jQuery UI and so it has all its variables and methods too.


Result widget

A widget displaying the search result.

Variables

  • pagination: can take 3 values
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.


Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.

 SubClassResult widget

A widget that implements Datafari specific code and parameters the Result widget. We did not test this widget towards a direct Solr system. This widget displays the search result. It displays results differently depending on the activation of the LikesAndFavorites widget.

Variables

  • pagination: can take 3 values
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.
  • elmSelector: used to store the results to be displayed. Corresponds to the jQuery selector.   
  • firstTimeWayPoint: used in the mobile mode, to know when we reach the bottom of the page, to trigger the spinner in order to load and display the further results.
  • isMobile: checks whether we are in mobile mode or not.
  • mutex_locked is a variable used as a mutex for the mobile mode


Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.

ResultIllustrated widget

A widget that extend Result Widget and that displays image in result.

Variables

  • pagination: can take 3 values
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.


Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.

LikesAndFavorites Widget

Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • function that is runned after getting the likes and favorites of the user
  • showError: function that analyze the error and display the corresponding error message 






SearchInformation widget

A widget displaying the search informations like the number of document found, the query execution time, ...

Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.



Table widget

A widget displaying a facet values in a table.

Variables

  • name: a name for the facet to be displayed.
  • pagination: can take 3 values:
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.
  • nbElmToDisplay: the number of facets to display (default: 10).
  • sort: can take 3 values
    • occurences(default): sort the facets by the number of occurences.
    • AtoZ: sort the facets name by alphabetical order.
    • ZtoA: sort the facets name in a reversed akphabetical order.
  • maxDisplay: maximum number of facets (default: 40).
  • checkedOnTop: if set to true, the checked facets will be sorted on the top before the unchecked facets (default: true).
  • mappingValues (optional): used to override the values of the facet by custom ones. This variable has to be initialized in the constructor call (search.js) and respect the following format : {"originalFacetValue1" : "customValue1", "originalFacetValue2" : "customValue2", ... }
    All the possible facet values don't have to be mapped to custom ones, you can fill this optional variable with the only needed ones, the other values will stay the same.

  • modules: list of modules instances that need to be implemented to this widget.
    When the widget is initialized, it will set the 'manager' varaible on each module of the list and create a specific <li> element in his <ul> for each module. The <li> element will be set to them as the 'elm' variable.
    Then, the beforeRequest() and afterRequest() method of the widget will respectively call the beforeRequest() and afterRequest() of each module.

Methods

  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • update: a method updating the content of the widget.
  • assocTags: a method maping the search query facets result.
  • sortBy: the method sorting the facets, takes the sort mode as parameter.
  • clickHandler: a callback called when a facet is selected or unslected.



FacetDuplicates widget :


This widget displays duplicate documents that are in the index. It is very specific, not recommended for instance if you have an ecommerce website. It is more useful in an intranet context, where you may be interested to know which documents are present several times in your repositories.

The class is of  type  « final ». For each hash of a given document, the widget retrieves the corresponding document name (the corresponding field name for the document name needs to be identified. By default in Datafari, it is title_en or title_fr). For more information, refer to the specific deduplication documentation.

Variables

  • name: a name for the facet to be displayed.
  • pagination: can take 3 values:
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.
  • nbElmToDisplay: the number of facets to display (default: 10).
  • sort: can take 3 values
    • occurences(default): sort the facets by the number of occurences.
    • AtoZ: sort the facets name by alphabetical order.
    • ZtoA: sort the facets name in a reversed akphabetical order.
  • maxDisplay: maximum number of facets (default: 40).
  • checkedOnTop: if set to true, the checked facets will be sorted on the top before the unchecked facets (default: true).


Methods

  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • update: sends an ajax request for each hash to get the name of the document. It will also build the html that will be used to display the facet. If there is no duplicate document, the facet will not be displayed.
  • assocTags: a method maping the search query facets result.
  • sortBy: the method sorting the facets, takes the sort mode as parameter.
  • clickHandler: a callback called when a facet is selected or unslected.



HierarchicalFacet widget

A widget displaying a facet values in a hierarchical way. Available as of Datafari v2.2.


Prerequisites

In order to make this widget work, it is mandatory that the selected facet field represents a path tokenization where each value is prefixed by its depth level.
For example, the path '/home/france/labs' will be tokenized as this : 0/home, 1/home/france, 2/home/france/labs

The default field that is used by the widget is ‘urlHierarchy’. This field exists in the Solr index but it is not filled because the "tokenization" strongly dépends on the crawled source. It can be filled like in the above example during the indexation phase by modifying the DatafariUpdateProcessor.java class located in [DATAFARI_REPO]/datafari-updateprocessor/src/main/java/com/francelabs/datafari/updateprocessor/. In this class, a commented section of the code can be found, that is an example to fill this field, you can use it and adapt it. Once the modifications are done, generate the update processor jar with maven with the command ‘mvn install’ ( to run in the ‘[DATAFARI_REPO]/datafari-updateprocessor/’ folder) then shutdown Datafari, replace the current update processor located in '/opt/datafari/solr/solrcloud/FileShare/lib/custom/' by the new one and restart Datafari.
Finally perform a complete crawl of the repository on which you want to use this widget (must be a full crawl/re-crawl, not a delta one). 


Variables

  • name: a name for the facet to be displayed.
  • pagination: can take 3 values:
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.
  • nbElmToDisplay: the number of facets to display (default: 10).
  • sort: can take 3 values
    • occurences(default): sort the facets by the number of occurences.
    • AtoZ: sort the facets name by alphabetical order.
    • ZtoA: sort the facets name in a reversed akphabetical order.
  • maxDisplay: maximum number of facets (default: 40).
  • checkedOnTop: if set to true, the checked facets will be sorted on the top above the unchecked facets (default: true).
  • rootLevel: the root depth level of the hierarchical tree (default: 0)
  • maxDepth: the maximum depth to be displayed, starting from the rootLevel (default: 3)
  • separator: the separator used between each depth level ( default '/' )


Methods

  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • update: a method updating the content of the widget.
  • assocTags: a method mapping the search query facets result.
  • sortBy: the method sorting the facets, takes the sort mode as parameter.
  • clickHandler: a callback called when a facet is selected or unslected.
  • selectNoRequest: a method that does the same as the selectHandler parent class method but that doesn't perform the request at the end
  • unselectNoRequest: a method that does the same as the unselectHandler parent class method but that doesn't perform the request at the end
  • displayLevel: a method which constructs the hierarchy tree with the search query facets result




PrevisualizeResult widget

A widget that extend Result Widget and that displays a preview window at mousover on the document.


Starting from Datafari 4.1 :

- By default,  the previsualize window displays the first 1000 characters of the content of the document.


Prerequisites

In order to make this widget work, you have to customize the content that you want in the window and to activate the widget.

To activate the widget :

  • in datafari/WebContent/js/search.js :

Uncomment the line :


Manager.addWidget(new AjaxFranceLabs.PrevisualizeResultWidget());
  • in datafari/WebContent/searchView.jsp

Uncomment the lines :

<script type="text/javascript" src="js/AjaxFranceLabs/widgets/PrevisualizeResult.widget.js" charset="utf-8"></script>

and

<div id="previsualize"></div>

To customize the information displayed :

Go to datafari/WebContent/js/AjaxFranceLabs/widgets/PrevisualizeResult.widget.js and edit the line to display whatever you want instead of the ID of the document :

$($('.doc_list .previsualizetemplate')[index]).append('<div id="previsualizeid">ID : '+docs[index].id+' </div>' );

Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • showError: function that analyze the error and display the corresponding error message 



ExternalResult widget

A widget that allows to have a federated search in Datafari ie display results from another search engine (Solr, Sharepoint for example) and display below the normal results from Datafari.

Prerequisites

In order to make this widget work, you have to parse the response from your external datasource. 

To activate the widget :

  • in datafari/WebContent/js/search.js :

Uncomment the line :


Manager.addWidget(new AjaxFranceLabs.ExternalResultWidget());
  • in datafari/WebContent/searchView.jsp

Uncomment the lines :

<script type="text/javascript" src="js/AjaxFranceLabs/widgets/ExternalResult.widget.js" charset="utf-8"></script>

and

<div id="external"></div>

to select the data to parse :

  • in datafari/WebContent/js/AjaxFranceLabs/widgets/ExternalResult.widget.js

Edit the line :

var urldatasource = 'http://localhost:8080/Datafari/externaldata.json';

Change the url for the data you want to parse.  

Adapt the code in the file to parse the information that you want in the JSON file.

By default the code is adapted to parse the file externaldata.json. Adapt this section :

$.getJSON(urldatasource,querySolr, function(result){

			$.each(result.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results,
					function(j, docu) {
				var highlightingvalues = docu.Cells.results[10].Value;
				highlightingvalues = replaceAll(highlightingvalues,"<c0>","<span class='em'>");
				highlightingvalues = replaceAll(highlightingvalues,"</c0>","</span>");

				elm.find('.externalresults').append(
						'<div class="external sp'+ j +'"></div>');
				var extension = docu.Cells.results[17].Value;
				elm.find('.external:last').append(
						'<div class="externaltitle"><a class="externallinktitle" target="_blank" href="'+docu.Cells.results[6].Value+'">'+docu.Cells.results[3].Value+'</a>');
				elm.find('.external:last').append('<p class="externalhighlight">'+highlightingvalues);
				elm.find('.external:last').append('<p class="externalurl">'+docu.Cells.results[6].Value);

			})
});


We provide some example data into Datafari if you want to test it out of the box :

  • Copy datafari/dev-tools/example-data/externaldata.json into datafari/WebContent

Methods

  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • showError: function that analyze the error and display the corresponding error message 



Table Facet Queries widget

A widget displaying facet queries in a table.

Variables

  • name: a name for the facet to be displayed.
  • field: the field that will be used in the queries
  • queries: the list of queries
  • pagination: can take 3 values:
    • false(default): no pagination.
    • true: pagination automaticaly created.
    • PagerWidget: a pager widget.
  • nbElmToDisplay: the number of facets to display (default: 10).
  • maxDisplay: maximum number of facets (default: 40).
  • modules: list of modules instances that need to be implemented to this widget.
    When the widget is initialized, it will set the 'manager' varaible on each module of the list and create a specific <li> element in his <ul> for each module. The <li> element will be set to them as the 'elm' variable.
    Then, the beforeRequest() and afterRequest() method of the widget will respectively call the beforeRequest() and afterRequest() of each module.

Spellcheck widget

A widget spellchecking a query string. (eg: can offer you to correct constellia in constellio).

This widget works with both basic and advanced search.

Note: this requires enabling a spellchecker component in the searchhandler of Solr (done in the xml config files), whether you use a pure Solr or a Constellio Solr.

Variables

There are no specific variables: only the ones inherited from AjaxFranceLabs.AbstractWidget.

Methods

  • buildWidget: an implementation of the parent class method: builds the widget.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method: here there is the logic of the spellchecker itself. It checks whether the result of the search query has some suggestions and, if so, it calls doSpellCheckerQuery to perform a new search with the spellchecked input, contained in the collations array.
  • doSpellcheckerQuery: performs a new search with the spellchecked input.



AdvancedSearch widget - new version (v3.2 of Datafari and above)

A widget enabling you to specify on which fields to perform a search.

The result of the search query is spellchecked by SpellChecker widget (if that widget is activated).

It contains a link useful to switch to basic search (if that widget is activated): in this case a default query is performed and the inputs and URL reset.

The AdvancedSearch widget is built with one other classe:

  • AdvancedSearchField: which are the different fields provided by the advanced search.

Variables

  • mappingFieldNameValues: a map containing labels associated to fieldNames. This is usefull if you want to display a different label in the advancesSearch than the default solr fieldName which can be non human friendly.
    The format of this parameter is the following: {"fieldName":"Custom label","fieldName2":"Custom label 2",...}


External variables

The advanced search widget is using external variables defined in the advanced-search.properties file located in DATAFARI_HOME/tomcat/conf
Here are the available variables in this file:

  • DENIEDFIELDLIST: list of Solr fields that you don't want to appear in the advanced search fields list. In this variable, fieldNames are separated by coma ( ex: DENIEDFIELDLIST=field1,field2,.... )
  • EXACTFIELDS: list of Solr fields that have associated exact fields in Solr. For each Solr field specified in this list, the advanceSearchWidget will use its associated exact field to perform exact expression search.
    In this variable, fieldNames are separated by coma ( ex: EXACTFIELDS=field1,field2,.... )
    As you cannot (for the moment) specify the name of the associated exact fields, the associated exact fields must respect the following naming rule for the advancedSearchWidget to be able to automaticaly use them : exact_fieldName

Methods

  • buildWidget: an implementation of the parent class method: builds the widget.
  • reinitVariables: cleans all the fields selected in the advanced search and their filters values
  • buildStartingUI: builds the advanced search UI according to the last executed query in the search UI. This function parses the last executed query in the standard search UI to build every required elements in the advanced search (the fields and their filters values)
  • extractFilterFromText: computes the values entered by the user for a specific field, in order to create the corresponding filters which can be processed as a query by Solr
  • addField: adds a new field and its filters elements to the advanced search UI
  • constructFilter: Method that constructs the proper filter UI corresponding to the field provided and the other parameters
  • beforeRequest: an implementation of the parent class method: builds the search query with the inputs from AdvancedSearchFields and calls updateAddressBar.
  • displayBasicSearch: hide the advanced search UI and displays the basic search UI
  • reset: an implementation of the parent class method: resets the inputs of the widget and calls the reset method on the underlying elements table and fields (useful when switching between basic and advanced search).
  • makeRequest: cleans the results area (list and facets) and performs a default search (*:*)
  • cleanResults: cleans the results area (list and facets)
  • updateAddressBar: updates the URL in the address bar with the advanced search query created by beforeRequest.


AdvancedSearchField

Extends AjaxFranceLabs.Class

Variables

  • elm: the AdvancedSearchField DOM element itself.
  • autocomplete (not implemented yet): can take 3 values:
    • false(default): no autocomplete.
    • true: autocomplete automaticaly created.
    • AutocomepleteWidget: an autocomplete widget.
  • autocompleteOptions (not implemented yet): options for the autocomplete widget if autocomplete set to true. Check the code to see the default structure.
  • dateSelectorModule: if the field type is a date, this variable will automatically refer to a date selector jquery widget.
  • values: map containing the filter names associated to this field as keys and their values. 
  • field: the field in the search engine index this AdvancedSearchField refers to.
  • fieldNameExactExpr:  if the field has an associated exact field, the variable will be filled by the advancedSearchWidget with the name of the exact field 


Methods

  • init: an init method, that creates the class.
  • buildTextFieldFilterUI: a method building the UI elements for a text type field.
  • buildNumericFieldFilterUI: a method building the UI elements for a numeric type field
  • getFilter: a method that returns the filter value for this field. It calls either the getNumberFilter method or the getTextFieldFilter method
  • getNumberFilter: a method that return the filter value for a numeric type field
  • getTextFieldFilter: a method that return the filter value for a text type field



AdvancedSearch widget (before v3.2 of Datafari)

A widget enabling you to specify on which fields to perform a search.

The result of the search query is spellchecked by SpellChecker widget (if that widget is activated).

It contains a link useful to switch to basic search (if that widget is activated): in this case a default query is performed and the inputs and URL reset.

By default the AdvancedSearch is desactivated from the splash page.

The AdvancedSearch widget is built with 2 other classes:

  • AdvancedSearchTable: which is a part of the advanced search form, containing fields.
  • AdvancedSearchField: which are the different fields provided by the advanced search.

Variables

  • tables: an array containing all the tables.
  • resizable: if set to true, display a resize bar on the bottom of the advanced search form. Requires jQuery UI Resizable plugin.
  • options: options given to the jQuery UI Resizable plugin.
  • optionsExtend: if set to true, extends the default parameters defined in this widget (default: true).


Methods

  • buildWidget: an implementation of the parent class method: builds the widget and links the basic search link to the basic search bar.
  • beforeRequest: an implementation of the parent class method: builds the search query with the inputs from AdvancedSearchFields and calls updateAddressBar.
  • addTable: adds the AdvancedSearchTable object given in parameter to the table array.
  • reset: an implementation of the parent class method: resets the inputs of the widget and calls the reset method on the underlying elements table and fields (useful when switching between basic and advanced search).
  • makeRequest: cleans the results area (list and facets) and performs a default search (*:*)
  • cleanResults: cleans the results area (list and facets)
  • updateAddressBar: updates the URL in the address bar with the advanced search query created by beforeRequest.


AdvancedSearchTable

Extends AjaxFranceLabs.Class

Variables

  • parent: the advancedSearch DOM element.
  • elm: the AdvancedSearchTable DOM element itself.
  • title: a name for the table (default: empty string).
  • description: a description for the table (default: empty string).
  • fieldStore: an array containing the AdvancedSearchField fields related to the table.
  • manager: a reference to the widget's manager.


Methods

  • init: an init method that creates the class.
  • addField: a method adding an AdvancedSearchField field to the fieldStore array.
  • reset: an implementation of the parent class method: resets the inputs of this class and calls the reset method on the underlying fields.


AdvancedSearchField

Extends AjaxFranceLabs.Class

Variables

  • parent: the advancedSearchTable DOM element.
  • elm: the AdvancedSearchField DOM element itself.
  • label: a name for the field (default: empty string).
  • range: if set to true, will create two inputs instead of one to enable an input range (default: false).
  • description: a description for the field (default: empty string).
  • multiInput: if set to true, will add a link which allows the user to add more inputs for this field (default: false).
  • addInputLabel: text to append to the link adding inputs (default: "Add input").
  • autocomplete: can take 3 values:
    • false(default): no autocomplete.
    • true: autocomplete automaticaly created.
    • AutocomepleteWidget: an autocomplete widget.
  • autocompleteOptions: options for the autocomplete widget if autocomplete set to true. Check the code to see the default structure.
  • manager: a reference to the widget's manager.
  • filter: if set to true, the widget will add the content of the field to a fq parameter instead of appending it to the q parameter (default: false).
  • field: the field in the search engine index this AdvancedSearchField refers to.


Methods

  • init: an init method, that creates the class.
  • getValue: a method returning the value of this field, after call to buildSearchTerm method.
  • reset: an implementation of the parent class method: resets the inputs of this class.
  • buildSearchTerm: expands the field's search term with the available languages: 
    e.g. content:giovanni becomes ((content_en:giovanni) OR (content_it:giovanni))

Information about dynamic query composition:

Since on Solr side we store the title and content on separated fields based on the detected language, the query in input is then translated into the logic OR between the Solr fields that are functionally the same thus having language specialization: 
E.g.: content:datafari =>  (content_fr:datafari) OR (content_en:datafari) OR (content_it:datafari) OR (...).

Then every "expanded" logical term is composed with the other "expanded" search terms by means of the radio buttons.

Please note that the query expansion based on languages is dynamic and it's based on the available languages array in i18n variable. 

How to add a new field:

You need create a new field object and add it to the table object, as follows:
in createAdvancedSearchTable function of both search.js

 

Add new field to advanced search
// Table is already created
 
var ast = new new AjaxFranceLabs.AdvancedSearchTable({ ... });

// Add your field NEW_FIELD
 
var asf = new AjaxFranceLabs.AdvancedSearchField({
		parent : '#advancedSearchTable',
		label : window.i18n.msgStore['advancedSearch-NEW_FIELD-label'],
		description : window.i18n.msgStore['advancedSearch-NEW_FIELD-descr'],
		field : 'NEW_SOLR_FIELD'		
	});
	
ast.addField(asf);



Menu widget

A widget building a dropdown menu.

Variables

  • name: the parent element text to display.
  • menuItems: a collection of the elements to add to the menu ( {name: ..., link: ...}).


Methods

  • buildWidget: an implementation of the parent class method.



Slider widget (beta)

A widget that will help you to select values as range or min/max for a chosen field.

This widget uses the jQuery UI Slider plugin.

Variables

  • name: String - name of the widget that will appear as the title in the search view
  • field: String - the field name in the Solr core that will be used by the widget
  • fieldType: String - the type of the chosen field. Only two values are accepted by the widget, 'date' and 'numeric'. (notice that the lowercases matter)
  • elm: String - the id of the div in the search view that will contain the widget
  • range: Boolean - set to true if you want a slider with a range, false otherwise
  • min: Integer - the minimum value of the slider (also used as the default minimum value if the range slider has been selected). Can be negative
  • max: Interger - the maximum value of the slider (also used as the default maximum value if the range slider has been selected). Can be negative
  • unit: String - this field is only used when the fieldType has been set to 'date'. In that case you have three options 'YEAR', 'MONTH' or 'DAY'. When a date field type is used with this widget, the resulting Solr query filter that will be applied by the widget will be "(field):[NOW(+/-)(slider_value)(unit)]. So keep in mind that the slider will be based on the current date to create the query. For now we didn't have implemented a parameter to change this behavior   
  • defaultValue: Integer - only used when the slider is not in the 'range mode'. Default value when the widget is loaded for the first time
  • step: Integer - defines the number which represents the minimum step performed when the user slide
  • comparator: String - only used when the widget is not in the 'range mode'. Two possible values, 'greater' or 'less' (lowercases matter). When the widget is not in the 'range mode' you have the choice to define if the chosen field value must be greater than or less than the selected  one in the slider. For now we didn't have implemented the 'equal' comparator.

Methods

  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.



Suggest widget

A widget creating a result widget that proposes other suggested documents to your search query. The name may be misleading, this is not the suggest module for an autocomplete, it is rather for a "more like this" behavior.

Variables

  • boots: a list of boosts to apply. { field1: boost_value1, field2: boost_value2, ... }.
  • resultWidget: the result widget which will contain the suggestions, internal use.


Methods

  • init: an implementation of the parent class method.
  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.




OntologySuggestion widget

A widget creating a result widget that proposes the most popular parent and child label of all the results. The name may be misleading, this is not the suggest module for an autocomplete, it is rather for a "related subjects" behavior.

Prerequisites

In order to make this widget work, it is mandatory that the ontologyEnabled parameter of the 'datafari.properties' file is set to true, as the documents (at least a few of them) in the results have been enriched by the OntologyUpdateProcessor

Variables

  • parentLabelsField: the field in your schema that contains the parent documents labels of the ontology
  • childLabelsField: the field in your schema that contains the child documents labels of the ontology
  • useLanguage: (boolean) should use the Datafari selected language for both parentLabelsField and childLabelsField ? If true, be sure that you used the OntologyUpdateProcessor with the parameter userLanguages set to true during the crawl of the documents by MCF


Methods

  • init: an implementation of the parent class method.
  • buildWidget: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.




Pager module

A module creating a pagination.

Variables

  • source: the source elements to apply the pagination on. Optional if the elements are retrieved by an Ajax request.
  • prevLabel: the content of the previous nav button (default: <).
  • nextLabel: the content of the next nav button (default: >).
  • firstLabel: the content of the first nav button (default: <<).
  • lastLabel: the content of the last nav button (default: >>).
  • nbElmToDisplay: the number of elements to display (default: 10).
  • nbPage: the number of pages, internal use.
  • nbPageDisplayed: the number of pages to display in the navigation bar.
  • nbElements: the number of elements in source, internal use.
  • fastNavigationAlwaysVisible: if set to true, will always display the navigation button even if they are useless (eg: first and previous button when you are on the first page. Default: false).
  • display: the css display value of the pagination elements.
  • pageSelected: the page actually selected (default: 0).


Methods

  • init: an implementation of the parent class method.
  • updatePages: the method updating the navigation bar (eg: elements to display)
  • clickHandler: a callback function called when a click on an element of the navigation is detected.
  • updateList: a method always called when a click on an element of the navigation is detected. This method is empty by default and must be implemented if you need it.



Autocomplete module

This module creates a list of suggestions when you type in an input field. Note: this requires enabling a suggest component as a requesthandler of Solr (done in the xml config files), in case you use a pure Solr. If you are using Constellio, this config is normally already activated in its Solr. For Constellio 1.3, it also requires a modification of the web service servlet in order to reach the Constellio autocomplete service. Contact us if you need help.

This module is also an extension of the jQuery UI Autocomplete plugin and also has all its parameters and methods.

Variables

  • options: options given to the jQuery UI Autocomplete plugin.
  • optionsExtend: if set to true, extends the default parameters defined in this module (default: true).
  • render: an empty variable. You can define it a function changing the way an element is rendering in the autocomplete.
  • field: if the values retrived must be focused on a specific field of your search engine index. Note that this option will not work with a standard 1.3 Constellio. It requires a modification of its web service. This field variable becomes the variable "f" in the generated query to the server
  • openOnFieldFocus: if set to true, executes a request to retrieve data when cursor entering the input field (default: false).
  • valueSelectFormat: a function that format the data selected in the autocomplete results (eg: if you want to put it between double quotes).
  • singleValue: if set to true, when a value is choson in the autocomplete result, the actual value in the input field will be replaced by the selected one.
  • searchForItSelf: if set to true, also search the term itself (default: false). This means that the list will contain the word currently typed in addition to the words which have at least one more letter


Methods

  • init: an implementation of the parent class method.



Collection widget

A widget displaying your constellio's collections. Obviously, this widget works only for Constellio. Note that this requires that your manager was initialised with the array of Constellio collections. See AbstractManager.collections for that. Note also that it requires a modification of the Constellio 1.3 web service servlet. Contact us to know what to modify.

Methods

  • buildWidget: an implementation of the parent class method.


Capsule widget

A widget that gives you tips about your search. Does not work for Solr. Note that this only works for Constellio 1.3, with a modified web service in order to support the request.

Methods

  • init: an implementation of the parent class method.
  • buildWidget: an implementation of the parent class method.
  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.



Favorite documents and searches

A module adding the possibility to create a favorite system on your searches and documents. Does not work for Solr. Note that this only works for Constellio 1.3, with a modified web service in order to support the request.

Variables

  • userId: the id of the user manipulating its favorites. This is actually optional if your server is managing the user sessions.


Methods

  • beforeRequest: an implementation of the parent class method.
  • afterRequest: an implementation of the parent class method.
  • removeFavoriteDocument: takes as parameter the id of the favorite document and a callback method.
  • removeFavoriteSearch: takes as parameter the id of the favorite search and a callback method.
  • removeSearchInHistory: takes as parameter the id of the search to remove in the history and a callback method.
  • getFavoriteDocuments: takes as parameter a callback function, the first element to start on and the number of elements to retrieve.
  • getFavoriteSearches: takes as parameter a callback function, the first element to start on and the number of elements to retrieve.
  • getSearchHistory: takes as parameter a callback function, the first element to start on and the number of elements to retrieve.


LoginDatafariFormWidget

The widget containing the login to admin UI form.

The code of this widget has been migrated from embedded JS of login.jsp to a separate widget.

Variables

No specific variables for this widget, only the ones inherited from AjaxFranceLabs.AbstractWidget.


Methods

  • buildWidget: an implementation of the parent class method. Creates the widget.
  • JQuery anonymous function $(function($) {...}: adds the widget to the manager.



LoginDatafariLinksWidget

The widget containing the login to admin UI form.

The code of this widget has been migrated from embedded JS of index.jsp to a separate widget.

Variables

No specific variables for this widget, only the ones inherited from AjaxFranceLabs.AbstractWidget.


Methods

  • buildWidget: an implementation of the parent class method. Creates the widget.



LanguageSelectorWidget

This widget enables the user to change the language of the UI, among the available ones.

When a language change is detected by the application, it gets reset and a new splash page is displayed.

To add a language, you need to add an option in the combo box (option DOM element of buildWidget).

Variables

No specific variables for this widget, only the ones inherited from AjaxFranceLabs.AbstractWidget.


Methods

  • buildWidget: an implementation of the parent class method. Creates the widget.