define(["js/api-impl/api-agent-impl"], function(impl) {
var exports = impl.namespace("NM.api.imail.agent");
exports.sidebar = {
/** This function expands the sidebar in the novomind iAGENT Desk.
*
* @return true if the sidebar is available and expanded, otherwise false
* @function expand
*/
expand : function() {
return impl.sidebar.expand();
},
/** This function collapses the sidebar in the novomind iAGENT Desk.
*
* @return true if the sidebar is available and collapsed, otherwise false
* @function collapse
*/
collapse : function() {
return impl.sidebar.collapse();
},
/** This function determines if the sidebar is currently expanded.
*
* @return true if the sidebar is currently expanded, otherwise false
* @function isExpanded
*/
isExpanded : function() {
return impl.sidebar.isExpanded();
},
/** This function determines if the sidebar is available on the current agent session.
*
* @return true if the sidebar is available, otherwise false
* @function isAvailable
*/
isAvailable : function() {
return _top().isSidebarAvailable();
}
};
exports.toolbar = {
/** This function opens the QuickCase editor and starts
* a new process with the given optional parameters.
* if there are no options provided the default options
* to create a new ticket will be used.
* The default options can be configured in the 'Routing.conf'
* configuration file by the key 'agent.newProcess.quickCase.defaultParams'
*
* @param options {object}
* object containing the following optional keys:
* <pre>
* customer : customer email address
* cc : cc address list for the ticket separated by '|'
* bcc : bcc address list for the ticket separated by '|'
* category : category name of ticket
* template : template to be used for answer proposal
* account : username or id of account to be used to process the ticket
* accountAddress : email address of account to be used to process the ticket - this is an alternative to identify the account by username or id
* refID : refID to be applied to the ticket
* subject : subject of the ticket
* language : language code of the ticket
* channel : channel of the ticket - allowed values are 1 (email), 2 (letter), 3 (fax)
* cause : cause of ticket creation - allowed values are 1 (default - new process), 4 (phone ticket / call channel), 6 (generic work item), 7 (web form), 9 (invisible), 10 (API)
* contactID : the id of the contact to be assigned to the ticket
* processID : the process id of the process where the ticket should be assigned to
* crm_* : for each parameter of type crm_<key> an email property will be created for the ticket
* </pre>
* @function startNewProcess
*/
startNewProcess : function(options) {
return impl.toolbar.startNewProcess(options);
},
/** This function adds a new custom tab to the sub tab bar
* which will be displayed together with QuickCases in the
* same tab bar.
* @param name {string} name of the new custom tab
* @param url {string} name of the url
* @param autoSwitch {boolean} activated if true
* @function addTab
*/
addTab : function(name, url, autoSwitch) {
return impl.toolbar.addTab(name, url, autoSwitch);
}
};
exports.mail = {
/** This function enables or disables the fullscreen
* mode of the mail editor view
* @param enable {boolean} activated if true
* @function setFullscreen
*/
setFullscreen : function(enable) {
return impl.mail.setFullscreen(enable);
},
/** This function allows to change the current template
* for the mail editor view. If there are unsaved changes
* a dialog window will appear and ask for a confirmation.
* @param templateName {string} name of the template
* @function changeTemplate
*/
changeTemplate : function(templateName) {
return impl.mail.changeTemplate(templateName);
},
/** This function will reload the currently selected template
* for the mail editor view. A reload of the current template
* will force a refresh of all template variables used in the template.
* If there are unsaved changes a dialog window will appear and ask for a confirmation.
* @function reloadTemplate
*/
reloadTemplate : function() {
return impl.mail.reloadTemplate();
},
/** This function triggers the internal recategorize operation
* on the currently selected ticket.
* After a successful recategorize operation the ticket may
* be removed from the agent's folder.
*
* @param category {string}
* the name of the new category for the ticket
*
* @param options {object}
* object containing the following optional keys:
*
* keep : if true the ticket will not be removed from the agent's
* folder after the successful recategorize operation
* @function recategorize
*/
recategorize : function(category, options) {
return impl.mail.recategorize(category, options);
},
/** This function has the same effect like clicking the button
* 'Close' on a ticket in the mail editor view.
* @function close
*/
close : function() {
return impl.mail.close();
},
/** This function triggers an internal forward operation on the
* currently selected ticket.
* The ticket can either be forwarded internally to another agent
* or to an agent group, if the configuration allows group forwarding.
*
* @param agentOrGroup {string}
* the username of the agent or the name of the agent group to
* be used as target for the internal forward operation
*
* @param dueDate {date}
* the due date for the internal forward operation as UTC timestamp
* or formatted date string with the pattern 'yyyy-MM-dd hh:mm:ss'
* (using the local timezone of the client)
* @function internalForward
*/
internalForward : function(agentOrGroup, dueDate) {
return impl.mail.internalForward(agentOrGroup, dueDate);
},
/** This function adds an attachment to the currently
* selected message.
* By calling this function the attachment will only be linked
* to the message.
* Please ensure having installed an AttachmentDataSourceProvider
* that implements the specified scheme and provides the binary
* attachment input stream, if requested.
* The uid and the scheme together have to be globally unique.
* The uid must contain only the following characters:
* [a-z][A-Z][0-9].-_
* The maximum number of characters of the uid is 255.
* The scheme must contain only lower case characters and digits [a-z][0-9]
* The maximum length of the scheme is 8 characters or digits.
* @param scheme {string} scheme with a maximum length of 8 characters or digits
* @param uid {string} uid
* @param name {string} name of the attachment
* @function addAttachment
*/
addAttachment : function(scheme, uid, name) {
return impl.mail.addAttachment(scheme, uid, name);
},
/** This function removes an external attachment from the currently
* selected message.
* @function removeAttachment
* @param scheme {string} scheme with a maximum length of 8 characters or digits
* @param uid {string} uid
*/
removeAttachment : function(scheme, uid) {
return impl.mail.removeAttachment(scheme, uid);
},
/** This function provides the currently assigned primary to-address
* of the ticket, used as recipient address to answer the currently
* selected message.
*
* @return
* the currently assigned primary to-address of the ticket or
* null if no message is currently selected.
* @function getPrimaryToAddress
*/
getPrimaryToAddress : function() {
return impl.mail.getPrimaryToAddress();
},
/** This function changes the primary to-address of the ticket,
* used as recipient address to answer the currently selected message.
* The primary to-address of the ticket is also used to identify
* the contact of the ticket.
*
* When the primary to-address is changed, the contact assignment
* of the ticket may also change.
* If the new to-address is not associated with an existing contact
* then a new contact will be created and assigned to the ticket.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param newAddress {string}
* the new address to be set for the currently selected ticket.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function setPrimaryToAddress
*/
setPrimaryToAddress : function(newAddress) {
return impl.mail.setPrimaryToAddress(newAddress);
},
/** This function provides the list of assigned additional
* to-addresses of the currently selected message.
*
* @return
* the list of assigned additional to-addresses as array
* of strings or null if no message is currently selected.
* @function getAdditionalToAddresses
*/
getAdditionalToAddresses : function() {
return impl.mail.getAdditionalToAddresses();
},
/** This function adds additional to-addresses to the currently selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param additionalToAddresses {string[]}
* the additional addresses to be added for the currently selected ticket
* as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function addAdditionalToAddresses
*/
addAdditionalToAddresses : function(additionalToAddresses) {
return impl.mail.addAdditionalToAddresses(additionalToAddresses);
},
/** This function removes additional to-addresses from the currently
* selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param additionalToAddressesToBeRemoved {string[]}
* the additional addresses to be removed from the currently selected
* message as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function removeAdditionalToAddresses
*/
removeAdditionalToAddresses : function(additionalToAddressesToBeRemoved) {
return impl.mail.removeAdditionalToAddresses(additionalToAddressesToBeRemoved);
},
/** This function provides the list of assigned
* cc-addresses of the currently selected message.
*
* @return
* the list of assigned cc-addresses as array
* of strings or null if no message is currently selected.
* @function getCcAddresses
*/
getCcAddresses : function() {
return impl.mail.getCcAddresses();
},
/** This function adds cc-addresses to the currently selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param ccAddresses {string[]}
* the cc-addresses to be added for the currently selected ticket
* as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function addCcAddresses
*/
addCcAddresses : function(ccAddresses) {
return impl.mail.addCcAddresses(ccAddresses);
},
/** This function removes cc-addresses from the currently
* selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param ccAddressesToBeRemoved {string[]}
* the cc-addresses to be removed from the currently selected
* message as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function removeCcAddresses
*/
removeCcAddresses : function(ccAddressesToBeRemoved) {
return impl.mail.removeCcAddresses(ccAddressesToBeRemoved);
},
/** This function provides the list of assigned
* bcc-addresses of the currently selected message.
*
* @return
* the list of assigned bcc-addresses as array
* of strings or null if no message is currently selected.
* @function getBccAddresses
*/
getBccAddresses : function() {
return impl.mail.getBccAddresses();
},
/** This function adds bcc-addresses to the currently selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param bccAddresses {string[]}
* the bcc-addresses to be added for the currently selected ticket
* as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function addBccAddresses
*/
addBccAddresses : function(bccAddresses) {
return impl.mail.addBccAddresses(bccAddresses);
},
/** This function removes bcc-addresses from the currently
* selected message.
*
* Please note that the operation is executed asynchronously and the
* changes will take effect a short time after the method returns.
*
* @param bccAddressesToBeRemoved {string[]}
* the bcc-addresses to be removed from the currently selected
* message as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message,
* otherwise true if the operation is being executed.
* @function removeBccAddresses
*/
removeBccAddresses : function(bccAddressesToBeRemoved) {
return impl.mail.removeBccAddresses(bccAddressesToBeRemoved);
},
/** This function provides the currently assigned primary forward address
* of the currently selected message.
*
* @return
* the currently assigned primary forward address of the message to
* be externally forwarded or null if no message is currently selected
* or the agent editor is currently not switched to external forward mode.
* @function getPrimaryForwardAddress
*/
getPrimaryForwardAddress : function() {
return impl.mail.getPrimaryForwardAddress();
},
/** This function changes the primary forward address of the currently
* selected message for the external forward or inquiry operation.
* The function can only be called while the agent editor is switched
* to external forward mode.
*
* @param newAddress {string}
* the new primary forward address to be set for the currently selected message.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message or
* if the agent editor currently is not switched to forward mode,
* otherwise true.
* @function setPrimaryForwardAddress
*/
setPrimaryForwardAddress : function(newAddress) {
return impl.mail.setPrimaryForwardAddress(newAddress);
},
/** This function provides the list of assigned additional
* forward addresses of the currently selected message.
*
* @return
* the list of currently assigned additional forward addresses of the
* message as array of strings or null if no message is currently selected
* or the agent editor is currently not switched to forward mode.
* @function getAdditionalForwardAddresses
*/
getAdditionalForwardAddresses : function() {
return impl.mail.getAdditionalForwardAddresses();
},
/** This function adds additional forward addresses to the currently
* selected message for the external forward or inquiry operation.
* The function can only be called while the agent editor is switched
* to external forward mode.
*
* @param additionalToAddresses {string[]}
* the additional addresses to be added for the currently selected
* message to be externally forwarded as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message or
* if the agent editor currently is not switched to forward mode,
* otherwise true.
* @function addAdditionalToAddresses
*/
addAdditionalForwardAddresses : function(additionalForwardAddresses) {
return impl.mail.addAdditionalForwardAddresses(additionalForwardAddresses);
},
/** This function removes additional forward addresses from the currently
* selected message for the external forward or inquiry operation.
* The function can only be called while the agent editor is switched
* to external forward mode.
*
* @param additionalForwardAddressesToBeRemoved {string[]}
* the additional addresses to be removed from the currently selected
* message to be externally forwarded as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message or
* if the agent editor currently is not switched to forward mode,
* otherwise true.
* @function removeAdditionalForwardAddresses
*/
removeAdditionalForwardAddresses : function(additionalForwardAddressesToBeRemoved) {
return impl.mail.removeAdditionalForwardAddresses(additionalForwardAddressesToBeRemoved);
},
/** This function provides the list of assigned cc-addresses of the
* currently selected message for the external forward or inquiry operation.
*
* @return
* the list of currently assigned cc-addresses of the message
* to be forwarded as array of strings or null if no message is currently
* selected or the agent editor is currently not switched to forward mode.
* @function getForwardCcAddresses
*/
getForwardCcAddresses : function() {
return impl.mail.getForwardCcAddresses();
},
/** This function adds cc-addresses to the currently
* selected message for the external forward or inquiry operation.
* The function can only be called while the agent editor is switched
* to external forward mode.
*
* @param forwardCcAddresses {string[]}
* the cc-addresses to be added for the currently selected
* message to be externally forwarded as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message or
* if the agent editor currently is not switched to forward mode,
* otherwise true.
* @function addForwardCcAddresses
*/
addForwardCcAddresses : function(forwardCcAddresses) {
return impl.mail.addForwardCcAddresses(forwardCcAddresses);
},
/** This function removes cc-addresses from the currently
* selected message for the external forward or inquiry operation.
* The function can only be called while the agent editor is switched
* to external forward mode.
*
* @param forwardCcAddressesToBeRemoved {string[]}
* the additional addresses to be removed from the currently selected
* message to be externally forwarded as array of strings.
*
* @return
* false if no message is currently selected or if the operation
* cannot be performed for the currently selected message or
* if the agent editor currently is not switched to forward mode,
* otherwise true.
* @function removeForwardCcAddresses
*/
removeForwardCcAddresses : function(forwardCcAddressesToBeRemoved) {
return impl.mail.removeForwardCcAddresses(forwardCcAddressesToBeRemoved);
},
editor : {
/** This function inserts plain text at the current cursor position
* into the mail agent editor content area.
* Please note that insert operations of huge text content may cause
* browser freeze or crash depending on the client environment and
* browser type.
* The text must be plain text, that will be auto converted to the
* required format, given by the currently selected template (txt, html, pdf)
* If the select parameter is true, the inserted text will be selected
* automatically after the insert operation.
* @function insertText
*/
insertText : function(text, select) {
return impl.mail.editor.insertText(text, select);
},
/** This function inserts html text at the current cursor position
* into the mail agent editor content area.
* The html code passed to the function must be valid html without
* the following tags: doctype, html, head, style, body, script
* Please note that insert operations of huge html content may cause
* browser freeze or crash depending on the client environment and
* browser type.
* The content will be auto converted to the required format, given
* by the currently selected template (txt, html, pdf)
* If the select parameter is true, the inserted text will be selected
* automatically after the insert operation.
* @function insertHtml
*/
insertHtml : function(html, select) {
return impl.mail.editor.insertHtml(html, select);
},
/** This function switches the mail agent editor to the external inquiry mode
* or opens the external inquiry dialog according to parameter property
* 'options.forceDialog' and key 'externalForward.dialog.legacy' in Routing.conf.
*
* @param options {object}
* object containing the following property:
* <pre>
* forceDialog : external inquiry editor or external inquiry dialog
* </pre>
* @return
* false if the external inquiry option isn't available in the mail agent editor,
* otherwise switches the mail agent editor to the external inquiry mode or opens
* the external inquiry dialog.
* <pre>
* options.forceDialog = false & externalForward.dialog.legacy = false --> switches editor
* options.forceDialog = false & externalForward.dialog.legacy = true --> opens dialog
* options.forceDialog = true & externalForward.dialog.legacy = false --> opens dialog
* options.forceDialog = true & externalForward.dialog.legacy = true --> opens dialog
* </pre>
* @function externalInquiry
*/
externalInquiry : function(options) {
return impl.mail.editor.externalInquiry(options);
}
}
};
exports.shortcut = {
/** With this function you are able to register a global shortcut in the agent UI.
* The callback function will be executed each time an agent uses the defined shortcut.
* You need to register the shortcut each time the page is (re)loaded,
* since the shortcut will be automatically unregistered upon page unload.
*
* @param shortcut {string[]}
* Shortcuts are currently restricted to a key combination of 'ctrl+shift+<digit>'.
* Example: 'ctrl+shift+1' For the digit, select only 1 - 9.
*
* @param callbackFunction {function}
* The function which will be called when using the shortcut, presupposed the
* frame is visible, in which the function is implemented.
* @function registerShortcut
*/
registerShortcut : function(shortcut, callbackFunction) {
return impl.shortcut.registerShortcut(shortcut, callbackFunction);
}
};
return exports;
});