Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] MSPB-315: Updated cross-site message based routing #520

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 33 additions & 50 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ define(function(require) {
},

requests: {},
subscribe: {},
subscribe: {
'core.crossSiteMessage.voip': 'crossSiteMessageHandler'
},
appFlags: {
common: {
hasProvisioner: false,
Expand Down Expand Up @@ -70,18 +72,7 @@ define(function(require) {
}
}
}
},
navigationMenus: [
'myOffice',
'numbers',
'users',
'groups',
'strategy',
'callLogs',
'devices',
'vmboxes',
'featureCodes'
]
}
},
global: {},
disableFirstUseWalkthrough: monster.config.whitelabel.disableFirstUseWalkthrough
Expand Down Expand Up @@ -158,45 +149,37 @@ define(function(require) {

bindEvents: function(parent) {
var self = this,
container = parent.find('.right-content'),
bindDefaultNavigation = function defaultNavigation() {
parent.find('.left-menu').on('click', '.category:not(.loading)', function() {
// Get the ID of the submodule to render
var $this = $(this),
args = {
parent: container,
callback: function() {
parent.find('.category').removeClass('loading');
}
},
id = $this.attr('id');

// Display the category we clicked as active
parent
.find('.category')
.removeClass('active')
.addClass('loading');
$this.toggleClass('active');

// Empty the main container and then render the submodule content
container.empty();
monster.pub('voip.' + id + '.render', args);
});
},
bindEventNavigation = function bindEventNavigation() {
window.addEventListener('message', function(event) {
var args = { parent: container };

if (event.data.type === 'smartpbx.routing' && self.appFlags.common.navigationMenus.includes(event.data.data)) {
container.empty();
monster.pub('voip.' + event.data.data + '.render', args);
container = parent.find('.right-content');

parent.find('.left-menu').on('click', '.category:not(.loading)', function() {
// Get the ID of the submodule to render
var $this = $(this),
args = {
parent: container,
callback: function() {
parent.find('.category').removeClass('loading');
}
});
};
},
id = $this.attr('id');

// Display the category we clicked as active
parent
.find('.category')
.removeClass('active')
.addClass('loading');
$this.toggleClass('active');

// Empty the main container and then render the submodule content
container.empty();
monster.pub('voip.' + id + '.render', args);
});
},

crossSiteMessageHandler: function(topic) {
var crossSiteMessageTopic = topic.replace('.tab', '') + '.render',
container = $('.right-content');

monster.util.getFeatureConfig('smartpbx.other.eventRouting', false)
? bindEventNavigation()
: bindDefaultNavigation();
monster.pub(crossSiteMessageTopic, { parent: container });
},

overlayInsert: function() {
Expand Down
3 changes: 2 additions & 1 deletion submodules/callLogs/callLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ define(function(require) {
var self = this,
template,
defaultDateRange = 1,
container = parent || $('.right-content'),
maxDateRange = 31;

if (!toDate && !fromDate) {
Expand Down Expand Up @@ -193,7 +194,7 @@ define(function(require) {

monster.ui.tooltips(template);

parent
container
.empty()
.append(template);

Expand Down