Add parameter customization.goback.requestClose to api: send event onRequestClose instead opening customization.goback.url

This commit is contained in:
Julia Radzhabova 2019-11-27 10:22:25 +03:00
parent 8a974c8a35
commit 61ab8193fb
13 changed files with 102 additions and 71 deletions

View file

@ -109,7 +109,8 @@
goback: {
url: 'http://...',
text: 'Go to London',
blank: true
blank: true,
requestClose: false // if true - goback send onRequestClose event instead opening url
},
chat: true,
comments: true,

View file

@ -75,7 +75,7 @@ DE.ApplicationController = new(function(){
$('#editor_sdk').addClass('top');
}
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && config.customization.goback.url)) {
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose))) {
$('#id-btn-close').hide();
// Hide last separator
@ -266,8 +266,12 @@ DE.ApplicationController = new(function(){
});
$('#id-btn-close').on('click', function(){
if (config.customization && config.customization.goback && config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
if (config.customization && config.customization.goback) {
if (config.customization.goback.requestClose && config.canRequestClose)
Common.Gateway.requestClose();
else if (config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
}
});
$('#id-btn-zoom-in').on('click', api.zoomIn.bind(this));

View file

@ -341,9 +341,10 @@ define([
this.appOptions.mergeFolderUrl = this.editorConfig.mergeFolderUrl;
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.canAnalytics = false;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')
&& (typeof (this.editorConfig.customization.goback) == 'object') && !_.isEmpty(this.editorConfig.customization.goback.url);
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
this.appOptions.canPlugins = false;
this.appOptions.canMakeActionLink = this.editorConfig.canMakeActionLink;
@ -648,11 +649,16 @@ define([
goBack: function(current) {
if ( !Common.Controllers.Desktop.process('goback') ) {
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
Common.Gateway.requestClose();
// Common.Controllers.Desktop.requestClose();
} else {
parent.location.href = href;
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
}
},
@ -1155,7 +1161,6 @@ define([
this.appOptions.isOffline = this.api.asc_isOffline();
this.appOptions.isReviewOnly = this.permissions.review === true && this.permissions.edit === false;
this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.canEdit = (this.permissions.edit !== false || this.permissions.review === true) && // can edit or review
(this.editorConfig.canRequestEditRights || this.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined
(!this.appOptions.isReviewOnly || this.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true

View file

@ -210,9 +210,10 @@ define([
me.appOptions.fileChoiceUrl = me.editorConfig.fileChoiceUrl;
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object')
&& (typeof (me.editorConfig.customization.goback) == 'object') && !_.isEmpty(me.editorConfig.customization.goback.url);
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
me.appOptions.canPlugins = false;
me.plugins = me.editorConfig.plugins;
@ -335,11 +336,15 @@ define([
},
goBack: function(current) {
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
Common.Gateway.requestClose();
} else {
parent.location.href = href;
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
},
@ -730,7 +735,6 @@ define([
me.appOptions.isOffline = me.api.asc_isOffline();
me.appOptions.isReviewOnly = (me.permissions.review === true) && (me.permissions.edit === false);
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined
(!me.appOptions.isReviewOnly || me.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true

View file

@ -51,8 +51,7 @@ define([
DE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var _backUrl,
stateDisplayMode = false;
var stateDisplayMode = false;
return {
models: [],
@ -67,9 +66,7 @@ define([
loadConfig: function (data) {
if (data && data.config && data.config.canBackToFolder !== false &&
data.config.customization && data.config.customization.goback && data.config.customization.goback.url) {
_backUrl = data.config.customization.goback.url;
data.config.customization && data.config.customization.goback && (data.config.customization.goback.url || data.config.customization.goback.requestClose && data.config.canRequestClose)) {
$('#document-back').show().single('click', _.bind(this.onBack, this));
}
},
@ -116,7 +113,7 @@ define([
{
text: me.leaveButtonText,
onClick: function() {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},
{
@ -126,7 +123,7 @@ define([
]
});
} else {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},

View file

@ -76,7 +76,7 @@ PE.ApplicationController = new(function(){
$('#editor_sdk').addClass('top');
}
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && config.customization.goback.url)) {
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose))) {
$('#id-btn-close').hide();
// Hide last separator
@ -310,8 +310,12 @@ PE.ApplicationController = new(function(){
});
$('#id-btn-close').on('click', function(){
if (config.customization && config.customization.goback && config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
if (config.customization && config.customization.goback) {
if (config.customization.goback.requestClose && config.canRequestClose)
Common.Gateway.requestClose();
else if (config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
}
});
$('#btn-left').on('click', function(){

View file

@ -310,9 +310,10 @@ define([
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
this.appOptions.canAnalytics = false;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')
&& (typeof (this.editorConfig.customization.goback) == 'object') && !_.isEmpty(this.editorConfig.customization.goback.url);
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
this.appOptions.canPlugins = false;
this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers;
@ -447,11 +448,16 @@ define([
goBack: function(current) {
var me = this;
if ( !Common.Controllers.Desktop.process('goback') ) {
var href = me.appOptions.customization.goback.url;
if (!current && me.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (me.appOptions.customization.goback.requestClose && me.appOptions.canRequestClose) {
Common.Gateway.requestClose();
// Common.Controllers.Desktop.requestClose();
} else {
parent.location.href = href;
var href = me.appOptions.customization.goback.url;
if (!current && me.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
}
},
@ -899,7 +905,6 @@ define([
this.appOptions.canCoAuthoring = !this.appOptions.isLightVersion;
/** coauthoring end **/
this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.canEdit = this.permissions.edit !== false && // can edit
(this.editorConfig.canRequestEditRights || this.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined
this.appOptions.isEdit = this.appOptions.canLicense && this.appOptions.canEdit && this.editorConfig.mode !== 'view';

View file

@ -209,9 +209,10 @@ define([
me.appOptions.fileChoiceUrl = me.editorConfig.fileChoiceUrl;
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object')
&& (typeof (me.editorConfig.customization.goback) == 'object') && !_.isEmpty(me.editorConfig.customization.goback.url);
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
me.appOptions.canPlugins = false;
me.plugins = me.editorConfig.plugins;
@ -322,11 +323,15 @@ define([
},
goBack: function(current) {
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
Common.Gateway.requestClose();
} else {
parent.location.href = href;
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
},
@ -662,7 +667,6 @@ define([
me.appOptions.isOffline = me.api.asc_isOffline();
me.appOptions.isReviewOnly = (me.permissions.review === true) && (me.permissions.edit === false);
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined
(!me.appOptions.isReviewOnly || me.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true

View file

@ -51,7 +51,6 @@ define([
PE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var _backUrl;
return {
models: [],
@ -66,9 +65,7 @@ define([
loadConfig: function (data) {
if (data && data.config && data.config.canBackToFolder !== false &&
data.config.customization && data.config.customization.goback && data.config.customization.goback.url) {
_backUrl = data.config.customization.goback.url;
data.config.customization && data.config.customization.goback && (data.config.customization.goback.url || data.config.customization.goback.requestClose && data.config.canRequestClose)) {
$('#document-back').show().single('click', _.bind(this.onBack, this));
}
},
@ -115,7 +112,7 @@ define([
{
text: me.leaveButtonText,
onClick: function() {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},
{
@ -125,7 +122,7 @@ define([
]
});
} else {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},

View file

@ -68,7 +68,7 @@ SSE.ApplicationController = new(function(){
common.controller.modals.init(embedConfig);
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && config.customization.goback.url))
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose)))
$('#id-btn-close').hide();
// Docked toolbar
@ -211,8 +211,12 @@ SSE.ApplicationController = new(function(){
});
$('#id-btn-close').on('click', function(){
if (config.customization && config.customization.goback && config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
if (config.customization && config.customization.goback) {
if (config.customization.goback.requestClose && config.canRequestClose)
Common.Gateway.requestClose();
else if (config.customization.goback.url)
window.parent.location.href = config.customization.goback.url;
}
});
$('#id-btn-zoom-in').on('click', function () {

View file

@ -326,9 +326,10 @@ define([
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram';
this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge';
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')
&& (typeof (this.editorConfig.customization.goback) == 'object') && !_.isEmpty(this.editorConfig.customization.goback.url);
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose);
this.appOptions.canBack = this.appOptions.canBackToFolder === true;
this.appOptions.canPlugins = false;
this.appOptions.canRequestUsers = this.editorConfig.canRequestUsers;
@ -477,11 +478,16 @@ define([
goBack: function(current) {
var me = this;
if ( !Common.Controllers.Desktop.process('goback') ) {
var href = me.appOptions.customization.goback.url;
if (!current && me.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (me.appOptions.customization.goback.requestClose && me.appOptions.canRequestClose) {
Common.Gateway.requestClose();
// Common.Controllers.Desktop.requestClose();
} else {
parent.location.href = href;
var href = me.appOptions.customization.goback.url;
if (!current && me.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
}
},
@ -950,7 +956,6 @@ define([
this.appOptions.canModifyFilter = true;
this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights;
this.appOptions.canRequestClose = this.editorConfig.canRequestClose;
this.appOptions.canEdit = this.permissions.edit !== false && // can edit
(this.editorConfig.canRequestEditRights || this.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined
this.appOptions.isEdit = (this.appOptions.canLicense || this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && this.permissions.edit !== false && this.editorConfig.mode !== 'view';

View file

@ -217,9 +217,10 @@ define([
me.appOptions.fileChoiceUrl = me.editorConfig.fileChoiceUrl;
me.appOptions.mergeFolderUrl = me.editorConfig.mergeFolderUrl;
me.appOptions.canAnalytics = false;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.customization = me.editorConfig.customization;
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object')
&& (typeof (me.editorConfig.customization.goback) == 'object') && !_.isEmpty(me.editorConfig.customization.goback.url);
me.appOptions.canBackToFolder = (me.editorConfig.canBackToFolder!==false) && (typeof (me.editorConfig.customization) == 'object') && (typeof (me.editorConfig.customization.goback) == 'object')
&& (!_.isEmpty(me.editorConfig.customization.goback.url) || me.editorConfig.customization.goback.requestClose && me.appOptions.canRequestClose);
me.appOptions.canBack = me.appOptions.canBackToFolder === true;
me.appOptions.canPlugins = false;
me.plugins = me.editorConfig.plugins;
@ -338,11 +339,15 @@ define([
},
goBack: function(current) {
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
if (this.appOptions.customization.goback.requestClose && this.appOptions.canRequestClose) {
Common.Gateway.requestClose();
} else {
parent.location.href = href;
var href = this.appOptions.customization.goback.url;
if (!current && this.appOptions.customization.goback.blank!==false) {
window.open(href, "_blank");
} else {
parent.location.href = href;
}
}
},
@ -706,7 +711,6 @@ define([
}
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canRequestClose = me.editorConfig.canRequestClose;
me.appOptions.canEdit = me.permissions.edit !== false && // can edit
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined
me.appOptions.isEdit = (me.appOptions.canLicense || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && me.permissions.edit !== false && me.editorConfig.mode !== 'view';

View file

@ -51,7 +51,6 @@ define([
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var _backUrl;
var locked = {
book: false,
sheet: false
@ -70,9 +69,7 @@ define([
loadConfig: function (data) {
if (data && data.config && data.config.canBackToFolder !== false &&
data.config.customization && data.config.customization.goback && data.config.customization.goback.url) {
_backUrl = data.config.customization.goback.url;
data.config.customization && data.config.customization.goback && (data.config.customization.goback.url || data.config.customization.goback.requestClose && data.config.canRequestClose)) {
$('#document-back').show().single('click', _.bind(this.onBack, this));
}
},
@ -124,7 +121,7 @@ define([
{
text: me.leaveButtonText,
onClick: function() {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},
{
@ -134,7 +131,7 @@ define([
]
});
} else {
window.parent.location.href = _backUrl;
Common.NotificationCenter.trigger('goback', true);
}
},