Skip to content

Commit

Permalink
Handle refresh file event
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Jul 2, 2024
1 parent fff4c1a commit 8ea2e6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
7 changes: 7 additions & 0 deletions apps/common/main/lib/component/SynchronizeTip.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ define([
return this.cmpEl && this.cmpEl.is(':visible');
},

setText: function(text) {
if (this.text !== text) {
this.text = text;
this.cmpEl.find('.tip-text').text(text);
}
},

textDontShow : 'Don\'t show this message again',
textSynchronize : 'The document has been changed by another user.<br>Please click to save your changes and reload the updates.'
}
Expand Down
28 changes: 21 additions & 7 deletions apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,9 @@ define([
return"#"+("000000"+color.toString(16)).substr(-6);
},

disableEditing: function(disable, temp) {
var app = this.getApplication();
disableEditing: function(disable, type) {
var app = this.getApplication(),
temp = type==='reconnect' || type==='refresh-file';
Common.NotificationCenter.trigger('editing:disable', disable, {
viewMode: disable,
reviewMode: false,
Expand All @@ -807,7 +808,7 @@ define([
toolbar: true,
plugins: false,
protect: false
}, temp ? 'reconnect' : 'disconnect');
}, temp ? type : 'disconnect');
},

onEditingDisable: function(disable, options, type) {
Expand Down Expand Up @@ -1006,9 +1007,13 @@ define([

if ( id == Asc.c_oAscAsyncAction['Disconnect']) {
this._state.timerDisconnect && clearTimeout(this._state.timerDisconnect);
this.disableEditing(false, true);
this.disableEditing(false, 'reconnect');
this.getApplication().getController('Statusbar').hideDisconnectTip();
this.getApplication().getController('Statusbar').setStatusCaption(this.textReconnect);
} else if (id === Asc.c_oAscAsyncAction['RefreshFile']) {
this.disableEditing(false, 'refresh-file');
this.getApplication().getController('Statusbar').hideDisconnectTip();
this.getApplication().getController('Statusbar').setStatusCaption('');
}

if ( type == Asc.c_oAscAsyncActionType.BlockInteraction &&
Expand Down Expand Up @@ -1111,7 +1116,7 @@ define([
case Asc.c_oAscAsyncAction['Disconnect']:
text = this.textDisconnect;
Common.UI.Menu.Manager.hideAll();
this.disableEditing(true, true);
this.disableEditing(true, 'reconnect');
var me = this;
statusCallback = function() {
me._state.timerDisconnect = setTimeout(function(){
Expand All @@ -1120,6 +1125,13 @@ define([
};
break;

case Asc.c_oAscAsyncAction['RefreshFile']:
text = this.textUpdating;
Common.UI.Menu.Manager.hideAll();
this.disableEditing(true, 'refresh-file');
this.getApplication().getController('Statusbar').showDisconnectTip(this.textUpdateVersion);
break;

default:
if (typeof action.id == 'string'){
title = action.id;
Expand Down Expand Up @@ -2780,7 +2792,7 @@ define([
warningDocumentIsLocked: function() {
var me = this;
var _disable_ui = function (disable) {
me.disableEditing(disable, true);
me.disableEditing(disable, 'reconnect');
};

Common.Utils.warningDocumentIsLocked({disablefunc: _disable_ui});
Expand Down Expand Up @@ -3443,7 +3455,9 @@ define([
errorInconsistentExtPdf: 'An error has occurred while opening the file.<br>The file content corresponds to one of the following formats: pdf/djvu/xps/oxps, but the file has the inconsistent extension: %1.',
errorInconsistentExt: 'An error has occurred while opening the file.<br>The file content does not match the file extension.',
errorCannotPasteImg: 'We can\'t paste this image from the Clipboard, but you can save it to your device and \ninsert it from there, or you can copy the image without text and paste it into the document.',
textTryQuickPrint: 'You have selected Quick print: the entire document will be printed on the last selected or default printer.<br>Do you want to continue?'
textTryQuickPrint: 'You have selected Quick print: the entire document will be printed on the last selected or default printer.<br>Do you want to continue?',
textUpdating: 'Updating',
textUpdateVersion: 'The file version has been changed. Please wait...',
}
})(), DE.Controllers.Main || {}))
});
7 changes: 5 additions & 2 deletions apps/documenteditor/main/app/controller/Statusbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,15 @@ define([
return tip;
},

showDisconnectTip: function () {
showDisconnectTip: function (text) {
var me = this;
text = text || this.textDisconnect;
if (!this.disconnectTip) {
var target = this.statusbar.getStatusLabel();
target = target.is(':visible') ? target.parent() : this.statusbar.isVisible() ? this.statusbar.$el : $(document.body);
this.disconnectTip = new Common.UI.SynchronizeTip({
target : target,
text : this.textDisconnect,
text : text,
placement: 'top',
position: this.statusbar.isVisible() ? undefined : {bottom: 0},
showLink: false,
Expand All @@ -342,6 +343,8 @@ define([
me.disconnectTip = null;
}
});
} else {
this.disconnectTip.setText(text);
}
this.disconnectTip.show();
},
Expand Down

0 comments on commit 8ea2e6f

Please sign in to comment.