Skip to main content

Gift What template

Description

The Gift What template renders column 2 ("For What") of the Gift Widget. It is injected into the mambo-ctrl-gift-what placeholder in the gift shell template once rewards data has loaded from the server.

This template is rendered separately from the shell so that server-data refreshes do not clear user input in the search field or reason textarea. It receives the rewards catalogue and current user data and renders the gifts dropdown, badge image, points dropdown, quantity input, and balance display.

Control classes

ClassDescriptionRequired
mambo-ctrl-gift-flipWrapper for the front and back card elementsNo
mambo-ctrl-show-giftsWrapper for elements shown on the front of the card (gifts view)No
mambo-ctrl-show-ptsWrapper for elements shown on the back of the card (points view)No
mambo-ctrl-gift-sel-whatToggles the mambo-ctrl-gift-flip element between front (gifts) and back (points). Only rendered when both withGifts and withPoints are trueNo
mambo-ctrl-gift-giftsSelect element whose option values are reward indices. On change, updates the badge image in mambo-ctrl-gift-badgeNo
mambo-ctrl-gift-badgeElement where the selected gift reward's badge image is displayedNo
mambo-ctrl-gift-ptsSelect element whose option values are point type IDs. Used together with the quantity input to calculate the remaining balanceNo
mambo-ctrl-gift-qntyInput for the number of points to giveNo
mambo-ctrl-gift-balanceDisplays the giver's remaining balance after the entered quantity is deducted. Updates as quantity changesNo

Template data

VariableDescriptionType
dataObject containing rewards sorted by type. Access gifts via data.gifts.viewData — each entry is passed through Mambo.Util.getRewardObj() to obtain the reward object with name, imageUrl, and active fieldsObject
userCurrent user data object. Access giftable point types via user.points — each entry has pointId, point.name, point.giftable, and balance fieldsObject
withPointsWhether the points gifting UI should be shown. Corresponds to the withPoints render option on the widgetBoolean
withGiftsWhether the gift rewards UI should be shown. Corresponds to the withGifts render option on the widgetBoolean

Implementation example

This example shows the "For What" column with a gift rewards view on the front face of the flip card and a points view on the back face. Use Mambo.Template.giftWhat as the template key.

JavaScript

Customisation options

Consider these enhancements:

  • Customising the gift badge display with additional reward metadata such as description or category
  • Adding a larger preview of the gift image before submission
  • Sorting or filtering the gifts dropdown by category or tag
  • Displaying a full points breakdown or transaction history instead of just the remaining balance
  • Adding a visual warning or tooltip when the entered quantity would result in a negative balance