Chore: Add web_widget_script in the Inboxes API (#615)
* Chore: Add web_widget_script in the Inboxes API
This commit is contained in:
@@ -1,20 +1,3 @@
|
||||
export const createWebsiteWidgetScript = websiteToken => `
|
||||
<script>
|
||||
(function(d,t) {
|
||||
var BASE_URL = '${window.location.origin}';
|
||||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src= BASE_URL + "/packs/js/sdk.js";
|
||||
s.parentNode.insertBefore(g,s);
|
||||
g.onload=function(){
|
||||
window.chatwootSDK.run({
|
||||
websiteToken: '${websiteToken}',
|
||||
baseUrl: BASE_URL
|
||||
})
|
||||
}
|
||||
})(document,"script");
|
||||
</script>
|
||||
`;
|
||||
|
||||
export const createMessengerScript = pageId => `
|
||||
<script>
|
||||
window.fbAsyncInit = function() {
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
>
|
||||
<div class="medium-12 columns text-center">
|
||||
<div class="website--code">
|
||||
<woot-code v-if="currentInbox.website_token" :script="websiteScript">
|
||||
<woot-code
|
||||
v-if="currentInbox.website_token"
|
||||
:script="currentInbox.web_widget_script"
|
||||
>
|
||||
</woot-code>
|
||||
</div>
|
||||
<router-link
|
||||
@@ -25,7 +28,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createWebsiteWidgetScript } from 'dashboard/helper/scriptGenerator';
|
||||
import EmptyState from '../../../../components/widgets/EmptyState';
|
||||
|
||||
export default {
|
||||
@@ -44,9 +46,6 @@ export default {
|
||||
}
|
||||
return this.$t('INBOX_MGMT.FINISH.WEBSITE_SUCCESS');
|
||||
},
|
||||
websiteScript() {
|
||||
return createWebsiteWidgetScript(this.currentInbox.website_token);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
:sub-title="$t('INBOX_MGMT.SETTINGS_POPUP.MESSENGER_SUB_HEAD')"
|
||||
>
|
||||
</settings-form-header>
|
||||
<woot-code :script="webWidgetScript"></woot-code>
|
||||
<woot-code :script="inbox.web_widget_script"></woot-code>
|
||||
</div>
|
||||
<div class="settings--content">
|
||||
<settings-form-header
|
||||
@@ -70,8 +70,12 @@
|
||||
>
|
||||
</settings-form-header>
|
||||
<select v-model="autoAssignment">
|
||||
<option value="true">{{ $t('INBOX_MGMT.EDIT.AUTO_ASSIGNMENT.ENABLED') }}</option>
|
||||
<option value="false">{{ $t('INBOX_MGMT.EDIT.AUTO_ASSIGNMENT.DISABLED') }}</option>
|
||||
<option value="true">
|
||||
{{ $t('INBOX_MGMT.EDIT.AUTO_ASSIGNMENT.ENABLED') }}
|
||||
</option>
|
||||
<option value="false">
|
||||
{{ $t('INBOX_MGMT.EDIT.AUTO_ASSIGNMENT.DISABLED') }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -81,10 +85,7 @@
|
||||
/* eslint no-console: 0 */
|
||||
/* global bus */
|
||||
import { mapGetters } from 'vuex';
|
||||
import {
|
||||
createWebsiteWidgetScript,
|
||||
createMessengerScript,
|
||||
} from 'dashboard/helper/scriptGenerator';
|
||||
import { createMessengerScript } from 'dashboard/helper/scriptGenerator';
|
||||
import { Compact } from 'vue-color';
|
||||
import SettingsFormHeader from '../../../../components/SettingsFormHeader.vue';
|
||||
|
||||
@@ -112,9 +113,6 @@ export default {
|
||||
inbox() {
|
||||
return this.$store.getters['inboxes/getInbox'](this.currentInboxId);
|
||||
},
|
||||
webWidgetScript() {
|
||||
return createWebsiteWidgetScript(this.inbox.website_token);
|
||||
},
|
||||
messengerScript() {
|
||||
return createMessengerScript(this.inbox.page_id);
|
||||
},
|
||||
@@ -196,9 +194,13 @@ export default {
|
||||
enable_auto_assignment: this.autoAssignment,
|
||||
},
|
||||
});
|
||||
this.showAlert(this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE'));
|
||||
this.showAlert(
|
||||
this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE')
|
||||
);
|
||||
} catch (error) {
|
||||
this.showAlert(this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE'));
|
||||
this.showAlert(
|
||||
this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE')
|
||||
);
|
||||
}
|
||||
},
|
||||
getWidgetColor() {
|
||||
|
||||
@@ -213,7 +213,6 @@ const IFrameHelper = {
|
||||
});
|
||||
},
|
||||
toggleCloseButton: () => {
|
||||
console.log(window.matchMedia('(max-width: 668px)'));
|
||||
if (window.matchMedia('(max-width: 668px)').matches) {
|
||||
IFrameHelper.sendMessage('toggle-close-button', { showClose: true });
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user