Enable/disable downloading and printing for different disconnections. Add Asc.c_oAscError.ID.EditingError error.

This commit is contained in:
Julia Radzhabova 2018-10-25 16:19:29 +03:00
parent 79a59b4838
commit c62858944f
21 changed files with 87 additions and 51 deletions

View file

@ -143,7 +143,7 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onReplaceAll', _.bind(this.onApiTextReplaced, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this));
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
/** coauthoring begin **/
@ -564,7 +564,7 @@ define([
}
},
onApiServerDisconnect: function(disableDownload) {
onApiServerDisconnect: function(enableDownload) {
this.mode.isEdit = false;
this.leftMenu.close();
@ -575,7 +575,7 @@ define([
this.leftMenu.btnPlugins.setDisabled(true);
this.leftMenu.btnNavigation.setDisabled(true);
this.leftMenu.getMenu('file').setMode({isDisconnected: true, disableDownload: !!disableDownload});
this.leftMenu.getMenu('file').setMode({isDisconnected: true, enableDownload: !!enableDownload});
if ( this.dlgSearch ) {
this.leftMenu.btnSearch.toggle(false, true);
this.dlgSearch['hide']();

View file

@ -949,7 +949,7 @@ define([
}
if (me.needToUpdateVersion)
Common.NotificationCenter.trigger('api:disconnect');
Common.NotificationCenter.trigger('api:disconnect', true);
var timer_sl = setInterval(function(){
if (window.styles_loaded) {
clearInterval(timer_sl);
@ -968,7 +968,7 @@ define([
me.updateThemeColors();
toolbarController.activateControls();
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
toolbarController.onApiCoAuthoringDisconnect(true);
me.api.UpdateInterfaceState();
me.fillTextArt(me.api.asc_getTextArtPreviews());
@ -1020,7 +1020,7 @@ define([
}
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
Common.NotificationCenter.trigger('api:disconnect', true);
var value = Common.localStorage.getItem("de-license-warning");
value = (value!==null) ? parseInt(value) : 0;
@ -1429,6 +1429,10 @@ define([
config.msg = this.errorDataEncrypted;
break;
case Asc.c_oAscError.ID.EditingError:
config.msg = (this.appOptions.isDesktopApp && this.appOptions.isOffline) ? this.errorEditingSaveas : this.errorEditingDownloadas;
break;
default:
config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id);
break;
@ -1482,6 +1486,9 @@ define([
}
})).show();
},10);
} else if (id == Asc.c_oAscError.ID.EditingError) {
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect', true); // enable download and print
}
this._state.lostEditingRights = false;
this.onEditComplete();
@ -2301,7 +2308,9 @@ define([
errorDataEncrypted: 'Encrypted changes have been received, they cannot be deciphered.',
textClose: 'Close',
textPaidFeature: 'Paid feature',
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department'
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department',
errorEditingSaveas: 'An error occurred during the work with the document.<br>Use the \'Save as...\' option to save the file backup copy to your computer hard drive.',
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.'
}
})(), DE.Controllers.Main || {}))
});

View file

@ -358,7 +358,7 @@ define([
this.api.asc_registerCallback('asc_onMarkerFormatChanged', _.bind(this.onApiStartHighlight, this));
this.api.asc_registerCallback('asc_onTextHighLight', _.bind(this.onApiHighlightColor, this));
this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onCanCopyCut', _.bind(this.onApiCanCopyCut, this));
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this));
@ -2674,8 +2674,8 @@ define([
});
},
onApiCoAuthoringDisconnect: function(disableDownload) {
this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload});
onApiCoAuthoringDisconnect: function(enableDownload) {
this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload});
this.editMode = false;
this.DisableToolbar(true, true);
},

View file

@ -381,11 +381,11 @@ define([
}
},
onApiCoAuthoringDisconnect: function() {
onApiCoAuthoringDisconnect: function(enableDownload) {
if (this.header) {
if (this.header.btnDownload)
if (this.header.btnDownload && !enableDownload)
this.header.btnDownload.hide();
if (this.header.btnPrint)
if (this.header.btnPrint && !enableDownload)
this.header.btnPrint.hide();
if (this.header.btnEdit)
this.header.btnEdit.hide();

View file

@ -322,8 +322,8 @@ define([
this.mode.canOpenRecent = this.mode.canCreateNew = false;
this.mode.isDisconnected = mode.isDisconnected;
this.mode.canRename = false;
this.mode.canPrint = false;
this.mode.canDownload = this.mode.canDownloadOrigin = false;
if (!mode.enableDownload)
this.mode.canPrint = this.mode.canDownload = this.mode.canDownloadOrigin = false;
} else {
this.mode = mode;
}

View file

@ -2003,7 +2003,7 @@ define([
setMode: function (mode) {
if (mode.isDisconnected) {
this.btnSave.setDisabled(true);
if (mode.disableDownload)
if (!mode.enableDownload)
this.btnPrint.setDisabled(true);
}

View file

@ -359,6 +359,8 @@
"DE.Controllers.Main.errorUserDrop": "The file cannot be accessed right now.",
"DE.Controllers.Main.errorUsersExceed": "The number of users allowed by the pricing plan was exceeded",
"DE.Controllers.Main.errorViewerDisconnect": "Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored.",
"DE.Controllers.Main.errorEditingSaveas": "An error occurred during the work with the document.<br>Use the 'Save as...' option to save the file backup copy to your computer hard drive.",
"DE.Controllers.Main.errorEditingDownloadas": "An error occurred during the work with the document.<br>Use the 'Download as...' option to save the file backup copy to your computer hard drive.",
"DE.Controllers.Main.leavePageText": "You have unsaved changes in this document. Click \"Stay on This Page\", then \"Save\" to save them. Click \"Leave This Page\" to discard all the unsaved changes.",
"DE.Controllers.Main.loadFontsTextText": "Loading data...",
"DE.Controllers.Main.loadFontsTitleText": "Loading Data",

View file

@ -133,7 +133,7 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onThumbnailsShow', _.bind(this.onThumbnailsShow, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this));
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
/** coauthoring begin **/
@ -422,7 +422,7 @@ define([
// this.api.asc_selectSearchingResults(false);
},
onApiServerDisconnect: function(disableDownload) {
onApiServerDisconnect: function(enableDownload) {
this.mode.isEdit = false;
this.leftMenu.close();
@ -432,7 +432,7 @@ define([
/** coauthoring end **/
this.leftMenu.btnPlugins.setDisabled(true);
this.leftMenu.getMenu('file').setMode({isDisconnected: true, disableDownload: !!disableDownload});
this.leftMenu.getMenu('file').setMode({isDisconnected: true, enableDownload: !!enableDownload});
if ( this.dlgSearch ) {
this.leftMenu.btnSearch.toggle(false, true);
this.dlgSearch['hide']();

View file

@ -712,7 +712,7 @@ define([
}
if (me.needToUpdateVersion)
Common.NotificationCenter.trigger('api:disconnect');
Common.NotificationCenter.trigger('api:disconnect', true);
var timer_sl = setInterval(function(){
if (window.styles_loaded) {
clearInterval(timer_sl);
@ -734,7 +734,7 @@ define([
me.fillTextArt(me.api.asc_getTextArtPreviews());
toolbarController.activateControls();
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
toolbarController.onApiCoAuthoringDisconnect(true);
me.api.UpdateInterfaceState();
Common.NotificationCenter.trigger('document:ready', 'main');
@ -784,7 +784,7 @@ define([
}
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
Common.NotificationCenter.trigger('api:disconnect', true);
var value = Common.localStorage.getItem("pe-license-warning");
value = (value!==null) ? parseInt(value) : 0;
@ -1164,6 +1164,10 @@ define([
config.msg = this.errorDataEncrypted;
break;
case Asc.c_oAscError.ID.EditingError:
config.msg = (this.appOptions.isDesktopApp && this.appOptions.isOffline) ? this.errorEditingSaveas : this.errorEditingDownloadas;
break;
default:
config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id);
break;
@ -1216,6 +1220,9 @@ define([
}
})).show();
},10);
} else if (id == Asc.c_oAscError.ID.EditingError) {
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect', true); // enable download and print
}
this._state.lostEditingRights = false;
this.onEditComplete();
@ -2071,7 +2078,9 @@ define([
errorDataEncrypted: 'Encrypted changes have been received, they cannot be deciphered.',
textClose: 'Close',
textPaidFeature: 'Paid feature',
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department'
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department',
errorEditingSaveas: 'An error occurred during the work with the document.<br>Use the \'Save as...\' option to save the file backup copy to your computer hard drive.',
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.'
}
})(), PE.Controllers.Main || {}))
});

View file

@ -339,7 +339,7 @@ define([
this.api.asc_registerCallback('asc_onCanUnGroup', _.bind(this.onApiCanUnGroup, this));
this.api.asc_registerCallback('asc_onPresentationSize', _.bind(this.onApiPageSize, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onZoomChange', _.bind(this.onApiZoomChange, this));
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
@ -770,8 +770,8 @@ define([
this.toolbar.lockToolbar(PE.enumLock.themeLock, false, {array: [this.toolbar.btnColorSchemas, this.toolbar.listTheme]});
},
onApiCoAuthoringDisconnect: function(disableDownload) {
this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload});
onApiCoAuthoringDisconnect: function(enableDownload) {
this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload});
this.editMode = false;
},

View file

@ -423,11 +423,11 @@ define([
}
},
onApiCoAuthoringDisconnect: function() {
onApiCoAuthoringDisconnect: function(enableDownload) {
if (this.header) {
if (this.header.btnDownload)
if (this.header.btnDownload && !enableDownload)
this.header.btnDownload.hide();
if (this.header.btnPrint)
if (this.header.btnPrint && !enableDownload)
this.header.btnPrint.hide();
if (this.header.btnEdit)
this.header.btnEdit.hide();

View file

@ -310,8 +310,8 @@ define([
this.mode.canOpenRecent = this.mode.canCreateNew = false;
this.mode.isDisconnected = mode.isDisconnected;
this.mode.canRename = false;
this.mode.canPrint = false;
this.mode.canDownload = false;
if (!mode.enableDownload)
this.mode.canPrint = this.mode.canDownload = false;
} else {
this.mode = mode;
}

View file

@ -1316,7 +1316,11 @@ define([
setMode: function (mode) {
if (mode.isDisconnected) {
this.lockToolbar(PE.enumLock.lostConnect, true);
}
if (!mode.enableDownload)
this.lockToolbar(PE.enumLock.cantPrint, true, {array: [this.btnPrint]});
} else
this.lockToolbar(PE.enumLock.cantPrint, !mode.canPrint, {array: [this.btnPrint]});
this.mode = mode;
if (!mode.nativeApp) {
var nativeBtnGroup = $('.toolbar-group-native');
@ -1328,8 +1332,6 @@ define([
if (mode.isDesktopApp)
$('.toolbar-group-native').hide();
this.lockToolbar(PE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]});
},
onSendThemeColorSchemes: function (schemas) {

View file

@ -271,6 +271,8 @@
"PE.Controllers.Main.errorUserDrop": "The file cannot be accessed right now.",
"PE.Controllers.Main.errorUsersExceed": "The number of users allowed by the pricing plan was exceeded",
"PE.Controllers.Main.errorViewerDisconnect": "Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored.",
"PE.Controllers.Main.errorEditingSaveas": "An error occurred during the work with the document.<br>Use the 'Save as...' option to save the file backup copy to your computer hard drive.",
"PE.Controllers.Main.errorEditingDownloadas": "An error occurred during the work with the document.<br>Use the 'Download as...' option to save the file backup copy to your computer hard drive.",
"PE.Controllers.Main.leavePageText": "You have unsaved changes in this presentation. Click \"Stay on This Page\", then \"Save\" to save them. Click \"Leave This Page\" to discard all the unsaved changes.",
"PE.Controllers.Main.loadFontsTextText": "Loading data...",
"PE.Controllers.Main.loadFontsTitleText": "Loading Data",

View file

@ -141,7 +141,7 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onRenameCellTextEnd', _.bind(this.onRenameText, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this));
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
/** coauthoring begin **/
@ -621,7 +621,7 @@ define([
}
},
onApiServerDisconnect: function(disableDownload) {
onApiServerDisconnect: function(enableDownload) {
this.mode.isEdit = false;
this.leftMenu.close();
@ -631,7 +631,7 @@ define([
/** coauthoring end **/
this.leftMenu.btnPlugins.setDisabled(true);
this.leftMenu.getMenu('file').setMode({isDisconnected: true, disableDownload: !!disableDownload});
this.leftMenu.getMenu('file').setMode({isDisconnected: true, enableDownload: !!enableDownload});
if ( this.dlgSearch ) {
this.leftMenu.btnSearch.toggle(false, true);
this.dlgSearch['hide']();

View file

@ -710,8 +710,8 @@ define([
}
if (me.needToUpdateVersion) {
Common.NotificationCenter.trigger('api:disconnect');
toolbarController.onApiCoAuthoringDisconnect();
Common.NotificationCenter.trigger('api:disconnect', true);
toolbarController.onApiCoAuthoringDisconnect(true);
}
var timer_sl = setInterval(function(){
@ -746,7 +746,7 @@ define([
formulasDlgController.setMode(me.appOptions).setApi(me.api);
}
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
toolbarController.onApiCoAuthoringDisconnect(true);
Common.NotificationCenter.trigger('document:ready', 'main');
me.applyLicense();
@ -811,7 +811,7 @@ define([
}
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
Common.NotificationCenter.trigger('api:disconnect', true);
var value = Common.localStorage.getItem("sse-license-warning");
value = (value!==null) ? parseInt(value) : 0;
@ -1326,6 +1326,10 @@ define([
config.msg = this.errorDataEncrypted;
break;
case Asc.c_oAscError.ID.EditingError:
config.msg = (this.appOptions.isDesktopApp && this.appOptions.isOffline) ? this.errorEditingSaveas : this.errorEditingDownloadas;
break;
default:
config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id);
break;
@ -1361,6 +1365,9 @@ define([
if (id == Asc.c_oAscError.ID.Warning && btn == 'ok' && this.appOptions.canDownload) {
Common.UI.Menu.Manager.hideAll();
(this.appOptions.isDesktopApp && this.appOptions.isOffline) ? this.api.asc_DownloadAs() : this.getApplication().getController('LeftMenu').leftMenu.showMenu('file:saveas');
} else if (id == Asc.c_oAscError.ID.EditingError) {
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect', true); // enable download and print
}
this._state.lostEditingRights = false;
this.onEditComplete();
@ -2251,7 +2258,9 @@ define([
errorDataEncrypted: 'Encrypted changes have been received, they cannot be deciphered.',
textClose: 'Close',
textPaidFeature: 'Paid feature',
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department'
textLicencePaidFeature: 'The feature you are trying to use is available for additional payment.<br>If you need it, please contact Sales Department',
errorEditingSaveas: 'An error occurred during the work with the document.<br>Use the \'Save as...\' option to save the file backup copy to your computer hard drive.',
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -381,7 +381,7 @@ define([
}
this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this, true));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this));
this.api.asc_registerCallback('asc_onZoomChanged', _.bind(this.onApiZoomChange, this));
@ -1627,8 +1627,8 @@ define([
window.styles_loaded = true;
},
onApiCoAuthoringDisconnect: function(disableDownload) {
this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload});
onApiCoAuthoringDisconnect: function(enableDownload) {
this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload});
this.editMode = false;
},

View file

@ -437,11 +437,11 @@ define([
}
},
onApiCoAuthoringDisconnect: function() {
onApiCoAuthoringDisconnect: function(enableDownload) {
if (this.header) {
if (this.header.btnDownload)
if (this.header.btnDownload && !enableDownload)
this.header.btnDownload.hide();
if (this.header.btnPrint)
if (this.header.btnPrint && !enableDownload)
this.header.btnPrint.hide();
if (this.header.btnEdit)
this.header.btnEdit.hide();

View file

@ -298,8 +298,8 @@ define([
this.mode.canOpenRecent = this.mode.canCreateNew = false;
this.mode.isDisconnected = mode.isDisconnected;
this.mode.canRename = false;
this.mode.canPrint = false;
this.mode.canDownload = false;
if (!mode.enableDownload)
this.mode.canPrint = this.mode.canDownload = false;
} else {
this.mode = mode;
}

View file

@ -2007,7 +2007,8 @@ define([
this.lockToolbar( SSE.enumLock.lostConnect, true );
this.lockToolbar( SSE.enumLock.lostConnect, true,
{array:[this.btnEditChart,this.btnUndo,this.btnRedo]} );
this.lockToolbar(SSE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]});
if (!mode.enableDownload)
this.lockToolbar(SSE.enumLock.cantPrint, true, {array: [this.btnPrint]});
} else {
this.mode = mode;
this.lockToolbar(SSE.enumLock.cantPrint, !mode.canPrint, {array: [this.btnPrint]});

View file

@ -445,6 +445,8 @@
"SSE.Controllers.Main.errorViewerDisconnect": "Connection is lost. You can still view the document,<br>but will not be able to download or print until the connection is restored.",
"SSE.Controllers.Main.errorWrongBracketsCount": "An error in the entered formula.<br>Wrong number of brackets is used.",
"SSE.Controllers.Main.errorWrongOperator": "An error in the entered formula. Wrong operator is used.<br>Please correct the error.",
"SSE.Controllers.Main.errorEditingSaveas": "An error occurred during the work with the document.<br>Use the 'Save as...' option to save the file backup copy to your computer hard drive.",
"SSE.Controllers.Main.errorEditingDownloadas": "An error occurred during the work with the document.<br>Use the 'Download as...' option to save the file backup copy to your computer hard drive.",
"SSE.Controllers.Main.leavePageText": "You have unsaved changes in this spreadsheet. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.",
"SSE.Controllers.Main.loadFontsTextText": "Loading data...",
"SSE.Controllers.Main.loadFontsTitleText": "Loading Data",