Module: alfresco/documentlibrary/_AlfHashMixin

alfresco/documentlibrary/_AlfHashMixin

Provides HTML5 style hash based history and location marking. This adopts the pattern originally used by the Document Library in Alfresco Share but can be mixed into any widget that requires hashing. Ideally this should only be mixed into a single widget on a page (e.g. the DocumentList) or multiple publications will occur on a hash change, but the activity of these publications can be tweaked with the careful application of the hashVarsForUpdate, hashVarsForUpdateRequired and hashVarsForUpdateMustEqual.
Author:
  • Dave Draper
  • Richard Smith
License:
Source:

Example

Sample configuration as applied with an AlfHashList)

{
   name: "alfresco/lists/AlfHashList",
   config: {
      loadDataPublishTopic: "MY_TOPIC",
      useHash: true,
      // Trigger a data update when any of these hash variables is present in the hash string
      hashVarsForUpdate: [
         "one",
         "two",
         "three"
      ],
      // Only perform an update when all of these hash variables are still present in the hash string
      hashVarsForUpdateRequired: [
         "one",
         "two"
      ],
      // Only proceed with the data update when the hash variable 'view' is equal to 'my_view'
      hashVarsForUpdateMustEqual: [
         {
            name: "view",
            value: "my_view"
         }
      ],
      widgets: [
         {
            name: "alfresco/lists/views/AlfListView",
            config: {
               ...
            }
         }
      ]
   }
}

Methods

constructor()

Extends the constructor chain to subscribe to the "/dojo/hashchange" topic which is hitched to onHashChange.
Source:

<private> doHashVarUpdate(payload) → {boolean}

Tests if a hashVar update should be performed by combining the results of payloadContainsUpdateableVar (does the hash containing ANYTHING we care about), payloadContainsRequiredUpdateableVars (does the hash contain EVERYTHING we care about) and payloadContainsEqualUpdateableVars (are there values in the hash that are EQUAL to what we care about).
Parameters:
Name Type Description
payload object The payload object
Source:
Returns:
Type
boolean

initialiseFilter(hashString)

Checks the initial state of the hash location. This is to ensure that bookmarks and copied links work on page loading. It is possible to provide an optional hash string which if provided will be used to set the current hash which in turn should trigger an hash change events.
Parameters:
Name Type Description
hashString string An optional string to use as the hash. If not provided the current hash will be
Source:

onHashChange(payload)

Responds to changes in the page hash.
Parameters:
Name Type Description
payload object The publication topic. This object needs to contain the attribute 'filter' for anything to happen.
Source:

<private> payloadContainsEqualUpdateableVars(payload) → {boolean}

Compares the payload object with the hashVarsForUpdateMustEqual array of key value pairs Returns true if hashVarsForUpdateMustEqual is empty Returns true if the payload contains the keys that are specified in hashVarsForUpdateMustEqual at the correct value Returns false otherwise Using configuration, this function allows hash updates to be performed only when a particular hash value is present and equal to a set value.
Parameters:
Name Type Description
payload object The payload object
Source:
Returns:
Type
boolean

<private> payloadContainsRequiredUpdateableVars(payload) → {boolean}

Compares the payload object with the hashVarsForUpdateRequired array of key names Returns true if hashVarsForUpdateRequired is empty Returns true if the payload contains all keys that are specified in hashVarsForUpdateRequired Returns false otherwise Using configuration, this function allows hash updates to be performed only when a particular set of hash values is present. All of the defined keys must be present in the hash string.
Parameters:
Name Type Description
payload object The payload object
Source:
Returns:
Type
boolean

payloadContainsUpdateableVar(payload, updateInstanceValues) → {boolean}

Compares the payload object with the hashVarsForUpdate array of key names Returns true if hashVarsForUpdate is empty Returns true if the payload contains a key that is specified in hashVarsForUpdate Returns false otherwise Using configuration, this function allows hash updates to be performed when a particular hash value changes.
Parameters:
Name Type Description
payload object The payload object
updateInstanceValues boolean Indicates whether or not the list instance should be updated with the payload values
Source:
Returns:
Type
boolean

processHashFilter(data)

Converts a filter string (of the form filter=||)) into an object.
Parameters:
Name Type Description
data object The data to convert to a filter
Since:
  • 1.0.54
Source: