Difference between revisions of "WID/Current/SDK/Calendar-combined"

From Genesys Documentation
Jump to: navigation, search
(Published)
(Published)
 
(8 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
|Context=Learn how to display a calendar, so your customers can choose when they want to be contacted.
 
|Context=Learn how to display a calendar, so your customers can choose when they want to be contacted.
 
|ComingSoon=No
 
|ComingSoon=No
|Platform=PureEngage
+
|Platform=GenesysEngage-cloud
 +
|Role=Developer
 
|Section={{Section
 
|Section={{Section
 
|sectionHeading=Overview
 
|sectionHeading=Overview
 
|alignment=Vertical
 
|alignment=Vertical
|structuredtext=The Calendar UI plugin displays time slots for a selected day. Each day is divided into 3 sections (for example, 'Morning', 'Afternoon' and 'Evening'). The number of days to display—as well as the opening and closing times for a day—are configurable, as shown in the {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=configuration}} section.
+
|structuredtext=The Calendar UI plugin displays time slots for a selected day. The number of days to display—and the opening and closing times for a day—are configurable, as shown in the {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=configuration}} section.
  
[[File:Calendar MainScreen 04032020.jpg|546x546px]]
+
[[File:Calendar MainScreen 04032020.jpg|546x546px|alt=The Calendar UI displays a list of dates and times to choose from]]
 
===Usage===
 
===Usage===
{{NoteFormat|By default, the Calendar widget needs a UI container to display itself properly. Refer to the {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=events|display text=events}} section for information about how to create and display a calendar.}}
+
{{NoteFormat|By default, the Calendar widget needs a UI container to display itself properly. For information about how to create and display a calendar, see the {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=events|display text=API events}} section.|}}
  
 
*Enable or disable certain sections of a day using {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=calendarHours.section.enable}}
 
*Enable or disable certain sections of a day using {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=calendarHours.section.enable}}
*Define your own business hours for each section of a day using {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=calendarHours.section.openTime and calendarHours.section.closeTime}}
+
*Define your own business hours for each section of a day using {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=calendarHours.section.openTime}} and {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=calendarHours.section.closeTime}}
 
*Use {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=showAvailability}} to enable only those time slots for which a customer service agent is available and disable the rest.
 
*Use {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=showAvailability}} to enable only those time slots for which a customer service agent is available and disable the rest.
 
*Define your own {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=time interval}} between each time slot.
 
*Define your own {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=config|display text=time interval}} between each time slot.
 +
 +
====How does the Calendar widget render time slots in local time zones?====
 +
 +
#The Calendar widget uses the command <tt>showAvailability</tt> which calls <tt>CallbackService.availability</tt> with the start date. This start date is then converted into the [https://en.wikipedia.org/wiki/ISO_8601 ISO 8601] format, using UTC as the timezone by <tt>toISOString()</tt>, internally.
 +
#The Callback service fetches the available time slots from the server.
 +
#The Calendar gets the available time slots from <tt>CallbackService.availableSlots</tt> in the ISO 8601 format, using UTC as the timezone.
 +
#Each and Every Time Slot is converted according to the user's local time zone internally through <tt>Date()</tt> and <tt>toTimeString()</tt> methods in the Calendar Plugin.
  
 
===Customization===
 
===Customization===
All the texts displayed by the Calendar widget are fully {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=localize|display text=localizable}}.
+
All the texts displayed by the Calendar Widget are fully {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=localize|display text=localizable}}.
 
===Namespace===
 
===Namespace===
The Calendar plugin has the following namespaces tied-up with each of the following types:  
+
The Calendar plugin has the following namespaces tied to each of the following types:  
 
{{{!}} class="wikitable" style="width: auto;"
 
{{{!}} class="wikitable" style="width: auto;"
 
{{!}}-
 
{{!}}-
Line 35: Line 43:
 
{{!}}{{!}}calendar
 
{{!}}{{!}}calendar
 
{{!}}-
 
{{!}}-
{{!}}{{!}}CXBus—{{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=commands|display text=API Commands}} & {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=events|display text=API Events}}
+
{{!}}{{!}}CXBus—{{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=commands|display text=API commands}} & {{Link-SomewhereInThisVersion|manual=SDK|topic=Calendar-combined|anchor=events|display text=API events}}
 
{{!}}{{!}}Calendar
 
{{!}}{{!}}Calendar
 
{{!}}-
 
{{!}}-
Line 42: Line 50:
 
{{!}}}
 
{{!}}}
  
===Mobile Support===
+
===Mobile support===
Calendar supports both desktop and mobile devices. Like all Genesys Widgets, there are two main modes: Desktop and Mobile. Desktop is used for monitors, laptops, and tablets, while Mobile is used for smartphones. When a smartphone is detected, Calendar switches to special full-screen templates that are optimized for both portrait and landscape orientations.  
+
Calendar supports both desktop and mobile devices. Like all Genesys Widgets, there are two main modes: Desktop and Mobile. Desktop is used for monitors, portable computers, and tablets, while Mobile is used for mobile devices. When a mobile device is detected, Calendar switches to special full-screen templates that are optimized for both portrait and landscape orientations.  
  
 
Switching between Desktop and Mobile mode is done automatically by default. You can also configure Genesys Widgets to switch between Desktop and Mobile mode manually.  
 
Switching between Desktop and Mobile mode is done automatically by default. You can also configure Genesys Widgets to switch between Desktop and Mobile mode manually.  
 
===Screenshots===
 
===Screenshots===
'''"Dark" Theme'''
+
'''Dark theme'''
<gallery>
+
 
Calendar_Mobile_Potrait_DarkMode_04032020.jpg|Mobile fullscreen view in portrait orientation
+
[[File:Calendar_Mobile_Potrait_DarkMode_04032020.jpg|150x150px|Mobile fullscreen view in portrait orientation|alt=Mobile full screen view in portrait orientation in Dark Mode]]
Calendar_Mobile_Landscape_DarkMode_04032020.jpg|Mobile fullscreen view in landscape orientation
+
[[File:Calendar_Mobile_Landscape_DarkMode_04032020.jpg|150x150px|Mobile fullscreen view in landscape orientation|alt=Mobile full screen view in landscape orientation in Dark Mode]]
</gallery>
+
 
 +
'''Light theme'''
  
'''"Light" Theme'''
+
[[File:Calendar_Mobile_Potrait_LightMode_04032020.jpg|150x150px|Mobile fullscreen view in portrait orientation|alt=Mobile full screen view in portrait orientation in Light Mode]]
<gallery>
+
[[File:Calendar_Mobile_Landscape_LightMode_04032020.jpg|150x150px|Mobile fullscreen view in landscape orientation|alt=Mobile full screen view in landscape orientation in Light Mode]]
Calendar_Mobile_Potrait_LightMode_04032020.jpg|Mobile fullscreen view in portrait orientation
 
Calendar_Mobile_Landscape_LightMode_04032020.jpg|Mobile fullscreen view in landscape orientation
 
</gallery>
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
Line 94: Line 100:
 
!{{!}}Required
 
!{{!}}Required
 
{{!}}-
 
{{!}}-
{{!}}{{!}}showAvailability
+
{{!}}{{!}}{{AnchorDiv|SA}}showAvailability
 
{{!}}{{!}}boolean
 
{{!}}{{!}}boolean
{{!}}{{!}}Enable or disable calendar to update the time slots based on the callback availability. The unavailable time slots are greyed out.
+
{{!}}{{!}}Enable or disable calendar to update the time slots based on the callback availability. The unavailable time slots are grayed out.
 
{{!}}{{!}}true
 
{{!}}{{!}}true
 
{{!}}{{!}}n/a
 
{{!}}{{!}}n/a
Line 118: Line 124:
 
{{!}}{{!}}n/a
 
{{!}}{{!}}n/a
 
{{!}}-
 
{{!}}-
{{!}}{{!}}calendarHours.interval
+
{{!}}{{!}}{{AnchorDiv|CHI}}calendarHours.interval
 
{{!}}{{!}}number
 
{{!}}{{!}}number
 
{{!}}{{!}}The time interval between each consecutive time slot displayed on calendar.
 
{{!}}{{!}}The time interval between each consecutive time slot displayed on calendar.
Line 124: Line 130:
 
{{!}}{{!}}n/a
 
{{!}}{{!}}n/a
 
{{!}}-
 
{{!}}-
{{!}}{{!}}calendarHours.allDay.openTime
+
{{!}}{{!}}{{AnchorDiv|CHADOT}}calendarHours.allDay.openTime
 
{{!}}{{!}}number
 
{{!}}{{!}}number
 
{{!}}{{!}}Opening time in 'HH:MM' 24 Hr format.
 
{{!}}{{!}}Opening time in 'HH:MM' 24 Hr format.
Line 130: Line 136:
 
{{!}}{{!}}n/a
 
{{!}}{{!}}n/a
 
{{!}}-
 
{{!}}-
{{!}}{{!}}calendarHours.allDay.closeTime
+
{{!}}{{!}}{{AnchorDiv|CHALCT}}calendarHours.allDay.closeTime
 
{{!}}{{!}}number
 
{{!}}{{!}}number
 
{{!}}{{!}}Closing time in 'HH:MM' 24 Hr format.
 
{{!}}{{!}}Closing time in 'HH:MM' 24 Hr format.
Line 141: Line 147:
 
|anchor=localize
 
|anchor=localize
 
|alignment=Vertical
 
|alignment=Vertical
|structuredtext={{NoteFormat|For information on how to set up localization, refer to the  {{Link-AnywhereElse|product=WID|version=Current|manual=Developer|topic=GWCInternat|display text=Localization Guide}}.|1}}
+
|structuredtext={{NoteFormat|For information on how to set up localization, refer to {{Link-AnywhereElse|product=WID|version=Current|manual=Developer|topic=GWCInternat|display text=Localize widgets and services}}.|1}}
 
===Usage===
 
===Usage===
 
You must use the '''calendar''' namespace when you're defining localization strings for the Calendar plugin in your i18n JSON file.
 
You must use the '''calendar''' namespace when you're defining localization strings for the Calendar plugin in your i18n JSON file.
Line 180: Line 186:
 
"CalendarClose": "Cancel",
 
"CalendarClose": "Cancel",
 
"AriaWindowTitle": "Calendar Window",
 
"AriaWindowTitle": "Calendar Window",
"AriaCalendarClose": "Cancel the Calendar and Go Back to the Callback Registration",
+
"AriaCalendarClose": "Cancel",
 
"AriaYouHaveChosen": "You have chosen",
 
"AriaYouHaveChosen": "You have chosen",
 
"AriaNoTimeSlotsFound": "No time slots found for selected date"
 
"AriaNoTimeSlotsFound": "No time slots found for selected date"
Line 188: Line 194:
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|sectionHeading=API Commands
+
|sectionHeading=API commands
 
|anchor=commands
 
|anchor=commands
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus.
 
|structuredtext=Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus.
  
{{NoteFormat|The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. Instead, see {{Link-SomewhereInThisManual|topic=GWCBusExtensions|anchor=top|display text=Widgets Extensions}} for more information about extending Genesys Widgets.|1}}
+
{{NoteFormat|The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. For more information about extending Genesys Widgets, see {{Link-AnywhereElse|product=WID|version=Current|manual=SDK|topic=GWCBusExtensions|display text=Genesys Widgets Extensions}}. |1}}
  
  
Line 338: Line 344:
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|sectionHeading=API Events
+
|sectionHeading=API events
 
|anchor=events
 
|anchor=events
 
|alignment=Vertical
 
|alignment=Vertical
 
|structuredtext=Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus.
 
|structuredtext=Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus.
  
{{NoteFormat|The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. Instead, see {{Link-SomewhereInThisManual|topic=GWCBusExtensions|anchor=top|display text=Widgets Extensions}} for more information about extending Genesys Widgets.|1}}
+
{{NoteFormat|The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. Instead, see {{Link-AnywhereElse|product=WID|version=Current|manual=SDK|topic=GWCBusExtensions|display text=Genesys Widgets Extensions}} for more information about extending Genesys Widgets.|1}}
  
  

Latest revision as of 12:33, January 17, 2022

This topic is part of the manual Widgets API Reference for version Current of Widgets.

Learn how to display a calendar, so your customers can choose when they want to be contacted.

Related documentation:

Overview

The Calendar UI plugin displays time slots for a selected day. The number of days to display—and the opening and closing times for a day—are configurable, as shown in the configuration section.

The Calendar UI displays a list of dates and times to choose from

Usage

Important
By default, the Calendar widget needs a UI container to display itself properly. For information about how to create and display a calendar, see the API events section.

How does the Calendar widget render time slots in local time zones?

  1. The Calendar widget uses the command showAvailability which calls CallbackService.availability with the start date. This start date is then converted into the ISO 8601 format, using UTC as the timezone by toISOString(), internally.
  2. The Callback service fetches the available time slots from the server.
  3. The Calendar gets the available time slots from CallbackService.availableSlots in the ISO 8601 format, using UTC as the timezone.
  4. Each and Every Time Slot is converted according to the user's local time zone internally through Date() and toTimeString() methods in the Calendar Plugin.

Customization

All the texts displayed by the Calendar Widget are fully localizable.

Namespace

The Calendar plugin has the following namespaces tied to each of the following types:

Type Namespace
Configuration calendar
i18n - Localization calendar
CXBus—API commands & API events Calendar
CSS .cx-calendar

Mobile support

Calendar supports both desktop and mobile devices. Like all Genesys Widgets, there are two main modes: Desktop and Mobile. Desktop is used for monitors, portable computers, and tablets, while Mobile is used for mobile devices. When a mobile device is detected, Calendar switches to special full-screen templates that are optimized for both portrait and landscape orientations.

Switching between Desktop and Mobile mode is done automatically by default. You can also configure Genesys Widgets to switch between Desktop and Mobile mode manually.

Screenshots

Dark theme

Mobile full screen view in portrait orientation in Dark Mode Mobile full screen view in landscape orientation in Dark Mode

Light theme

Mobile full screen view in portrait orientation in Light Mode Mobile full screen view in landscape orientation in Light Mode

Configuration

Description

Calendar shares the _genesys.widgets.calendar configuration namespace. It also has UI options.

Example

window._genesys.widgets.calendar = {

	showAvailability: true,
	numberOfDays: 5,
	hideUnavailableTimeSlots: false

	calendarHours: {

		interval: 10,
		allDay: {

			openTime: '09:00',
			closeTime: '23:59'
		}
	}
};

Options

Name Type Description Default Required

showAvailability

boolean Enable or disable calendar to update the time slots based on the callback availability. The unavailable time slots are grayed out. true n/a
numberOfDays number The number of days to display on calendar starting today. 5 n/a
timeFormat number/string This sets the time format for the timestamps in this widget. It can be 12 or 24. 12 n/a
hideUnavailableTimeSlots boolean Show hide the unavailable callback time slots. false n/a

calendarHours.interval

number The time interval between each consecutive time slot displayed on calendar. 15 n/a

calendarHours.allDay.openTime

number Opening time in 'HH:MM' 24 Hr format. 17:00 n/a

calendarHours.allDay.closeTime

number Closing time in 'HH:MM' 24 Hr format. 23:59 n/a

Localization

Important
For information on how to set up localization, refer to Localize widgets and services.

Usage

You must use the calendar namespace when you're defining localization strings for the Calendar plugin in your i18n JSON file.

The following example shows how to define new strings for the en (English) language. You can use any language codes you wish, as there isn't a standard format. When selecting the active language in your configuration, you must match one of the language codes defined in your i18n JSON file. Note that you must only define a language code once in your i18n JSON file. Inside each language object you must define new strings for each widget.

Example i18n JSON

{
	"en": {
		"calendar": {
			"CalendarDayLabels": [
				"Sunday",
				"Monday",
				"Tuesday",
				"Wednesday",
				"Thursday",
				"Friday",
				"Saturday"
			],
			"CalendarMonthLabels": [
				"Jan",
				"Feb",
				"Mar",
				"Apr",
				"May",
				"Jun",
				"Jul",
				"Aug",
				"Sept",
				"Oct",
				"Nov",
				"Dec"
			],
			"CalendarLabelToday": "Today",
			"CalendarLabelTomorrow": "Tomorrow",
			"CalendarTitle": "Schedule a Call",
			"CalendarOkButtonText": "Okay",
			"CalendarError": "Unable to fetch availability details.",
			"CalendarClose": "Cancel",
			"AriaWindowTitle": "Calendar Window",
			"AriaCalendarClose": "Cancel",
			"AriaYouHaveChosen": "You have chosen",
			"AriaNoTimeSlotsFound": "No time slots found for selected date"
		}
	}
}

API commands

Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus.

Important
The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. For more information about extending Genesys Widgets, see Genesys Widgets Extensions.


var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');

oMyPlugin.command('Calendar.reset');


configure

Internal use only. The main App plugin shares widget configuration settings using each widget’s configure command. The configure command can only be called once, at startup. If you call configure after startup, the results are unpredictable.


generate

Builds and generates the calendar. Subscribe to the generate events to get the generated calendar and display it where you would like to.


Example

oMyPlugin.command('Calendar.generate', {date: 'Mon Mar 20 2017 19:51:47 GMT-0700 (PDT)'}).done(function(e){

	// Calendar generated successfully

}).fail(function(e){

	// Calendar failed to generate
});


Options

Option Type Description
date Date string/object To pre-select the date and time on calendar.


Resolutions

Status When Returns
resolved When the calendar is successfully generated n/a
rejected When Invalid date is passed to calendar 'Invalid data'


showAvailability

Update the calendar time slots with the callback availability. This enables only those time slots that have the callback facility and disables the rest.


Example

oMyPlugin.command('Calendar.showAvailability', {date: '03/22/17'}).done(function(e){

	// Calendar showed availability successfully

}).fail(function(e){

	// Calendar failed to show availability
});


Options

Option Type Description
date Date string/object Update the available time slots in the Calendar plugin for the selected Date. Note that, after calling this command, the internal showAvailability value is set to true for this session and the Calendar only shows the available time slots when switching between other dates.


Resolutions

Status When Returns
resolved When time slots are successfully updated n/a
rejected When no date value is found to check the availability 'No date found to check availability'
rejected When invalid date value is found 'Invalid date'


reset

Resets the calendar with no pre-selected values.


Example

oMyPlugin.command('Calendar.reset').done(function(e){

	// Calendar reset successfully

}).fail(function(e){

	// Calendar failed to reset
});


Resolutions

Status When Returns
resolved When calendar is successfully reset n/a

API events

Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus.

Important
The global bus object is a debugging tool. When implementing Widgets on your own site, you must not use the global bus object to register your custom plugins. Instead, see Genesys Widgets Extensions for more information about extending Genesys Widgets.


var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');

oMyPlugin.subscribe('Calendar.ready', function(e){});


Name Description Data
ready Calendar is initialized and ready to accept commands. n/a
generated Calendar UI has been generated. Use this event to get the calendar UI and display where you would like to. { ndCalendar: <Generated HTML Calendar> }
selectedDateTime Date and time selected on calendar. { dayString: <The day selected on calendar>, dateString: <The date selected on calendar in DD MMM format>, timeString: <The time selected on calendar in HH:MM 12 Hr format>, date: <Entire Date in date string format>}
Comments or questions about this documentation? Contact us for support!