Extends the standard Aikau button to allow the payload to dynamically be updated on published topics. This allows a button to be contextually sensitive to changes on the page. Configure the updates by setting the publishPayloadSubscriptions.
It is also possible to configure the button to udpate the payload as the browser URL hash fragment changes (again using an optional mapping).
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Example
{
"name": "alfresco/buttons/AlfDynamicPayloadButton",
"config": {
"publishTopic": "MY_TOPIC_WHEN_CLICKED",
"publishPayload": {
"value": "A"
},
"publishPayloadSubscriptions": [
{
"topic": "MIXIN_COMPLETE_PAYLOAD"
},
{
"topic": "MAP_SELECTED_DATA",
"dataMapping": {
"incomingPayloadProperty": "buttonPayloadProperty"
}
}
],
"useHash": true,
"hashDataMapping": {
"hashFragmentParameterName": "buttonPayloadProperty"
}
}
}
Extends
- alfresco/buttons/AlfButton
Members
-
hashDataMapping :object
-
An optional mapping of hash fragment data to publish payload data. This allows only certain elements of the hash to be used and for them to be assigned to specific properties of the published payload.
Type:
- object
- Default Value:
- null
- Source:
-
publishPayloadSubscriptions :array
-
Represents the topics that will trigger an update of the button payload. Each topic can have it's own mapping of data. If no 'dataMapping' attribute is provided then the entire published payload will be mixed into the payload for the button.
Type:
- array
- Default Value:
- null
- Source:
-
useHash :boolean
-
Indicates whether not has values can be used to map data into the button payload.
Type:
- boolean
- Default Value:
- false
- Source:
Methods
-
mapData(dataMapping, data)
-
Maps the data provided into the payload based on the dataMapping provided.
Parameters:
Name Type Description dataMapping
object The mapping to use for the data data
object The data to be mapped -
onHashChanged(payload)
-
This function is called whenever the browser URL hash fragment is changed.e end of the fragment
Parameters:
Name Type Description payload
object -
onPayloadUpdate()
-
This handles the mapping of data for a subscribed topic. It ensures that a publishPayload object exists and then attempts to map the requested data defined in the supplied dataMapping argument from the payload argument into the publishPayload object. If no dataMapping argument is provided then the entire payload is mixed in.
-
postCreate()
-
Extends the inherited function to check update the payload based on the browser URL hash and set up handlers for hash changes (if useHash is true).
-
postMixInProperties()
-
Extends the inherited function to set up the subscriptions for the [publishPayloadSubscriptions] module:alfresco/buttons/AlfDynamicPayloadButton#publishPayloadSubscriptions entries.
-
setupPayloadSubscriptions()
-
Sets up subscriptions for each configured publishPayloadSubscription entry.