Bulk edit template

From VYRE

Jump to: navigation, search

Summary: This article describes the Bulk edit feature introduced in 4.3.1.

In Unify version 4.4 and above, you can create a Resource for a bulk edit template which will allow you to version the bulk edit template. See Buk Edit Template Resource


Contents

Bulk Editing

Bulk editing in VYRE takes place in two stages:

1. The users searches for and selects items to be edited. Items are added to a bulk editing "shopping basket" (an extension to VYRE's existing asset ordering basket).

2. The user selects which fields, links etc are modified using an extended version of the current content editable templates.



Creating an interface that will allow the user to select items to be added to a bulk edit basket

As long as you can retrieve the ID of an item in your application, you can create an interface to select it for bulk editing. For example, the item might be displayed in a list (as part of the output of a search results portlet, or a list of localizations of a single item) or on its own on page (using an items display portlet).

Items are added to the bulk editing basket using a simple JavaScript function (which we'll come to in a moment). In order to use this function, you will need to include it in your page (page template), as VYRE doesn't automatically include it when it generates a page. The script doesn't need to be called in the of the HTML page, so you can call it in your XSL: For more information on the javascript please see the article: Ajax Basket Framework

Adding

The JavaScript function used to add one or more items to the bulk editing basket is:

addToBasket()

It accepts the following parameters:

  • Item ID - the VYRE ID of the item (or a comma separated list of ids) to be added to the basket. This must be an integer.
  • Collection Schema ID - the collection schema ID of the item to be added to the basket. This must be an integer.
  • Redirect Path - in this case of the bulk editing basket, this will usually be the current page. This should be the full path to the page.
  • Basket Type - this can be either "order" or "bulkEdit". The parameters are case sensitive.

Removing

The corresponding removal function is:

removeFromBasket()

It accepts the following parameters:

  • Item ID - the VYRE ID of the item (or a comma separated list of ids) to be removed from the basket. This must be an integer.
  • Redirect Path - in this case of the bulk editing basket, this will usually be the current page. This should be the full path to the page.
  • Basket Type - this can be either "order" or "bulkEdit". The parameters are case sensitive.

So, in some XSL to output search results, you would might the following code (see figure : search results)

[javascript:addToBasket('{@id}','{collection-schema/@id}','/home/bulk','bulkEdit') Edit]

==Add selected to basket There is also a JavaScript function used to add items based on checkboxes being checked:

addSelectedToBasket()

It accepts the following parameters:

  • Group Name'Bold text' - Name of the "checkbox" elements that should be checked. There should be one check box for each item on the page, all with the same name, with value equal to the item ID.
  • Collection Schema Prefix - Prefix to the "hidden" elements that contain the collection schema ID for each item. Each such hidden element should be named 'schemaGroupPrefix + itemId', where 'itemId' is the ID of an item.
  • Redirect Path - in this case of the bulk editing basket, this will usually be the current page. This should be the full path to the page.
  • Basket Type - this can be either "order" or "bulkEdit". The parameters are case sensitive.

Remove selected from basket

The corresponding removal function is:

removeSelectedFromBasket()

It accepts the following parameters:

  • Group Name - Name of the "checkbox" elements that should be checked. There should be one check box for each item on the page, all with the same name, with value equal to the item ID.
  • Redirect Path - in this case of the bulk editing basket, this will usually be the current page. This should be the full path to the page.
  • Basket Type - this can be either "order" or "bulkEdit". The parameters are case sensitive.

Add entire search to the basket

You can also provide code to add all search results (even if they're spread over more than one page) using action extensions (please see separate documentation for this):

[{search-results/forward/action}{search-results/action-extensions/add-to-basket/bulk-edit} Add All]

Remove all from the basket

Finally, you can provide functionality for removing all the items selected for editing from the bulk edit basket:

File:Moz-screenshot-1.jpg

[javascript:emptyBasket('/home/bulk','bulkEdit'); Remove all]

The user can put items from any repository in the basket, however when the user comes to bulk edit items, they can only do so for one store at a time. Items from the basket that do not come from the store that was edited will remain in the basket for editing.

The basket is persisted through the user's session, but not between user sessions.

Displaying and Editing the Basket

The display and edit of the bulk editing basket is handled by two portlets: Item - Edit Basket and Item - Display Basket. These two portlets share the same configuration parameters, and differ only in the fact that the Edit Basket portlet returns actions that can be used to remove items from the basket. Both portlets can be used to display the contents of the basket.

If you intend the user to manipulate the basket, simply use the Edit Basket portlet. If you want to ensure that the user can not manipulate the basket (perhaps in a final confirmation step), then use the Display Basket portlet. Using the Edit Basket portlet would allow a sophisticated user to manipulate the basket.

The two portlets have only a few parameters:

  • XSL style sheet: the style sheet used to format the XML output of the portlet
  • Select basket to use: there are only two choices, "Bulk edit basket" or "Order Basket"
  • Filter by content store: filters the content of the basket by the repository selected from this list

As with all results portlets, you can decide whether or not to have lightweight results, retrieve linked items (and full content and metadata if desired), and retrieve linked users. Be aware that retrieving extra information can impact on the performance of your application.

The output of the basket should be rendered as usual. The XML provides a number of elements that allow you to manipulate the basket:

delete-path: this allows you to create a link to delete an item from the basket -

(see right hand side)

The 'Item - Display basket' and ‘Item - Edit basket' portlets are not persistent for ‘Bulk edit basket' whereas they are for ‘Order basket'. This means that ‘Item-Display Basket' or ‘Item-Edit Basket' will not recall the content that has previously been added.

Once the user has all the items they want to edit, they can be directed to a page with the appropriate Bulk Editing template portlet.

There is a limit to how many items can be added to basket, and then edited at the same time. Too many items will cause the process to time out.

Bulk Edit Templates

Bulk Edit templates allow the administrator to create and control the interface that users work with once they have selected the items they wish to bulk edit.

Bulk edit adds the functionality to edit and update multiple items at the same time.

It is used in the same way as Content templates, and in fact the JSP tag libraries that Bulk edit uses extends the Content template tag libraries. When the user has selected to update items the update process is run in the background by the same functionality that is used for importing items.

The Bulk edit tag library is a subset of the Content template tag library, removing some tags and attributes, and introducing some new attributes.

This document will manly focus on the new attributes.

Please see below an overview of tags which are shared with content template and newly added tags for for bluk edit.


<%@ taglib uri="http://www.vyre.com/taglibs/vyre-bulk-edit-items-1.0" prefix="vyre-bulk" %>


Bulk editing templates are used in the same way as Content templates, and in fact the JSP tag libraries that Bulk Editing use extends the Content template tag libraries. Bulk Edit templates are stored separately to content editing templates, and you cannot combine the two different types of templates.

When the user updates the items they have selected the update process is run in the background using the same functionality that is used for importing items. Once a user has completed the bulk edit form, they will be presented with a status report that updates them on the progress (or any errors) of the update process, finally presenting them with a confirmation message.

The Bulk edit tag library is based on a subset of the Content template tag library, but introduces some tags and attributes of its own. Please note while many of the tags are similar to the content editing tags, many attributes are not applicable in the context of bulk editing, and some behave differently. The following tags are in the library:

vyre-bulk:attribute

The following attributes can be used in this tag (one of id, externalId or name MUST be specified):

  • id - the ID of the attributes
  • externalId - the external ID of the attribute (from an attribute template)
  • name - the case sensitive name of the attribute
    • id (id is not a relevant attribute here, since id of an item cannot be edited.)
    • name
    • description
    • keywords
    • locale (locale is not a relevant attribute here, since locale of an item cannot be edited.)
  • mode - [field/element] this is the input mode. If "field" is specified, then an input form field will be displayed. If "element" is specified, then (on submit) the value will be retrieved using innerHTML (or value if the element name is "input") from an HTML element (elementId attribute needs to be specified for this to work).
  • hidden - [true/false] For mode="field". Specifies whether the input field should be hidden. Defaults to false.
  • label - [true/false] For mode="field". Specifies whether the label should be shown. Defaults to true.
  • elementId - For mode="element". The ID of the HTML element from which the value will be retrieved.
  • defaultValue - A default value for the attribute. If not specified the default value specified in the attribute definition will be used.
  • presentationRuleId - The ID of the presentation rule to use for this attribute, if omitted the default presentation rule will be used. Works for custom attributes, and the name, description, and keywords. (since 4.3)
  • presentationRuleName - The case-insensitive name of the presentation rule to use for this attribute, if omitted the default presentation rule will be used. Works for custom attributes, and the name, description, and keywords. Note that presentationRuleId overrides any value in this attribute. (since 4.3)
  • override - [true/false] if the input value is empty, then if this is true, an empty calue will overwrite any value that already exists, if false, the existing value of the attribute will not be changed if the input field is left blank. Override does not work for ‘keywords', ‘name' and ‘description'.
  • overrideSelector - [none/select/checkbox/radiobutton]. If "select", "checkbox" or "radiobutton" are chosen, the user will be
    • override=true and overrideSelector=none no options presented to the user. If the field is blank, the empty value will be written over the existing value
    • override=false and overrideSelector=none no options presented to the user. If the field is blank, target attribute will NOT be updated
    • override=true and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute.
    • override=true and overrideSelector=checkbox a single checked checkbox labeled with "Override with empty value" be displayed. The user can uncheck the box to prevent the action being run on that attribute.
    • override=false and overrideSelector=checkbox a single unchecked checkbox labeled with "Override with empty value" be displayed. The user can check the box to have the action run on that attribute.
    • override=true and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute.

vyre-bulk:action

The following attributes can be used in this tag:

  • type: Specifies the action to be performed. There is currently only one available action:
    • update

Note that this tag prints a javascript method call, so if you are using it inside an anchor tag (a href...), then remember to use the "javascript" prefix.

vyre-bulk:taxonomy

  • type: [add/remove] Default is "add". "add" is a tree of categories items will be added to, "remove" is a tree of categories items will be removed from. If the "add" is selected, the any branch selected will automatically select all ancestors in the tree. If "delete" is selected, the tree will automatically deselect all descendants.

Refer to Content template#vyre-item:taxonomy for other attributes available.

NOTE: a subtle difference between these tags is that bulk edit template would hide edit restricted categories by default and content template wouldn't (due to legacy reasons).

Hint: there can be 2 trees in the same Bulk edit template, one for categories to add, and another for categories to remove from.

vyre-bulk:item-link

The following attributes can be used in this tag (one of id, name HAS to be specified):

  • id - the ID of the link definition.
  • name - The name of the link definition (that is, the name of the other end of the link definition).
  • mode - [field/formatted] The editing mode. If set to "field", then the old drop-down list will be displayed. If set to "formatted", then XSL will be used to transform the list (and xslId or xslName MUST be specified).
  • xslId - Only for mode="formatted". The ID of the XSL stylesheet to use (this must be an item list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslName - Only for mode="formatted". The name of the XSL stylesheet to use (this must be an item list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslPath (from Unify 4.8 only) - Only for mode="formatted". Allows to specify full path to XSL including folder name, e.g. '/Others/some_xsl'.
  • lightweight - [true/false] Only for mode="formatted". If false, then the full content and metadata of the linked items will be loaded. Defaults to "true".
  • elementId - Only for mode="formatted". The ID of the HTML element that contains the link list.
  • cardinality - [one/many] Only for mode="field". Can be either "one" or "many", default is "one". Determines whether to display a multiple select box or not.
  • saveType - Only for mode="field". Specifies how to save the links. Either "replace_existing" (default) or "add_to_existing". If saveType=add_to_existing has been selected then override and overrideSelector is not available.
  • inputType [select/detect] Only for mode="field". Specifies how to get the link values. Defaults to "select". When "detect" is specified, then the link field will be hidden and the IDs of the items to link to will be retrieved from a request parameter by the name of "link_${linkDefinitionId}".
  • firstOptionEmpty - [true/false] Only for mode="field", inputType="select", cardinality="one". Specifies whether the first option in the select list should be an empty option (default is true).
  • savedSearchId - Only for mode="field". ID of a saved search to filter the options (optional).
  • savedSearchName Only for mode="field". Name of a saved search to filter the options (optional).
  • locale - Only for mode="field" and inputType="select" ; use this attribute to filter items in a specific locale. The possible values are: a Locale ID String ('en', 'en_US', etc.), or 'user_locale' (displays items in the same locale as the currently logged-in user) or 'site_locale' (displays items in the same locale as the site the user is currently browsing).
  • override - [true/false] if the input value is empty, then if this is true, an empty value will overwrite any value that already exists, if false, the existing value of the attribute will not be changed if the input field is left blank. Override only works with saveType=replace_existing.
  • overrideSelector - [none/select/checkbox/radiobutton]. If "select", "checkbox" or "radiobutton" are chosen, the user will be
    • override=true and overrideSelector=none no options presented to the user. If the field is blank, the empty value will be written over the existing value
    • override=false and overrideSelector=none no options presented to the user. If the field is blank, target attribute will NOT be updated
    • override=true and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute.
    • override=true and overrideSelector=checkbox a single checked checkbox labeled with "Override with empty value" be displayed. The user can uncheck the box to prevent the action being run on that attribute.
    • override=false and overrideSelector=checkbox a single unchecked checkbox labeled with "Override with empty value" be displayed. The user can check the box to have the action run on that attribute.
    • override=true and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute.

To add actions for adding/removing linked items in the XSL, VYRE provides the following variables that can be used in the XSL style sheet:

$link_add_action: prints a javascript function call that opens the popup window for selecting items to link to.

$link_clear_action: prints a javascript function call for clearing all linked items.

$link_remove_functionname: prints the name of a javascript function for removing a specific linked item. See note below.

$linkDefinitionId: prints the ID of the current link definition.

When printing an action to remove a single item from a list of linked items, something along the lines of the following should be used in the XSL:

href="javascript:$link_remove_functionname('$linkDefinitionId', '{@id}')"

Where {@id} is an XPath reference to the ID of the current item.

vyre-bulk:user-link

The following attributes can be used in this tag (one of id, name HAS to be specified):

  • id - the ID of the link definition
  • linkTitle - unique title of the link definition, introduced in 4.8
  • name - See The name of the link definition (that is, the name of the other end of the link definition). Deprecated in 4.8, use linkTitle.
  • mode - [field/formatted] The editing mode. If set to "field", then the old drop-down list will be displayed. If set to "formatted", then XSL will be used to transform the list (and xslId or xslName MUST be specified).
  • xslId - Only for mode="formatted". The ID of the XSL stylesheet to use (this must be a user list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslName - Only for mode="formatted". The name of the XSL stylesheet to use (this must be a user list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslPath (from Unify 4.8 only) - Only for mode="formatted". Allows to specify full path to XSL including folder name, e.g. '/Others/some_xsl'.
  • elementId - Only for mode="formatted". The ID of the HTML element that contains the link list.
  • cardinality - [one/many] Only for mode="field". Can be either "one" or "many", default is "one". Determines whether to display a multiple select box or not.
  • loadItemLinks - [true/false] Only for mode="formatted". If true, then the linked items will be loaded. Defaults to "false". (since 4.5)
  • loadLinkedContentAndMetadata - [true/false] Only for mode="formatted". If true, then the content and metadata for the linked items will be loaded. Defaults to "false". (since 4.5)
  • saveType - Only for mode="field". Specifies how to save the links. Either "replace_existing" (default) or "add_to_existing". If saveType=add_to_existing has been selected then override and overrideSelector is not available.
  • inputType - [select/detect_user/detect_parameter] Only for mode="field". Specifies how to get the link values. Defaults to "select". When "detect_parameter" is specified, then the link field will be hidden and the IDs of the users to link to will be retrieved from a request parameter by the name of "link_${linkDefinitionId}". When "detect_user" is specified, then the ID of the user currently logged in will be used.
  • firstOptionEmpty - [true/false] Only for mode="field", inputType="select", cardinality="one". Specifies whether the first option in the select list should be an empty option (default is true)
  • groupId - Only for mode="field". ID of a group to filter the options (optional)
  • groupName - Only for mode="field". Name of a group to filter the options (optional).
  • profileGroupId - Only for mode="field". ID of a profile group to filter the options (optional)
  • profileGroupName - Only for mode="field". Name of a profile group to filter the options (optional).
  • override - [true/false] if the input value is empty, then if this is true, an empty calue will overwrite any value that already exists, if false, the existing value of the attribute will not be changed if the input field is left blank. Override only works with saveType=replace_existing.
  • overrideSelector - [none/select/checkbox/radiobutton]. If "select", "checkbox" or "radiobutton" are chosen, the user will be
    • override=true and overrideSelector=none no options presented to the user. If the field is blank, the empty value will be written over the existing value
    • override=false and overrideSelector=none no options presented to the user. If the field is blank, target attribute will NOT be updated
    • override=true and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=select a select box with "Leave if empty" and "Override with empty value" options will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute.
    • override=true and overrideSelector=checkbox a single checked checkbox labeled with "Override with empty value" be displayed. The user can uncheck the box to prevent the action being run on that attribute.
    • override=false and overrideSelector=checkbox a single unchecked checkbox labeled with "Override with empty value" be displayed. The user can check the box to have the action run on that attribute.
    • override=true and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Override with empty value". The user can choose which behavior will be run on that attribute.
    • override=false and overrideSelector=radiobutton two radio buttons one labelled "Leave if empty" and one labeled "Override with empty value" will be displayed. The default selection will be "Leave if empty". The user can choose which behavior will be run on that attribute

vyre-bulk:attribute

The following attributes can be used in this tag (one of id, externalId, name HAS to be specified):

  • id - See Content template document
  • externalId - See Content template document
  • name - See Content template document
  • mode - See Content template document
  • hidden - See Content template document
  • label - See Content template document
  • elementId - See Content template document
  • defaultValue - See Content template document
  • presentationRuleId - See Content template document
  • presentationRuleName - See Content template document
  • override - [true/false] If this is "true", then the existing attribute value will be overridden by the default value.
  • overrideSelector - [none/select/checkbox/radiobutton]

vyre-bulk:action

The following attributes can be used in this tag:

  • type: Specifies the action to be performed. This can be one of the following:
    • update

Note that this tag prints a javascript method call, so if you are using it inside an a href, then remember to use the "javascript:" prefix.

vyre-bulk:taxonomy

The following attributes can be used in this tag:

  • sorting: See Content template document
  • hideRestricted: See Content template document
  • rootIds: See Content template document
  • rootPaths: See Content template document
  • localizeLabels: See Content template document
  • type: [add/remove] Default is "add". "add" is a tree of categories items will be added to, "remove" is a tree of categories items will be removed from. There can be 2 trees in the same Bulk edit template, one for categories to add to and another for categories to remove from.

vyre-bulk:item-link

The following attributes can be used in this tag (one of id, name HAS to be specified):

  • id - See Content template document
  • name - See Content template document
  • mode - See Content template document
  • xslId - See Content template document
  • xslName - See Content template document
  • lightweight - See Content template document
  • elementId - See Content template document
  • cardinality - See Content template document
  • saveType - See Content template document
  • inputType - See Content template document
  • firstOptionEmpty - See Content template document
  • savedSearchId - See Content template document
  • savedSearchName - See Content template document
  • locale - See Content template document
  • loadVersionHistory - See Content template document
  • loadVersionContent - See Content template document
  • override - [true/false] If this is "true", then the existing attribute value will be overridden by the default value.
  • overrideSelector - [none/select/checkbox/radiobutton]

vyre-bulk:user-link

The following attributes can be used in this tag (one of id, name HAS to be specified):

  • id - See Content template document
  • name - See Content template document
  • mode - See Content template document
  • xslId - See Content template document
  • xslName - See Content template document
  • elementId - See Content template document
  • cardinality - See Content template document
  • saveType - See Content template document
  • inputType - See Content template document
  • firstOptionEmpty - See Content template document
  • groupId - See Content template document
  • groupName - See Content template document
  • profileGroupId - See Content template document
  • profileGroupName - See Content template document
  • override - [true/false] If this is "true", then the existing attribute value will be overridden by the default value.
  • overrideSelector - [none/select/checkbox/radiobutton]



Screenshots

Figure 1

Image:BulkEdit2_xsl_search_results.jpg

Figure 2

Image:BulkEdit3_href_add_all.jpg

Figure 3

Image:BulkEdit4_href_remove_all.jpg

Figure 4

Image:BulkEdit5_href_delete.jpg

Related Links

Ajax Basket Framework

Personal tools