Module: alfresco/services/ActionService

alfresco/services/ActionService

This handles publications requesting to perform actions on documents. It instantiates a "legacy" YUI2 based Alfresco.DocListToolbar widget which is delegated any actions that aren't explicitly handled by the service. Over time this service should handle more and more of the core document actions as the old YUI2 code is phased out. However, currently it just aliases those actions as well as any custom actions that are registered by extensions. Custom actions prior to 4.2 were provided via the YAHOO.Bubbling.fire("registerAction" ...) event where the target function accepted a single argument of the file to work with. "action.js" handles the registering of these functions. "toolbar.js" augments its prototype with that of "action.js" to get all of the default action handlers and in turn will be able to register additional handlers. Custom actions only supported single files in versions prior to 4.2
Author:
  • Dave Draper & David Webster
License:
Source:

Members

_currentNode :object

The current Node that content will be worked relative to.
Type:
  • object
Default Value:
  • null
Source:

containerId :string

This should be set when the current context is a site, typically this will be set to "documentlibrary"
Type:
  • string
Default Value:
  • null
Source:

currentlySelectedDocuments :object

This is used to keep track of the documents that are currently selected. It is initialised to an empty array in the constructor, the onDocumentSelected function adds elements and the onDocumentDeselected function removes them.
Type:
  • object
Default Value:
  • null
Source:

currentTarget :string

This can be set to either "NEW" or "CURRENT" to indicate whether or not a linked page is displayed in the current or a new window/tab. This setting is only honoured if an action is not explicitly configured with a target.
Type:
  • string
Default Value:
  • "CURRENT"
Source:

i18nRequirements :object[]

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

rootNode :string

This should be set if "siteId" is not set.
Type:
  • string
Default Value:
  • null
Source:

selectionTimeout :timeout

This is used to keep a reference to a timeout that is started on the publication of a selected document topic. It is important that multiple selection events can be captured so that only one publication of selected items occurs. Otherwise the responsiveness ot the UI is degraded as each individual selection event is processed (e.g. by AlfDocumentActionMenuItems)
Type:
  • timeout
Default Value:
  • null
Source:

siteId :string

This should be set when the current context is a site.
Type:
  • string
Default Value:
  • null
Source:

Methods

addSelectedItems(payload)

This function is called when handling actions for the currently selected items. If the payload provided does not include a "documents" attribute then one will be created and populated with the selected items that have been tracked by this service. Ideally this will not be necessary as the payload should include the items populated by the AlfSelectedItemsMenuBarPopup.
Parameters:
Name Type Description
payload object The data passed in the request to perform the action.
Since:
  • 1.0.38
Source:

createJavaScriptContent(payload)

Calls a JavaScript function to handle content creation.
Parameters:
Name Type Description
payload object The payload published on the requesting topic
Source:

createLinkContent(payload, document)

Links to an external page to handle content creation.
Parameters:
Name Type Description
payload object The payload published on the requesting topic
document object The document to perform the action on.
Source:

createPageLinkContent(payload, document)

Links to another page within Share to handle the content creation.
Parameters:
Name Type Description
payload object
document object The document to perform the action using.
Source:

deferredSelectionHandler()

This is called from onDocumentSelected when the selectionTimeout times out. It rests the selectionTimeout to null and calls onSelectedItemsChanged
Source:

getSelectedDocumentArray()

Converts the currently selected documents object into an array for easier iteration.
Source:

handleCurrentNodeChange()

Source:

handleMultiDocLegacyAction(payload)

Parameters:
Name Type Description
payload object The data passed in the request to perform the action.
Source:

handleSingleDocAction(payload)

This function handles requests to perform an action on a single document. The action will be handled by the legacy action handler.
Parameters:
Name Type Description
payload
Source:

onActionAssignWorkflow(payload)

Assign workflow.
Parameters:
Name Type Description
payload object The payload from the original request
Source:
Fires:

onActionChangeType(payload)

Handles requests to change the type of a node.
Parameters:
Name Type Description
payload object The payload from the original request
Since:
  • 1.0.58
Source:
Fires:

onActionCloudSync(payload)

Handles requests to sync content to the cloud.
Parameters:
Name Type Description
payload object The payload from the original request
Since:
  • 1.0.94
Source:
Fires:

onActionCompleteSuccess(payload)

Used by action handlers. Deletes subscription handle and reloads doclist.
Parameters:
Name Type Description
payload object
Source:

onActionCopyTo(payload)

Handles requests to copy the supplied documents to another location.
Parameters:
Name Type Description
payload object The payload from the original request
Source:
Fires:
  • module:alfresco/core/topics#event:COPY_OR_MOVE

onActionDelete(payload)

Handles requests to delete the supplied document.
Parameters:
Name Type Description
payload object The payload from the original request
Source:
Fires:
  • module:alfresco/core/topics#event:DELETE_CONTENT

onActionDetails(payload)

Handles requests to edit the basic metadata of the node provided.
Parameters:
Name Type Description
payload object The response from the request
Source:

onActionDownload(payload)

Handles requests to download multiple items as a single archive file. This is only expected to be called as a multiple item selection action
Parameters:
Name Type Description
payload object The payload from the original request
Since:
  • 1.0.33
Source:
Fires:
  • module:alfresco/core/topics#event:DOWNLOAD_AS_ZIP

onActionEditInline(payload, document)

Handles requests to edit a document inline.
Parameters:
Name Type Description
payload object The response from the request
document object The document to edit.
Source:

onActionEditInlineSucess(payload)

This function will be called in response to a documents details being successfully retrieved.
Parameters:
Name Type Description
payload object
Source:
Fires:
  • event:ALF_CREATE_FORM_DIALOG_REQUEST

onActionEditOffline(payload)

Handles requests to edit the supplied document offline. This posts a request to the "/slingshot/doclib/action/checkout/node/{store_type}/{store_id}" repository WebScript to checkout the document. Successful requests are handled by the onActionEditOfflineSuccess function and failed requests are handled by the onActionEditOfflineFailure function.
Parameters:
Name Type Description
payload object The payload from the original action request
Source:

onActionEditOfflineFailure(response, originalRequestConfig)

This is the failure callback handler from the XHR request made by onActionEditOffline. It prompts the user with a message indicating that the document could not be checked out.
Parameters:
Name Type Description
response object The response from the request
originalRequestConfig object The configuration passed on the original request
Source:

onActionEditOfflineSuccess(response, originalRequestConfig)

This is the success callback handler from the XHR request made by onActionEditOffline. The success response should contain a download URL for the checked out document which is then passed to the browser to automatically trigger a download of the document. A request is then published to reload the document list data.
Parameters:
Name Type Description
response object The response from the request
originalRequestConfig object The configuration passed on the original request
Source:

onActionFolderDownload(payload)

Handles requests to start a folder download.
Parameters:
Name Type Description
payload object The payload from the original request
Source:
Fires:
  • module:alfresco/core/topics#event:DOWNLOAD_AS_ZIP

onActionManageAspects(payload)

Parameters:
Name Type Description
payload object The payload from the original request
Source:

onActionMoveTo(payload)

Handles requests to move the supplied documents to another location.
Parameters:
Name Type Description
payload object The payload from the original request
Source:
Fires:
  • module:alfresco/core/topics#event:COPY_OR_MOVE

onActionSimpleRepoAction(payload)

Handles the "onActionSimpleRepoAction" that is used by multiple configured actions within Alfresco Share. The publication that mapped to the "action" attribute is called. Currently this is only supporting the "document-approve" and "document-reject" actions which are delegated to the SimpleWorkflowService.
Parameters:
Name Type Description
payload object The payload from the original request
Source:

onActionUploadNewVersion(payload)

Handles requests to upload a new version of the supplied document.
Parameters:
Name Type Description
payload object The payload supplied on the original request
Source:

onDocumentDeselected(payload)

Updates the array of documents that are currently selected.
Parameters:
Name Type Description
payload object The details of the document selected
Source:

onDocumentSelected(payload)

Updates the aray of documents that are currently selected.
Parameters:
Name Type Description
payload object The details of the document selected
Source:

onDocumentsLoaded(payload)

The primary purpose of this function is to reset the 'currentlySelectedDocuments' attribute.
Parameters:
Name Type Description
payload object The details of the documents loaded
Source:

onFileAction(layer, args)

Generic file action event handler
Parameters:
Name Type Description
layer object Event fired
args array Event parameters (depends on event type)
Source:

onSelectedItemsChanged()

Handle changes in file selection by updating the ActionService 'currentlySelectedDocuments' attribute so that other handlers can apply actions to the appropriate files and then evaluates the permissions and aspects on the selected files and publishes the details on the 'selectedDocumentsChangeTopic' attribute topic to allow menus to filter actions appropriately.
Source:

processActionObject(payload)

This function handles requests to create new content. It handles content creation of 4 different types: - pagelink (a link to another page within the application) - link (a link to an external page) - javascript (calls a JavaScript action handler) - template (creates templated content)
Parameters:
Name Type Description
payload object The original payload requesting the action
Source:

registerSubscriptions()

Sets up the subscriptions for the Action Service
Since:
  • 1.0.32
Source:
Listens to Events:

requestRefresh()

Source:

<inner> onActionCancelEditing(payload)

Cancels Editing for checked out documents.
Parameters:
Name Type Description
payload object The payload supplied on the original request
Source:

<inner> onActionLocate(item)

Parameters:
Name Type Description
item object The item to perform the action on
Source: