CASH-313 | refactor

This commit is contained in:
Scott Kiener 2025-05-19 15:24:41 -04:00
parent ff0b9fe1d1
commit ec18956856
9 changed files with 124 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -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: 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 * Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
* CSS is not copied in * CSS is not copied in
* First <script> tag loading in the file from the CDN 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 * Copy the entire contents of the second <script> tag inside the initializeSalesforceWebchatForDev
and the wrapper exported function `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) { var initESW = function (gslbBaseURL) {
let embedded_svc = window.embedded_svc;
embedded_svc.settings.displayHelpButton = true; //Or false embedded_svc.settings.displayHelpButton = true; //Or false
embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US' embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US'
//embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert) //embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert)
//embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline) //embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline)
//embedded_svc.settings.loadingText = ''; //(Defaults to Loading) //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) //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 // Settings for Chat
//embedded_svc.settings.directToButtonRouting = function(prechatFormData) { //embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
// Dynamically changes the button ID based on what the visitor enters in the pre-chat form. // 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.enabledFeatures = ["LiveAgent"];
embedded_svc.settings.entryFeature = "LiveAgent"; embedded_svc.settings.entryFeature = "LiveAgent";
setupCustomSettings(
modifyEmbeddedSvcCallback,
finishedLoadingCallback,
onWebchatOpenCallback,
onWebchatCloseCallback
);
embedded_svc.init( embedded_svc.init(
"https://safelite2--dev.sandbox.my.salesforce.com", "https://safelite2--dev.sandbox.my.salesforce.com",
"https://safelite2--dev.sandbox.my.salesforce-sites.com/chat", "https://safelite2--dev.sandbox.my.salesforce-sites.com/chat",

View file

@ -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: 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 * Only the javascript inside the second <script> tag in the provided salesforce code is copy pasted
* CSS is not copied in * CSS is not copied in
* First <script> tag loading in the file from the CDN 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 * Copy the entire contents of the second <script> tag inside the initializeSalesforceWebchatForDev
and the wrapper exported function `initializeSalesforceWebChatForProd` 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) { var initESW = function (gslbBaseURL) {
let embedded_svc = window.embedded_svc; let embedded_svc = window.embedded_svc;
embedded_svc.settings.displayHelpButton = true; //Or false embedded_svc.settings.displayHelpButton = true; //Or false
@ -31,6 +58,13 @@ export function initializeSalesforceWebchatForProd(embedded_svc) {
embedded_svc.settings.enabledFeatures = ["LiveAgent"]; embedded_svc.settings.enabledFeatures = ["LiveAgent"];
embedded_svc.settings.entryFeature = "LiveAgent"; embedded_svc.settings.entryFeature = "LiveAgent";
setupCustomSettings(
modifyEmbeddedSvcCallback,
finishedLoadingCallback,
onWebchatOpenCallback,
onWebchatCloseCallback
);
embedded_svc.init( embedded_svc.init(
"https://safelite2.my.salesforce.com", "https://safelite2.my.salesforce.com",
"https://safelite2.my.salesforce-sites.com/chat", "https://safelite2.my.salesforce-sites.com/chat",

View file

@ -1,12 +1,4 @@
/* eslint-disable */ /* 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( function setupCustomSettings(
modifyEmbeddedSvcCallback, modifyEmbeddedSvcCallback,
@ -20,6 +12,23 @@ function setupCustomSettings(
embedded_svc.addEventHandler("afterDestroy", onWebchatCloseCallback); 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( export function initializeSalesforceWebchatForQa(
modifyEmbeddedSvcCallback, modifyEmbeddedSvcCallback,
finishedLoadingCallback, finishedLoadingCallback,
@ -27,13 +36,7 @@ export function initializeSalesforceWebchatForQa(
onWebchatCloseCallback onWebchatCloseCallback
) { ) {
var initESW = function (gslbBaseURL) { var initESW = function (gslbBaseURL) {
setupCustomSettings( embedded_svc.settings.displayHelpButton = true; //Or false
modifyEmbeddedSvcCallback,
finishedLoadingCallback,
onWebchatOpenCallback,
onWebchatCloseCallback
);
embedded_svc.settings.displayHelpButton = false; //Or false
embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US' embedded_svc.settings.language = ""; //For example, enter 'en' or 'en-US'
//embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert) //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.enabledFeatures = ["LiveAgent"];
embedded_svc.settings.entryFeature = "LiveAgent"; embedded_svc.settings.entryFeature = "LiveAgent";
setupCustomSettings(
modifyEmbeddedSvcCallback,
finishedLoadingCallback,
onWebchatOpenCallback,
onWebchatCloseCallback
);
embedded_svc.init( embedded_svc.init(
"https://safelite2--safeliteua.sandbox.my.salesforce.com", "https://safelite2--safeliteua.sandbox.my.salesforce.com",
"https://safelite2--safeliteua.sandbox.my.salesforce-sites.com/chat", "https://safelite2--safeliteua.sandbox.my.salesforce-sites.com/chat",

View file

@ -39,11 +39,15 @@ export default {
initializeSalesforceWebchat() { initializeSalesforceWebchat() {
switch (applicationConfig.CURRENT_ENVIRONMENT) { switch (applicationConfig.CURRENT_ENVIRONMENT) {
case "Prod": case "Prod":
initializeSalesforceWebchatForProd(); initializeSalesforceWebchatForProd(
this.modifyEmbeddedSvcCallback,
this.finishedLoadingCallback,
this.onWebchatOpenCallback,
this.onWebchatCloseCallback
);
break; break;
case "QA": case "QA":
case "SysTest": case "SysTest":
case "Localhost":
initializeSalesforceWebchatForQa( initializeSalesforceWebchatForQa(
this.modifyEmbeddedSvcCallback, this.modifyEmbeddedSvcCallback,
this.finishedLoadingCallback, this.finishedLoadingCallback,
@ -52,17 +56,21 @@ export default {
); );
break; break;
case "Dev": case "Dev":
initializeSalesforceWebchatForDev(); case "Localhost":
initializeSalesforceWebchatForDev(
this.modifyEmbeddedSvcCallback,
this.finishedLoadingCallback,
this.onWebchatOpenCallback,
this.onWebchatCloseCallback
);
break; break;
} }
}, },
modifyEmbeddedSvcCallback() { modifyEmbeddedSvcCallback() {
window.embedded_svc.settings.avatarImgURL = window.embedded_svc.settings.avatarImgURL = require("@/assets/img/salesforce-webchat/avatar_webchat.png");
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/avatar_webchat.png"; window.embedded_svc.settings.prechatBackgroundImgURL = require("@/assets/img/salesforce-webchat/safelite_logo_webchat.png");
window.embedded_svc.settings.prechatBackgroundImgURL = window.embedded_svc.settings.smallCompanyLogoImgURL = require("@/assets/img/salesforce-webchat/minimized_chat_bubble_webchat.png");
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite_logo_webchat.png"; window.embedded_svc.settings.displayHelpButton = false;
window.embedded_svc.settings.smallCompanyLogoImgURL =
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/minimized_chat_bubble_webchat";
}, },
finishedLoadingCallback(data) { finishedLoadingCallback(data) {
this.isAgentAvailable = data.isAgentAvailable; this.isAgentAvailable = data.isAgentAvailable;
@ -79,12 +87,11 @@ export default {
this.updateShouldShowWebchatButton(); this.updateShouldShowWebchatButton();
}, },
updateShouldShowWebchatButton() { updateShouldShowWebchatButton() {
this.webchatGlobalNonpersistedState.showWebchatButton = ( this.webchatGlobalNonpersistedState.showWebchatButton =
!this.hideSalesforceWebchatLaunchButton && !this.hideSalesforceWebchatLaunchButton &&
this.isAgentAvailable && this.isAgentAvailable &&
!this.isWebchatOpen !this.isWebchatOpen;
); },
}
}, },
computed: {}, computed: {},
components: {}, components: {},

View file

@ -70,8 +70,11 @@ export default {
return this.getCmsContent(this.cmsWidgetName, "LogoImage"); return this.getCmsContent(this.cmsWidgetName, "LogoImage");
}, },
shouldShowWebchatButton() { shouldShowWebchatButton() {
return !this.shouldHideWebchatButtonOnPage && this.webchatGlobalNonpersistedState.showWebchatButton; return (
} !this.shouldHideWebchatButtonOnPage &&
this.webchatGlobalNonpersistedState.showWebchatButton
);
},
}, },
methods: { methods: {
pushGlobalAlert(alertToPush, isAutoDismissing) { pushGlobalAlert(alertToPush, isAutoDismissing) {

View file

@ -7,7 +7,6 @@ const webchatGlobalNonpersistedState = reactive({
}); });
export const webchatHelper = () => { export const webchatHelper = () => {
function launchWebchat() { function launchWebchat() {
if (webchatGlobalNonpersistedState.shouldLaunchSierra) { if (webchatGlobalNonpersistedState.shouldLaunchSierra) {
// do sierra logic here // do sierra logic here