Professional Documents
Culture Documents
.module('ff4e89d6-e846-4cbf-90ac-1bb715447a26', ['core.services.WidgetAPI'])
.directive('journeyElements', widgetComponent);
var INTERACTION_TYPES = {
VOICE: 'voice',
SMS: 'sms',
EMAIL: 'email'
};
var API_PROTOCOLS = {
HTTP: 'http://',
HTTPS: 'https://'
};
setCustomerManagementFQDN();
$http(requestConfig)
.then(function successCallback(response) {
isJourneyEmpty = false
scope.saveBtnText = 'Save';
api.sendMessage(UPDATE_MESSAGE);
api.sendNotification('info', 'Widget: ' + ' Customer Journey details
saved');
}, function errorCallback(response) {
scope.saveBtnText = 'Save';
api.sendNotification('warning', 'Widget: ' + ' Customer Journey details
failed to update');
console.error('updateJourneyElement error: ' + JSON.stringify(response,
null, 2));
});
};
/**
* Adds additional key/value pairs to additionalInfo collection
* Prevents adding duplicate keys to additionalInfo collection
*/
scope.addOtherInformation = function (additionalKey, additionalValue) {
/**
* Remove selected table row
*/
scope.removeTableRow = function (idx) {
scope.additionalInfo.splice(idx, 1);
};
/**
* Checks Configuration settings for a valid
* customerManagementFQDN domain.
*/
function setCustomerManagementFQDN() {
var message = 'Invalid Context Store settings: ';
var configObject = api.getConfiguration();
if (!_.isUndefined(configObject.settings.customerManagementFQDN)) {
var customerManagementFQDN = configObject.settings.customerManagementFQDN;
baseCustomerManagementUrl = API_PROTOCOLS.HTTPS + customerManagementFQDN +
'/services/CustomerManagement/rest/customers';
} else {
console.error(message + ' customerManagementFQDN is not valid. ' + '
customerManagementFQDN: ' + configObject.settings.customerManagementFQDN);
}
}
/**
* This event is triggered when customer and context data is available in
* Chat, SMS, Email and Social work cards. This event can be used to obtain
* customer details and customer history data from Chat, SMS, Email and
* Social interactions.
*/
api.onDataEvent('onContextDataEvent', function (data) {
if (data.customerDetails[0]) {
scope.customerEmail = data.customerDetails[0].data.email;
}
});
/**
* This event is triggered when a new work card (interaction) appears in
* Workspaces. This event is triggered in the background when the work
* card is in the ALERTING state and it is called at least once per incoming
* interaction.
* */
api.onDataEvent('onInteractionEvent', function (data) {
if (data.workRequestId) {
workRequestId = data.workRequestId;
}
});
/**
* This event is triggered when other widgets broadcast a data message by using
the sendMessage() API method.
* This event is used primarily for inter-widget communication.
*/
api.onDataEvent('onMessageEvent', function (data) {
var message = data;
if (message === REJECTED_MESSAGE) {
isJourneyEmpty = true;
} else if (message === RESOLVED_MESSAGE) {
isJourneyEmpty = false;
}
});
return {
scope: {},
replace: true,
template: template,
link: widgetContainer
};
}