CASH-313 | refactor
This commit is contained in:
parent
ff0b9fe1d1
commit
ec18956856
9 changed files with 124 additions and 41 deletions
BIN
src/assets/img/salesforce-webchat/avatar_webchat.png
Normal file
BIN
src/assets/img/salesforce-webchat/avatar_webchat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 503 B |
Binary file not shown.
|
After Width: | Height: | Size: 622 B |
BIN
src/assets/img/salesforce-webchat/safelite_logo_webchat.png
Normal file
BIN
src/assets/img/salesforce-webchat/safelite_logo_webchat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 KiB |
|
|
@ -1,24 +1,47 @@
|
|||
/* eslint-disable */
|
||||
|
||||
function setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
) {
|
||||
modifyEmbeddedSvcCallback();
|
||||
embedded_svc.addEventHandler("onSettingsCallCompleted", finishedLoadingCallback);
|
||||
embedded_svc.addEventHandler("afterMaximize", onWebchatOpenCallback);
|
||||
embedded_svc.addEventHandler("afterDestroy", onWebchatCloseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
The code below is generated from salesforce but modified in the following ways:
|
||||
* Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
|
||||
* CSS is not copied in
|
||||
* First <script> tag loading in the file from the CDN is not copied in
|
||||
* The only custom code added here is `let embedded_svc = window.embedded_svc` in the first line of the `initESW` function
|
||||
and the wrapper exported function `initializeSalesforceWebChatForDev`
|
||||
* Copy the entire contents of the second <script> tag inside the initializeSalesforceWebchatForDev
|
||||
method and add a call to setupCustomSettings before the 'embedded_svc.init()' method is called
|
||||
|
||||
Actual call to paste in:
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
*/
|
||||
|
||||
export function initializeSalesforceWebchatForDev() {
|
||||
export function initializeSalesforceWebchatForDev(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
) {
|
||||
var initESW = function (gslbBaseURL) {
|
||||
let embedded_svc = window.embedded_svc;
|
||||
embedded_svc.settings.displayHelpButton = true; //Or false
|
||||
embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US'
|
||||
|
||||
//embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert)
|
||||
//embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline)
|
||||
|
||||
//embedded_svc.settings.loadingText = ''; //(Defaults to Loading)
|
||||
//embedded_svc.settings.storageDomain = 'yourdomain.com'; //(Sets the domain for your deployment so that visitors can navigate subdomains during a chat session)
|
||||
|
||||
// Settings for Chat
|
||||
//embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
|
||||
// Dynamically changes the button ID based on what the visitor enters in the pre-chat form.
|
||||
|
|
@ -31,6 +54,13 @@ export function initializeSalesforceWebchatForDev() {
|
|||
embedded_svc.settings.enabledFeatures = ["LiveAgent"];
|
||||
embedded_svc.settings.entryFeature = "LiveAgent";
|
||||
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
|
||||
embedded_svc.init(
|
||||
"https://safelite2--dev.sandbox.my.salesforce.com",
|
||||
"https://safelite2--dev.sandbox.my.salesforce-sites.com/chat",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,40 @@
|
|||
/* eslint-disable */
|
||||
|
||||
function setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
) {
|
||||
modifyEmbeddedSvcCallback();
|
||||
embedded_svc.addEventHandler("onSettingsCallCompleted", finishedLoadingCallback);
|
||||
embedded_svc.addEventHandler("afterMaximize", onWebchatOpenCallback);
|
||||
embedded_svc.addEventHandler("afterDestroy", onWebchatCloseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
The code below is generated from salesforce but modified in the following ways:
|
||||
* Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
|
||||
* CSS is not copied in
|
||||
* First <script> tag loading in the file from the CDN is not copied in
|
||||
* The only custom code added here is `let embedded_svc = window.embedded_svc` in the first line of the `initESW` function
|
||||
and the wrapper exported function `initializeSalesforceWebChatForProd`
|
||||
* Copy the entire contents of the second <script> tag inside the initializeSalesforceWebchatForDev
|
||||
method and add a call to setupCustomSettings before the 'embedded_svc.init()' method is called
|
||||
|
||||
Actual call to paste in:
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
*/
|
||||
|
||||
export function initializeSalesforceWebchatForProd(embedded_svc) {
|
||||
export function initializeSalesforceWebchatForProd(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
) {
|
||||
var initESW = function (gslbBaseURL) {
|
||||
let embedded_svc = window.embedded_svc;
|
||||
embedded_svc.settings.displayHelpButton = true; //Or false
|
||||
|
|
@ -31,6 +58,13 @@ export function initializeSalesforceWebchatForProd(embedded_svc) {
|
|||
embedded_svc.settings.enabledFeatures = ["LiveAgent"];
|
||||
embedded_svc.settings.entryFeature = "LiveAgent";
|
||||
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
|
||||
embedded_svc.init(
|
||||
"https://safelite2.my.salesforce.com",
|
||||
"https://safelite2.my.salesforce-sites.com/chat",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,4 @@
|
|||
/* eslint-disable */
|
||||
/*
|
||||
The code below is generated from salesforce but modified in the following ways:
|
||||
* Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
|
||||
* CSS is not copied in
|
||||
* First <script> tag loading in the file from the CDN is not copied in
|
||||
* The only custom code added here is `let embedded_svc = window.embedded_svc` in the first line of the `initESW` function
|
||||
and the wrapper exported function `initializeSalesforceWebChatForQa`
|
||||
*/
|
||||
|
||||
function setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
|
|
@ -20,6 +12,23 @@ function setupCustomSettings(
|
|||
embedded_svc.addEventHandler("afterDestroy", onWebchatCloseCallback);
|
||||
}
|
||||
|
||||
/*
|
||||
The code below is generated from salesforce but modified in the following ways:
|
||||
* Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
|
||||
* CSS is not copied in
|
||||
* First <script> tag loading in the file from the CDN is not copied in
|
||||
* Copy the entire contents of the second <script> tag inside the initializeSalesforceWebchatForQa
|
||||
method and add a call to setupCustomSettings before the 'embedded_svc.init()' method is called
|
||||
|
||||
Actual call to paste in:
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
*/
|
||||
|
||||
export function initializeSalesforceWebchatForQa(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
|
|
@ -27,13 +36,7 @@ export function initializeSalesforceWebchatForQa(
|
|||
onWebchatCloseCallback
|
||||
) {
|
||||
var initESW = function (gslbBaseURL) {
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
embedded_svc.settings.displayHelpButton = false; //Or false
|
||||
embedded_svc.settings.displayHelpButton = true; //Or false
|
||||
embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US'
|
||||
|
||||
//embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert)
|
||||
|
|
@ -54,6 +57,13 @@ export function initializeSalesforceWebchatForQa(
|
|||
embedded_svc.settings.enabledFeatures = ["LiveAgent"];
|
||||
embedded_svc.settings.entryFeature = "LiveAgent";
|
||||
|
||||
setupCustomSettings(
|
||||
modifyEmbeddedSvcCallback,
|
||||
finishedLoadingCallback,
|
||||
onWebchatOpenCallback,
|
||||
onWebchatCloseCallback
|
||||
);
|
||||
|
||||
embedded_svc.init(
|
||||
"https://safelite2--safeliteua.sandbox.my.salesforce.com",
|
||||
"https://safelite2--safeliteua.sandbox.my.salesforce-sites.com/chat",
|
||||
|
|
|
|||
|
|
@ -39,11 +39,15 @@ export default {
|
|||
initializeSalesforceWebchat() {
|
||||
switch (applicationConfig.CURRENT_ENVIRONMENT) {
|
||||
case "Prod":
|
||||
initializeSalesforceWebchatForProd();
|
||||
initializeSalesforceWebchatForProd(
|
||||
this.modifyEmbeddedSvcCallback,
|
||||
this.finishedLoadingCallback,
|
||||
this.onWebchatOpenCallback,
|
||||
this.onWebchatCloseCallback
|
||||
);
|
||||
break;
|
||||
case "QA":
|
||||
case "SysTest":
|
||||
case "Localhost":
|
||||
initializeSalesforceWebchatForQa(
|
||||
this.modifyEmbeddedSvcCallback,
|
||||
this.finishedLoadingCallback,
|
||||
|
|
@ -52,17 +56,21 @@ export default {
|
|||
);
|
||||
break;
|
||||
case "Dev":
|
||||
initializeSalesforceWebchatForDev();
|
||||
case "Localhost":
|
||||
initializeSalesforceWebchatForDev(
|
||||
this.modifyEmbeddedSvcCallback,
|
||||
this.finishedLoadingCallback,
|
||||
this.onWebchatOpenCallback,
|
||||
this.onWebchatCloseCallback
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
modifyEmbeddedSvcCallback() {
|
||||
window.embedded_svc.settings.avatarImgURL =
|
||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/avatar_webchat.png";
|
||||
window.embedded_svc.settings.prechatBackgroundImgURL =
|
||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite_logo_webchat.png";
|
||||
window.embedded_svc.settings.smallCompanyLogoImgURL =
|
||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/minimized_chat_bubble_webchat";
|
||||
window.embedded_svc.settings.avatarImgURL = require("@/assets/img/salesforce-webchat/avatar_webchat.png");
|
||||
window.embedded_svc.settings.prechatBackgroundImgURL = require("@/assets/img/salesforce-webchat/safelite_logo_webchat.png");
|
||||
window.embedded_svc.settings.smallCompanyLogoImgURL = require("@/assets/img/salesforce-webchat/minimized_chat_bubble_webchat.png");
|
||||
window.embedded_svc.settings.displayHelpButton = false;
|
||||
},
|
||||
finishedLoadingCallback(data) {
|
||||
this.isAgentAvailable = data.isAgentAvailable;
|
||||
|
|
@ -79,12 +87,11 @@ export default {
|
|||
this.updateShouldShowWebchatButton();
|
||||
},
|
||||
updateShouldShowWebchatButton() {
|
||||
this.webchatGlobalNonpersistedState.showWebchatButton = (
|
||||
this.webchatGlobalNonpersistedState.showWebchatButton =
|
||||
!this.hideSalesforceWebchatLaunchButton &&
|
||||
this.isAgentAvailable &&
|
||||
!this.isWebchatOpen
|
||||
);
|
||||
}
|
||||
!this.isWebchatOpen;
|
||||
},
|
||||
},
|
||||
computed: {},
|
||||
components: {},
|
||||
|
|
|
|||
|
|
@ -70,8 +70,11 @@ export default {
|
|||
return this.getCmsContent(this.cmsWidgetName, "LogoImage");
|
||||
},
|
||||
shouldShowWebchatButton() {
|
||||
return !this.shouldHideWebchatButtonOnPage && this.webchatGlobalNonpersistedState.showWebchatButton;
|
||||
}
|
||||
return (
|
||||
!this.shouldHideWebchatButtonOnPage &&
|
||||
this.webchatGlobalNonpersistedState.showWebchatButton
|
||||
);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
pushGlobalAlert(alertToPush, isAutoDismissing) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ const webchatGlobalNonpersistedState = reactive({
|
|||
});
|
||||
|
||||
export const webchatHelper = () => {
|
||||
|
||||
function launchWebchat() {
|
||||
if (webchatGlobalNonpersistedState.shouldLaunchSierra) {
|
||||
// do sierra logic here
|
||||
|
|
|
|||
Loading…
Reference in a new issue