Package org.ametys.cms.clientsideelement
Class WorkflowStepsClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.cms.clientsideelement.WorkflowStepsClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,MenuClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
FormEntriesWorkflowStepsClientSideElement
public class WorkflowStepsClientSideElement extends StaticFileImportsClientSideElement implements MenuClientSideElement
This element creates multiple toggle buttons representing a workflow. A menu represent workflow actions. The awaited configuration is: <workflow name="WORKFLOWNAME"> <action> <menu-1-label>I18N_KEY</menu-1-label> </action> <workflow-actions mode="exclude"> <action>22</action> <action>222</action> </workflow-actions> <workflow-steps mode="include"> <step>1</step> <step>2</step> </workflow-steps> <steps> <step id="1"> <workflow-actions mode="include"> <action>2</action> </workflow-actions> <comments mode="include"> <action>3</action> </comments> <action> <menu-1-label /> </action> </step> </steps> </workflow> Where WORKFLOWNAME is the name of the workflow such as 'content'. MANDATORY Where <action> is optional to override the default configuration of every step button and step menu The attribute name="..." is optional to specify the JS class used. Where <workflow-actions< is optional to restrict the available actions in the menu. Default value is <workflow-actions mode="exclude"/> The attribute mode="include" indicates that the list of actions ids will replace the one automatically determined (even if it only can by a sublist). Listing ids here ensure that no new actions will appear in this menu if the workflow is modified. The attribute mode="exclude" (default value) indicates that the list of actions ids will be removed from the one automatically determined (it only can by a sublist of it). Listing ids here ensure that when the workflow has a new action it will be added here. Where <steps> is optional and allows you to configure each step specifically. The <step> id attribute is MANDATORY The <workflow-actions> is identical to the one at the root of <workflow> but only for this specific step Where <comments< is identical to <workflow-actions< but to display to the user a dialog box to enter comments. The workflow has to support comments on that action. To avoid comments, set <comments mode="include"/> The <action> is identical to the one at the root of <workflow> but only for this specific step Here is a declaration sample in a plugin.xml file <extension id="org.ametys.cms.workflow.WorkflowSteps" point="org.ametys.core.ui.RibbonControlsManager" class="org.ametys.cms.clientsideelement.WorkflowStepsClientSideElement"> <workflow name="content"> <steps> <step id="1"> <!-- Draft --> <workflow-actions mode="exclude"> <action>2</action><!-- Edit --> </workflow-actions> <comments mode="include"> <action>3</action><!-- propose --> </comments> </step> </steps> </workflow> </extension> Default configuration is proposed upon the StaticFileImportsClientSideElement. - default js class is "Ametys.plugins.cms.content.controller.WorkflowMenu" - default js files are loaded : /plugins/cms/resources/js/Ametys/plugins/cms/content/controller/WorkflowMenu.js and /plugins/cms/resources/js/Ametys/plugins/cms/content/actions/WorkflowAction.js - default js parameters are - label (to the i18nkey application:WORFKLOW_STEP_NAME) - description (to the i18nkey application:WORFKLOW_STEP_NAME_DESCRIPTION) - footerDescription (to the i18nkey application:WORFKLOW_STEP_NAME_FOOTER) - selection-target-id (to ^content$) - icon-small, icon-medium, icon-large (to /plugins/cms/resources_workflow/WORFKLOW_STEP_NAME-small.png for an application i18nkey, or /plugins/PLUGINNAME/resources/img/workflow/WORFKLOW_STEP_NAME-small.png for a plugin i18nkey) - workflow-step (tp the value configured avove) - workflow-name (to the value configured above) - selection-enable-multiselection (true) - selection-description-empty : i18nkey plugin.cms:CONTENT_WORKFLOW_NOSELECTION_DESCRIPTION - selection-description-nomatch : i18nkey plugin.cms:CONTENT_WORKFLOW_NOMATCH_DESCRIPTION - selection-description-multiselectionforbidden : i18nkey plugin.cms:CONTENT_WORKFLOW_NOMULTISELECT_DESCRIPTION - additionnal js parameters are - noaction-available-description : i18nkey for description when no actions are available, plugin.cms:CONTENT_WORKFLOW_NOACTIONAVAILABLE_DESCRIPTION - refreshing-description : i18nkey for description when refreshing, plugin.cms:CONTENT_WORKFLOW_REFRESH_DESCRIPTION - contentselected-start-description : i18nkey for description of the current content selection (start of the description) : plugin.cms:CONTENT_WORKFLOW_DESCRIPTION_BEGIN - contentselected-end-description : i18nkey for description of the current content selection (end of the description) : plugin.cms:CONTENT_WORKFLOW_DESCRIPTION_END - editing-description : i18nkey for description when the content is beeing edited : plugin.cms:CONTENT_WORKFLOW_EDITING_DESCRIPTION So there is no need to define a <class> by default or import js files. Additionnal i18nkeys used are plugin.cms:CONTENT_WORKFLOW_DESCRIPTION and plugin.cms:CONTENT_WORKFLOW_LOCKED_DESCRIPTION
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper
_contentHelper
The content helperprotected ThreadSafeComponentManager<ClientSideElement>
_menuItemManager
The client side element component manager for menu items.protected Map<String,List<ClientSideElement>>
_menuItems
The menu itemsprotected List<ClientSideElement>
_referencedClientSideElement
The referenced client side elementprotected AmetysObjectResolver
_resolver
Ametys object resolverprotected List<ClientSideElement.Script>
_scripts
The scriptsprotected ServiceManager
_smanager
The service managerprotected Map<String,List<String>>
_unresolvedMenuItems
The unresolved itemsprotected UserManager
_userManager
Runtime users managerprotected WorkflowHelper
_workflowHelper
Workflow helperprotected WorkflowProvider
_workflowProvider
Workflow provider-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description WorkflowStepsClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_additionalMenuItemConfiguration(Configuration itemConf, DefaultConfiguration classConf, int actionId, Map<String,Object> parameters)
Additional configuration for menu itemsprotected void
_configureDefaultDescriptions(Map<String,Object> parameters)
Configure the default descriptionprotected void
_configureMenuItems(ClientSideElement.Script script, Configuration configuration)
Configure the menu itemsprotected void
_configureParameters(Map<String,Object> parameters)
Configure parameters recursivelyprotected ClientSideElement.Script
_configureScript(Configuration configuration)
Configure the scriptprotected void
_configureScripts(Configuration workflowConfiguration, List<Integer> stepIds, Map<Integer,Configuration> stepsConfiguration, List<Integer> allowedActionIds, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor)
Configure the list of Scripts, for each step available to the workflow.protected void
_configureWorkflow(Configuration configuration)
Read the workflow configuration, to set up the scripts.protected void
_configureWorkflowStep(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, Integer stepId, Map<String,Object> stepParameters, Configuration stepConfiguration, List<Integer> allowedActionIds)
Configure the parameters specific to the workflow, for the given stepprotected List<Integer>
_configureWorkflowStepActions(String workflowName, Integer stepId, List<Integer> currentStepActions, List<Integer> allowedStepActions, Configuration stepActionsConfiguration)
Get the list of actions available for a step, from the configurationprotected List<Integer>
_getAllowedActions(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, List<Integer> stepIds, boolean actionsIncludeMode, List<Integer> configuredActions)
Get the actions allowed for the current workflow and only for the specified steps.protected List<Integer>
_getAllowedSteps(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, boolean stepsIncludeMode, List<Integer> configuredSteps)
Get the steps allowed for the current workflowprotected String
_getDefaultActionClassName()
Get the default class name for workflow actionprotected String
_getDefaultMenuClassName()
Get the default class name for workflow menuprotected String
_getDefaultPluginName()
Get the default plugin nameprotected String
_getSelectionTargetId()
Get the selection target id (can be a Regexp)void
configure(Configuration configuration)
List<ClientSideElement>
getReferencedClientSideElements(Map<String,Object> contextParameters)
This method returns theClientSideElement
referenced by the menu through its menu or gallery itemsList<ClientSideElement.Script>
getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
This method return the scripts that will be used on client side.Map<String,Object>
getWorkflowState(List<String> contentsId, String scriptId)
Get the workflow state of contentsvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, getDependencies, getId, getPluginName, getRights, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_menuItemManager
protected ThreadSafeComponentManager<ClientSideElement> _menuItemManager
The client side element component manager for menu items.
-
_smanager
protected ServiceManager _smanager
The service manager
-
_userManager
protected UserManager _userManager
Runtime users manager
-
_workflowProvider
protected WorkflowProvider _workflowProvider
Workflow provider
-
_workflowHelper
protected WorkflowHelper _workflowHelper
Workflow helper
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_referencedClientSideElement
protected List<ClientSideElement> _referencedClientSideElement
The referenced client side element
-
_menuItems
protected Map<String,List<ClientSideElement>> _menuItems
The menu items
-
_unresolvedMenuItems
protected Map<String,List<String>> _unresolvedMenuItems
The unresolved items
-
_scripts
protected List<ClientSideElement.Script> _scripts
The scripts
-
-
Constructor Detail
-
WorkflowStepsClientSideElement
public WorkflowStepsClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classStaticFileImportsClientSideElement
- Throws:
ConfigurationException
-
_configureWorkflow
protected void _configureWorkflow(Configuration configuration) throws ConfigurationException
Read the workflow configuration, to set up the scripts.- Parameters:
configuration
- The configuration- Throws:
ConfigurationException
- If an error occurs
-
_getAllowedSteps
protected List<Integer> _getAllowedSteps(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, boolean stepsIncludeMode, List<Integer> configuredSteps)
Get the steps allowed for the current workflow- Parameters:
workflowDescriptor
- The workflow descriptorstepsIncludeMode
- True if the step listed should be the only steps included, false if they should be excluded from all available workflow's steps.configuredSteps
- A list of step ids.- Returns:
- The steps allowed.
-
_getAllowedActions
protected List<Integer> _getAllowedActions(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, List<Integer> stepIds, boolean actionsIncludeMode, List<Integer> configuredActions)
Get the actions allowed for the current workflow and only for the specified steps.- Parameters:
workflowDescriptor
- The workflow descriptorstepIds
- The list of steps specifiedactionsIncludeMode
- True if the action listed should be the only actions included, false if they should be excluded from all available workflow's actions.configuredActions
- A list of actions ids.- Returns:
- The actions allowed.
-
_configureScripts
protected void _configureScripts(Configuration workflowConfiguration, List<Integer> stepIds, Map<Integer,Configuration> stepsConfiguration, List<Integer> allowedActionIds, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor) throws ConfigurationException
Configure the list of Scripts, for each step available to the workflow.- Parameters:
workflowConfiguration
- The configurationstepIds
- The list of stepsstepsConfiguration
- The parameters for each stepallowedActionIds
- The list of globally allowed actions for this workflowworkflowDescriptor
- The descriptor for the current workflow- Throws:
ConfigurationException
- If an error occurs
-
_getDefaultMenuClassName
protected String _getDefaultMenuClassName()
Get the default class name for workflow menu- Returns:
- the default class name
-
_getDefaultActionClassName
protected String _getDefaultActionClassName()
Get the default class name for workflow action- Returns:
- the default class name
-
_configureWorkflowStep
protected void _configureWorkflowStep(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, Integer stepId, Map<String,Object> stepParameters, Configuration stepConfiguration, List<Integer> allowedActionIds) throws ConfigurationException
Configure the parameters specific to the workflow, for the given step- Parameters:
workflowDescriptor
- The descriptor of the workflowstepId
- The stepstepParameters
- The parameters of the stepstepConfiguration
- The step configurationallowedActionIds
- The list of globally allowed actions- Throws:
ConfigurationException
- If an error occurs
-
_configureWorkflowStepActions
protected List<Integer> _configureWorkflowStepActions(String workflowName, Integer stepId, List<Integer> currentStepActions, List<Integer> allowedStepActions, Configuration stepActionsConfiguration) throws ConfigurationException
Get the list of actions available for a step, from the configuration- Parameters:
workflowName
- The name of the current workflowstepId
- The stepcurrentStepActions
- All the actions available for this stepallowedStepActions
- The actions allowed by the configuration for this stepstepActionsConfiguration
- The configuration for the step actions- Returns:
- The list of actions for the step
- Throws:
ConfigurationException
- If an error occurs
-
getReferencedClientSideElements
public List<ClientSideElement> getReferencedClientSideElements(Map<String,Object> contextParameters)
Description copied from interface:MenuClientSideElement
This method returns theClientSideElement
referenced by the menu through its menu or gallery items- Specified by:
getReferencedClientSideElements
in interfaceMenuClientSideElement
- Parameters:
contextParameters
- Contextuals parameters transmitted by the environment.- Returns:
- the referenced client side elements.
-
getScripts
public List<ClientSideElement.Script> getScripts(boolean ignoreRights, Map<String,Object> contextParameters)
Description copied from interface:ClientSideElement
This method return the scripts that will be used on client side. This class will be parametrized by initial and current parameters.- Specified by:
getScripts
in interfaceClientSideElement
- Overrides:
getScripts
in classStaticFileImportsClientSideElement
- Parameters:
ignoreRights
- True to ignore the rights verification.contextParameters
- Contextuals parameters transmitted by the environment.- Returns:
- The list of scripts or an empty list.
-
_configureScript
protected ClientSideElement.Script _configureScript(Configuration configuration) throws ConfigurationException
Description copied from class:StaticFileImportsClientSideElement
Configure the script- Overrides:
_configureScript
in classStaticFileImportsClientSideElement
- Parameters:
configuration
- the global configuration- Returns:
- The script created
- Throws:
ConfigurationException
- The configuration is incorrect
-
_configureParameters
protected void _configureParameters(Map<String,Object> parameters) throws ConfigurationException
Configure parameters recursively- Parameters:
parameters
- The parameters map to fill- Throws:
ConfigurationException
- The configuration is incorrect
-
_getDefaultPluginName
protected String _getDefaultPluginName()
Get the default plugin name- Returns:
- the default plugin name
-
_getSelectionTargetId
protected String _getSelectionTargetId()
Get the selection target id (can be a Regexp)- Returns:
- the selection target id
-
_configureMenuItems
protected void _configureMenuItems(ClientSideElement.Script script, Configuration configuration)
Configure the menu items- Parameters:
script
- The parameters map to fillconfiguration
- The items configuration
-
_additionalMenuItemConfiguration
protected void _additionalMenuItemConfiguration(Configuration itemConf, DefaultConfiguration classConf, int actionId, Map<String,Object> parameters)
Additional configuration for menu items- Parameters:
itemConf
- The item configurationclassConf
- The class configurationactionId
- The workflow action idparameters
- The script parameters
-
_configureDefaultDescriptions
protected void _configureDefaultDescriptions(Map<String,Object> parameters)
Configure the default description- Parameters:
parameters
- The parameters
-
-