Skip to content

Commit

Permalink
Merge pull request 'Add onUserActionRequired event' (#169) from featu…
Browse files Browse the repository at this point in the history
…re/user-action into release/v8.3.0
  • Loading branch information
Julia Radzhabova committed Dec 10, 2024
2 parents c365d66 + 36565b7 commit 18b7c22
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 14 deletions.
1 change: 1 addition & 0 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
'onRequestStartFilling': <try to start filling forms> // used in pdf-form edit mode. must call startFilling method
'onSubmit': <filled form is submitted> // send when filled form is submitted successfully
'onRequestRefreshFile': <request new file version> // send when file version is updated. use instead of onOutdatedVersion
'onUserActionRequired': <user action callback> // send if the user needs to enter a password or select encoding/delimiters when opening a file
}
}
Expand Down
4 changes: 4 additions & 0 deletions apps/common/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ if (window.Common === undefined) {
_postMessage({ event: 'onRequestRefreshFile' });
},

userActionRequired: function() {
_postMessage({ event: 'onUserActionRequired' });
},

saveDocument: function(data) {
data && _postMessage({
event: 'onSaveDocument',
Expand Down
8 changes: 7 additions & 1 deletion apps/documenteditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ DE.ApplicationController = new(function(){
btnSubmit,
_submitFail, $submitedTooltip, $requiredTooltip,
$listControlMenu, listControlItems = [], listObj,
bodyWidth = 0;
bodyWidth = 0,
requireUserAction = true;

var LoadingDocument = -256;

Expand Down Expand Up @@ -647,6 +648,7 @@ DE.ApplicationController = new(function(){

Common.Gateway.documentReady();
Common.Analytics.trackEvent('Load', 'Complete');
requireUserAction = false;
}

function onEditorPermissions(params) {
Expand Down Expand Up @@ -750,6 +752,10 @@ DE.ApplicationController = new(function(){
api && api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, advOptions.asc_getRecommendedSettings() || new Asc.asc_CTextOptions());
onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
}
if (requireUserAction) {
Common.Gateway.userActionRequired();
requireUserAction = false;
}
}

function onError(id, level, errData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ define([
isTooltipHiding = false,
bodyWidth = 0,
ttOffset = [0, -10],
_logoImage = '';
_logoImage = '',
requireUserAction = true;

DE.Controllers.ApplicationController = Backbone.Controller.extend(_.assign({
views: [
Expand Down Expand Up @@ -995,6 +996,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._openDlg.show();
}
if (requireUserAction) {
Common.Gateway.userActionRequired();
requireUserAction = false;
}
},

onDocMouseMoveStart: function() {
Expand Down Expand Up @@ -1551,6 +1556,7 @@ define([
Common.Gateway.documentReady();
Common.Analytics.trackEvent('Load', 'Complete');
Common.NotificationCenter.trigger('document:ready');
requireUserAction = false;
},

onOptionsClick: function(menu, item, e) {
Expand Down
7 changes: 6 additions & 1 deletion apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ define([

this.stackMacrosRequests = [];

this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false};
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true};
this.languages = null;

// Initialize viewport
Expand Down Expand Up @@ -1522,6 +1522,7 @@ define([

$(document).on('contextmenu', _.bind(me.onContextMenu, me));
Common.Gateway.documentReady();
this._state.requireUserAction = false;

$('#editor-container').css('overflow', '');
$('.doc-placeholder').remove();
Expand Down Expand Up @@ -2889,6 +2890,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._state.openDlg.show();
}
if (me._state.requireUserAction) {
Common.Gateway.userActionRequired();
me._state.requireUserAction = false;
}
},

onTryUndoInFastCollaborative: function() {
Expand Down
8 changes: 7 additions & 1 deletion apps/documenteditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class MainController extends Component {
licenseType: false,
isFromGatewayDownloadAs: false,
isDocModified: false,
docProtection: false
docProtection: false,
requireUserAction: true
};

this.defaultTitleText = __APP_TITLE_TEXT__;
Expand Down Expand Up @@ -421,6 +422,7 @@ class MainController extends Component {
Common.Notifications.trigger('document:ready');
Common.Gateway.documentReady();
appOptions.changeDocReady(true);
this._state.requireUserAction = false;

if(isOForm) {
f7.dialog.create({
Expand Down Expand Up @@ -974,6 +976,10 @@ class MainController extends Component {
onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM);
this.isDRM = true;
}
if (this._state.requireUserAction) {
Common.Gateway.userActionRequired();
this._state.requireUserAction = false;
}
});

// Protection document
Expand Down
7 changes: 6 additions & 1 deletion apps/pdfeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ define([

this.stackMacrosRequests = [];

this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false};
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true};
this.languages = null;

// Initialize viewport
Expand Down Expand Up @@ -1166,6 +1166,7 @@ define([

$(document).on('contextmenu', _.bind(me.onContextMenu, me));
Common.Gateway.documentReady();
this._state.requireUserAction = false;

$('#editor-container').css('overflow', '');
$('.doc-placeholder').remove();
Expand Down Expand Up @@ -2330,6 +2331,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._state.openDlg.show();
}
if (me._state.requireUserAction) {
Common.Gateway.userActionRequired();
me._state.requireUserAction = false;
}
},

onTryUndoInFastCollaborative: function() {
Expand Down
8 changes: 7 additions & 1 deletion apps/presentationeditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ PE.ApplicationController = new(function(){
created = false,
currentPage = 0,
ttOffset = [5, -10],
labelDocName;
labelDocName,
requireUserAction = true;

var LoadingDocument = -256;

Expand Down Expand Up @@ -518,6 +519,7 @@ PE.ApplicationController = new(function(){
$('#btn-play').on('click', onPlayStart);
Common.Gateway.documentReady();
Common.Analytics.trackEvent('Load', 'Complete');
requireUserAction = false;
}

function onEditorPermissions(params) {
Expand Down Expand Up @@ -593,6 +595,10 @@ PE.ApplicationController = new(function(){
else $('#loading-mask').addClass("none-animation");
onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
}
if (requireUserAction) {
Common.Gateway.userActionRequired();
requireUserAction = false;
}
}

function onError(id, level, errData) {
Expand Down
7 changes: 6 additions & 1 deletion apps/presentationeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ define([
onLaunch: function() {
var me = this;

this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false};
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true};
this.languages = null;

window.storagename = 'presentation';
Expand Down Expand Up @@ -1105,6 +1105,7 @@ define([
});
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
Common.Gateway.documentReady();
this._state.requireUserAction = false;

$('.doc-placeholder').remove();
this.appOptions.user.guest && this.appOptions.canRenameAnonymous && (Common.Utils.InternalSettings.get("guest-username")===null) && this.showRenameUserDialog();
Expand Down Expand Up @@ -2555,6 +2556,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._state.openDlg.show();
}
if (me._state.requireUserAction) {
Common.Gateway.userActionRequired();
me._state.requireUserAction = false;
}
},

warningDocumentIsLocked: function() {
Expand Down
8 changes: 7 additions & 1 deletion apps/presentationeditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class MainController extends Component {

this._state = {
licenseType: false,
isDocModified: false
isDocModified: false,
requireUserAction: true
};

this.defaultTitleText = __APP_TITLE_TEXT__;
Expand Down Expand Up @@ -603,6 +604,7 @@ class MainController extends Component {
Common.Notifications.trigger('document:ready');

appOptions.changeDocReady(true);
this._state.requireUserAction = false;
}

insertImage (data) {
Expand Down Expand Up @@ -848,6 +850,10 @@ class MainController extends Component {
}).open();
this.isDRM = true;
}
if (this._state.requireUserAction) {
Common.Gateway.userActionRequired();
this._state.requireUserAction = false;
}
}

onDocumentName () {
Expand Down
9 changes: 7 additions & 2 deletions apps/spreadsheeteditor/embed/js/ApplicationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ SSE.ApplicationController = new(function(){
maxPages = 0,
created = false,
iframePrint = null,
isRtlSheet = false;
isRtlSheet = false,
requireUserAction = true;
var $ttEl,
$tooltip,
ttOffset = [6, -15],
Expand Down Expand Up @@ -557,7 +558,7 @@ SSE.ApplicationController = new(function(){

Common.Gateway.documentReady();
Common.Analytics.trackEvent('Load', 'Complete');

requireUserAction = false;
onSheetsChanged();
setupScrollButtons();
}
Expand Down Expand Up @@ -640,6 +641,10 @@ SSE.ApplicationController = new(function(){
api && api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, advOptions.asc_getRecommendedSettings() || new Asc.asc_CTextOptions());
onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
}
if (requireUserAction) {
Common.Gateway.userActionRequired();
requireUserAction = false;
}
}

function onError(id, level, errData) {
Expand Down
8 changes: 7 additions & 1 deletion apps/spreadsheeteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ define([
// $(document.body).css('position', 'absolute');
var me = this;

this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false};
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true};

if (!Common.Utils.isBrowserSupported()){
Common.Utils.showBrowserRestriction();
Expand Down Expand Up @@ -1181,6 +1181,8 @@ define([
} else checkWarns();

Common.Gateway.documentReady();
this._state.requireUserAction = false;

if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle && (Common.Utils.InternalSettings.get("guest-username")===null))
this.showRenameUserDialog();
if (this._needToSaveAsFile) // warning received before document is ready
Expand Down Expand Up @@ -2595,6 +2597,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._state.openDlg.show();
}
if (me._state.requireUserAction) {
Common.Gateway.userActionRequired();
me._state.requireUserAction = false;
}
},

onActiveSheetChanged: function(index) {
Expand Down
8 changes: 7 additions & 1 deletion apps/spreadsheeteditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class MainController extends Component {

this._state = {
licenseType: false,
isDocModified: false
isDocModified: false,
requireUserAction: true
};

this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns',
Expand Down Expand Up @@ -486,6 +487,10 @@ class MainController extends Component {
onAdvancedOptions(type, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose, this.isDRM);
this.isDRM = true;
}
if (this._state.requireUserAction) {
Common.Gateway.userActionRequired();
this._state.requireUserAction = false;
}
});

// Toolbar settings
Expand Down Expand Up @@ -766,6 +771,7 @@ class MainController extends Component {
f7.emit('resize');

appOptions.changeDocReady(true);
this._state.requireUserAction = false;
}

insertImage (data) {
Expand Down
7 changes: 6 additions & 1 deletion apps/visioeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ define([

this.stackMacrosRequests = [];

this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false};
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false, requireUserAction: true};
this.languages = null;

// Initialize viewport
Expand Down Expand Up @@ -997,6 +997,7 @@ define([

$(document).on('contextmenu', _.bind(me.onContextMenu, me));
Common.Gateway.documentReady();
this._state.requireUserAction = false;

$('.doc-placeholder').remove();

Expand Down Expand Up @@ -1771,6 +1772,10 @@ define([
this.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
me._state.openDlg.show();
}
if (me._state.requireUserAction) {
Common.Gateway.userActionRequired();
me._state.requireUserAction = false;
}
},

onAuthParticipantsChanged: function(users) {
Expand Down
8 changes: 7 additions & 1 deletion apps/visioeditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class MainController extends Component {

this._state = {
licenseType: false,
isDocModified: false
isDocModified: false,
requireUserAction: true
};

this.defaultTitleText = __APP_TITLE_TEXT__;
Expand Down Expand Up @@ -391,6 +392,7 @@ class MainController extends Component {
Common.Notifications.trigger('document:ready');

appOptions.changeDocReady(true);
this._state.requireUserAction = false;
}

onLicenseChanged (params) {
Expand Down Expand Up @@ -610,6 +612,10 @@ class MainController extends Component {
}).open();
this.isDRM = true;
}
if (this._state.requireUserAction) {
Common.Gateway.userActionRequired();
this._state.requireUserAction = false;
}
}

onDocumentName () {
Expand Down

0 comments on commit 18b7c22

Please sign in to comment.