[DE mobile] Changes related to main controller

This commit is contained in:
JuliaSvinareva 2021-04-20 19:49:49 +03:00
parent 1a2dca4872
commit 57043e6602
5 changed files with 41 additions and 12 deletions

View file

@ -94,7 +94,8 @@
"errorUpdateVersionOnDisconnect": "Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.", "errorUpdateVersionOnDisconnect": "Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.",
"errorDefaultMessage": "Error code: %1", "errorDefaultMessage": "Error code: %1",
"criticalErrorExtText": "Press 'OK' to back to document list.", "criticalErrorExtText": "Press 'OK' to back to document list.",
"notcriticalErrorTitle": "Warning" "notcriticalErrorTitle": "Warning",
"scriptLoadError": "The connection is too slow, some of the components could not be loaded. Please reload the page."
}, },
"LongActions": { "LongActions": {
"openTitleText": "Opening Document", "openTitleText": "Opening Document",

View file

@ -1,8 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect } from 'react';
import { inject } from 'mobx-react'; import { inject } from 'mobx-react';
import { f7 } from 'framework7-react'; import { f7 } from 'framework7-react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import LongActionsController from "./LongActions";
const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocument}) => { const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocument}) => {
const {t} = useTranslation(); const {t} = useTranslation();
@ -22,7 +21,7 @@ const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocu
if (id === Asc.c_oAscError.ID.LoadingScriptError) { if (id === Asc.c_oAscError.ID.LoadingScriptError) {
f7.notification.create({ f7.notification.create({
title: _t.criticalErrorTitle, title: _t.criticalErrorTitle,
text: _t.criticalErrorTitle, text: _t.scriptLoadError,
closeButton: true closeButton: true
}).open(); }).open();
return; return;
@ -183,7 +182,7 @@ const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocu
// report only critical errors // report only critical errors
Common.Gateway.reportError(id, config.msg); Common.Gateway.reportError(id, config.msg);
config.title = this.criticalErrorTitle; config.title = _t.criticalErrorTitle;
if (storeAppOptions.canBackToFolder && !storeAppOptions.isDesktopApp) { if (storeAppOptions.canBackToFolder && !storeAppOptions.isDesktopApp) {
config.msg += '</br></br>' + _t.criticalErrorExtText; config.msg += '</br></br>' + _t.criticalErrorExtText;

View file

@ -20,7 +20,7 @@ class LongActions extends Component {
} }
closePreloader() { closePreloader() {
if (this.loadMask.el) { if (this.loadMask && this.loadMask.el) {
f7.dialog.close(this.loadMask.el); f7.dialog.close(this.loadMask.el);
} }
} }
@ -70,7 +70,7 @@ class LongActions extends Component {
if (action) { if (action) {
this.setLongActionView(action) this.setLongActionView(action)
} else { } else {
this.loadMask.el && this.loadMask.el.classList.contains('modal-in') && f7.dialog.close(this.loadMask.el); this.loadMask && this.loadMask.el && this.loadMask.el.classList.contains('modal-in') && f7.dialog.close(this.loadMask.el);
} }
} }

View file

@ -189,6 +189,9 @@ class MainController extends Component {
}; };
const onDocumentContentReady = () => { const onDocumentContentReady = () => {
if (this._isDocReady)
return;
const appOptions = this.props.storeAppOptions; const appOptions = this.props.storeAppOptions;
const appSettings = this.props.storeApplicationSettings; const appSettings = this.props.storeApplicationSettings;
@ -327,8 +330,8 @@ class MainController extends Component {
Common.Utils.Metric.setCurrentMetric(value); Common.Utils.Metric.setCurrentMetric(value);
this.api.asc_SetDocumentUnits((value === Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value===Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); this.api.asc_SetDocumentUnits((value === Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value===Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter));
//me.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(me.onDocumentModifiedChanged, me)); this.api.asc_registerCallback('asc_onDocumentModifiedChanged', this.onDocumentModifiedChanged.bind(this));
//me.api.asc_registerCallback('asc_onDocumentCanSaveChanged', _.bind(me.onDocumentCanSaveChanged, me)); this.api.asc_registerCallback('asc_onDocumentCanSaveChanged', this.onDocumentCanSaveChanged.bind(this));
//if (me.stackLongActions.exist({id: ApplyEditRights, type: Asc.c_oAscAsyncActionType['BlockInteraction']})) { //if (me.stackLongActions.exist({id: ApplyEditRights, type: Asc.c_oAscAsyncActionType['BlockInteraction']})) {
// me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], ApplyEditRights); // me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], ApplyEditRights);
@ -342,6 +345,19 @@ class MainController extends Component {
window.onunload = this.onUnload.bind(this); window.onunload = this.onUnload.bind(this);
} }
onDocumentModifiedChanged () {
const isModified = this.api.asc_isDocumentCanSave();
if (this._state.isDocModified !== isModified) {
this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified());
}
this.updateWindowTitle();
}
onDocumentCanSaveChanged (isCanSave) {
//
}
onBeforeUnload () { onBeforeUnload () {
LocalStorage.save(); LocalStorage.save();
@ -485,6 +501,7 @@ class MainController extends Component {
this.api.asc_registerCallback('asc_onServerVersion', this.onServerVersion.bind(this)); this.api.asc_registerCallback('asc_onServerVersion', this.onServerVersion.bind(this));
this.api.asc_registerCallback('asc_onDocumentName', this.onDocumentName.bind(this)); this.api.asc_registerCallback('asc_onDocumentName', this.onDocumentName.bind(this));
this.api.asc_registerCallback('asc_onPrintUrl', this.onPrintUrl.bind(this)); this.api.asc_registerCallback('asc_onPrintUrl', this.onPrintUrl.bind(this));
this.api.asc_registerCallback('asc_onPrint', this.onPrint.bind(this));
EditorUIController.initThemeColors && EditorUIController.initThemeColors(); EditorUIController.initThemeColors && EditorUIController.initThemeColors();
@ -677,6 +694,14 @@ class MainController extends Component {
} }
} }
onPrint () {
if (!this.props.storeAppOptions.canPrint) return;
if (this.api)
this.api.asc_Print();
Common.component.Analytics.trackEvent('Print');
}
onPrintUrl (url) { onPrintUrl (url) {
if (this.iframePrint) { if (this.iframePrint) {
this.iframePrint.parentNode.removeChild(this.iframePrint); this.iframePrint.parentNode.removeChild(this.iframePrint);

View file

@ -55,6 +55,8 @@ class DownloadController extends Component {
const DownloadWithTranslation = withTranslation()(DownloadController); const DownloadWithTranslation = withTranslation()(DownloadController);
const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequestClose) => { const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequestClose) => {
if ($$('.dlg-adv-options.modal-in').length > 0) return;
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (type == Asc.c_oAscAdvancedOptionsID.TXT) { if (type == Asc.c_oAscAdvancedOptionsID.TXT) {
let picker; let picker;
@ -97,7 +99,8 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest
'</div>' + '</div>' +
'<div id="txt-encoding"></div>' + '<div id="txt-encoding"></div>' +
'</div>', '</div>',
buttons: buttons buttons: buttons,
cssClass: 'dlg-adv-options'
}).open(); }).open();
dialog.on('opened', () => { dialog.on('opened', () => {
picker = f7.picker.create({ picker = f7.picker.create({
@ -122,7 +125,7 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest
const password = document.getElementById('modal-password').value; const password = document.getElementById('modal-password').value;
api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password));
//if (!me._isDocReady) { //if (!me._isDocReady) {
//me.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); //Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument);
//} //}
} }
}]; }];
@ -138,7 +141,8 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest
text: _t.txtProtected, text: _t.txtProtected,
content: content:
'<div class="input-field"><input type="password" name="modal-password" placeholder="' + _t.advDRMPassword + '" id="modal-password"></div>', '<div class="input-field"><input type="password" name="modal-password" placeholder="' + _t.advDRMPassword + '" id="modal-password"></div>',
buttons: buttons buttons: buttons,
cssClass: 'dlg-adv-options'
}).open(); }).open();
} }
}; };