Module: alfresco/services/CrudService

alfresco/services/CrudService

This is a generic service for handling CRUD requests between widgets and the repository. By default all URLs will be encoded unless encodeURIs is configured to be false.
Author:
  • Dave Draper
License:
Source:

Members

i18nRequirements :object[]

An array of the i18n files to use with this service.
Type:
  • object[]
Default Value:
  • [{i18nFile: "./i18n/CrudService.properties"}]
Source:

Methods

addQueryParameter()

Source:
See:

failureCallback(response, originalRequestConfig)

This is called whenever a create, update or delete operation fails. It will generate a notification with a message (optionally supplied as failureMessage in the payload).
Parameters:
Name Type Description
response object The response from the original XHR request.
originalRequestConfig object The configuration passed to the original XHR request.
Source:

getUrlFromPayload(payload) → {string}

This function is called to get the URL from the payload provided and will issue a warning if one is not found. This is called from all the CRUD handling functions. The payload is expected to contain a 'url' attribute that maps to a Repository WebScript. This function will automatically prefix it with the appropriate proxy stem.
Parameters:
Name Type Description
payload object
Source:
Returns:
The URL to use to make the CRUD request or null if no 'url' attribute was provided.
Type
string

onCreate(payload)

Creates a new item via the supplied URL. The payload needs to contain both a 'url' attribute (that indicates the REST API to call) and a 'data' attribute (that defines the object to be created).
Parameters:
Name Type Description
payload object
Source:

onDelete(payload)

Handles delete requests. If the supplied payload contains an attribute "requiresConfirmation" that is set to true, then a dialog will be displayed prompting the user to confirm the delete action. The payload can optionally contain localized messages for the dialog title, prompt and button labels.
Parameters:
Name Type Description
payload object
Source:

onDeleteConfirmation(payload)

This function is called when the user confirms that they wish to peform the delete action.
Parameters:
Name Type Description
payload object An object containing the deletion details.
Source:

onGetAll(payload)

Makes a GET request to the Repository using the 'url' attribute provided in the payload passed in the publication on the topic that this function subscribes to. The 'url' is expected to be a Repository WebScript URL and should not include the Repository proxy stem.
Parameters:
Name Type Description
payload object
Source:

onGetOne(payload)

TODO: This needs to be completed.
Parameters:
Name Type Description
payload object
Source:

onUpdate(payload)

Parameters:
Name Type Description
payload object
Source:

performDelete(url, payload)

Handles the actual deletion, this is abstracted to a separate function so that it can be called from both onDelete and onDeleteConfirmation depending upon whether or not the user needs to confirm the delete action.
Parameters:
Name Type Description
url string The URL to use to perform the delete
payload object The original payload
Source:

refreshRequest(response, originalRequestConfig)

This is called whenever a create, update or delete operation is performed to ensure that any associated list views are refreshed. It does this by publishing on the "ALF_DOCLIST_RELOAD_DATA" topic (for historical reasons - a more generic topic should be used in the future).
Parameters:
Name Type Description
response object The response from the original XHR request.
originalRequestConfig object The configuration passed to the original XHR request.
Source:
Fires:

registerSubscriptions()

Since:
  • 1.0.32
Source:

requestDeleteConfirmation(url, payload)

Called from onDelete when user confirmation for the delete action is required. Displays a dialog prompting the user to confirm the action. The dialog title, prompt and button labels can all be configured via the attributes on the supplied payload.
Parameters:
Name Type Description
url string The URL to use to perform the delete
payload object The original request payload.
Source:

<inner> clonePayload(payload) → {object}

This is a utility function for cloning a payload and removing attributes that should not be passed onto the [serviceXhr] module:alfresco/core/CoreXhr#serviceXhr function
Parameters:
Name Type Description
payload object The payload to clone
Source:
Returns:
The cloned payload
Type
object