Module: alfresco/services/DragAndDropModellingService

alfresco/services/DragAndDropModellingService

This service should be used in conjunction with the DragAndDropTargetControl and the widgets in the "alfresco/dnd" package. It should be configured with models for how dropped items should be both rendered and edited. Each model should be placed into the models array. An example model might look like this:

{
   property: "name",
   targetValues: ["alfresco/forms/controls/(.*)"],
   widgetsForConfig: [
      {
         id: "ALF_EDIT_FORM_CONTROL_LABEL",
         name: "alfresco/forms/controls/TextBox",
         config: {
            fieldId: "LABEL",
            label: "Label",
            description: "The label for the form field value",
            name: "config.label"
         }
      }
   ],
   widgetsForDisplay: [
      {
         name: "alfresco/dnd/DroppedItemWrapper",
         config: {
            label: "{label}",
            value: "{value}",
            type: "{type}",
            widgets: [
               {
                  name: "alfresco/dnd/DroppedItemWidgets"
               }
            ]
         }
      }
   ]
}

In this example we are mapping the configuration of a dropped item that has a property "name" that matches any of the Regular Expressions defined in the "targetValues" array (in this case we are targeting any data objects that have a "name" property that maps to that of a form control wigdget (e.g. "alfresco/forms/controls/TextBox")). If the criteria for this model is met then the "widgetsForConfig" or "widgetsForDisplay" arrays will be returned depending upon which has been asked for.

The "widgetsForDisplay" array is a model of widgets that will be rendered for the dropped item and the "widgetsForConfig" array is a model of widgets that can be used to edit the value of that item.

Author:
  • Dave Draper
License:
Source:

Members

models :array

This should be configured as an array of models to inspect when data is requested. See the main service description above for details.
Type:
  • array
Default Value:
  • null
Source:

widgetsForDefaultConfig :array

This is the default widget model to use as for editing dropped items.
Type:
  • array
Source:

widgetsForDefaultDisplay :array

This is the default widget model to render for dropped items that are not matched against any specific model.
Type:
  • array
Source:

widgetsForDefaultNestedConfig :array

This is the default widget model to include when editing nested dropped items.
Type:
  • array
Source:

Methods

addConfig(parameters)

Add the externalised configuration defined for a template to the model for displaying it.
Parameters:
Name Type Description
parameters object
Since:
  • 1.0.49
Source:

findDropTargets(parameters) → {boolean}

Find the drop targets in a template and ensure that they are have the appropriate template configuration applied to them (i.e. that when they are displayed they are shown with the externalised template label and set the appropriate property).
Parameters:
Name Type Description
parameters object The template processing parameters
Since:
  • 1.0.49
Source:
Returns:
An indication as to whether or not a template was processed.
Type
boolean

matchesTargetValue(value, regex) → {boolean}

This function is used by the processModel function to test a supplied value against a Regular Expression to determine whether or not the model applies to the value.
Parameters:
Name Type Description
value object The value to test
regex string The string to use to build a Regular Expression with to test the value against.
Source:
Returns:
True if the value matches against the Regular Expression and false otherwise.
Type
boolean

onDroppedItemDataRequest(configAttribute, payload)

Handles requests to find a model that matches the value provided in the published payload. If a matching model is found then the supplied configuration from that model will be published in response.
Parameters:
Name Type Description
configAttribute string The attribute to use from the configuration if the model matches
payload object The payload provided
Source:

processModel(configAttribute, response, value, model)

Inspects the supplied model with data provided to see whether or not the model matches the data.
Parameters:
Name Type Description
configAttribute string The configuration attribute to return from the model
response object The payload object to populate if the current model matches the supplied value.
value object The value to compare against the model provided
model object The model to test the value against
Source:

provideResponse(payload, response)

Provides a response to the request for information via either a promise or on a response topic depending upon what has been provided in the supplied payload argument.
Parameters:
Name Type Description
payload object An object containing the details of the request.
response object The response to return.
Source:

registerSubscriptions()

Sets up the subscriptions for the service
Since:
  • 1.0.32
Source: