[SSE mobile] Added Spreadsheet Info and App Options

This commit is contained in:
SergeyEzhin 2021-02-25 17:10:28 +03:00
parent 935b7c7d57
commit 2c44e7f3a3
8 changed files with 342 additions and 4 deletions

View file

@ -273,7 +273,19 @@
"textShowNotification": "Show Notification",
"textDisableAllMacrosWithNotification": "Disable all macros with a notification",
"textEnableAll": "Enable All",
"textEnableAllMacrosWithoutNotification": "Enable all macros without a notification"
"textEnableAllMacrosWithoutNotification": "Enable all macros without a notification",
"textSpreadsheetTitle": "Spreadsheet Title",
"textOwner": "Owner",
"textLocation": "Location",
"textUploaded": "Uploaded",
"textTitle": "Title",
"textSubject": "Subject",
"textComment": "Comment",
"textLastModified": "Last Modified",
"textLastModifiedBy": "Last Modified By",
"textCreated": "Created",
"textApplication": "Application",
"textAuthor": "Author"
}
},
"Common": {

View file

@ -4,8 +4,9 @@ import { inject } from "mobx-react";
import { f7 } from 'framework7-react';
import { withTranslation } from 'react-i18next';
import CollaborationController from '../../../../common/mobile/lib/controller/Collaboration.jsx'
import { onAdvancedOptions } from './settings/Download.jsx';
@inject("storeFocusObjects", "storeCellSettings", "storeTextSettings", "storeChartSettings", "storeSpreadsheetSettings")
@inject("storeAppOptions", "storeFocusObjects", "storeCellSettings", "storeTextSettings", "storeChartSettings", "storeSpreadsheetSettings", "storeSpreadsheetInfo")
class MainController extends Component {
constructor(props) {
super(props)
@ -52,6 +53,8 @@ class MainController extends Component {
me.appOptions.user = Common.Utils.fillUserInfo(me.editorConfig.user, me.editorConfig.lang, me.textAnonymous);
me.appOptions.lang = me.editorConfig.lang;
this.props.storeAppOptions.setConfigOptions(this.editorConfig);
// var value = Common.localStorage.getItem("sse-settings-regional");
// if (value!==null)
// this.api.asc_setLocale(parseInt(value));
@ -92,8 +95,10 @@ class MainController extends Component {
let _permissions = Object.assign({}, data.doc.permissions),
_user = new Asc.asc_CUserInfo();
_user.put_Id(this.appOptions.user.id);
_user.put_FullName(this.appOptions.user.fullname);
const _userOptions = this.props.storeAppOptions.user;
_user.put_Id(_userOptions.id);
_user.put_FullName(_userOptions.fullname);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);
@ -124,6 +129,12 @@ class MainController extends Component {
this.api.asc_enableKeyEvents(true);
// Common.SharedSettings.set('document', data.doc);
// Document Info
const storeSpreadsheetInfo = this.props.storeSpreadsheetInfo;
storeSpreadsheetInfo.setDataDoc(this.document);
};
const onEditorPermissions = params => {
@ -131,6 +142,8 @@ class MainController extends Component {
const licType = params.asc_getLicenseType();
me.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
this.props.storeAppOptions.setPermissionOptions(this.document, licType, params, this.permissions);
// 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
@ -258,6 +271,14 @@ class MainController extends Component {
storeSpreadsheetSettings.addSchemes(schemes);
});
// Downloaded Advanced Options
this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => {
const {t} = this.props;
const _t = t("Settings", { returnObjects: true });
onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this.props.storeAppOptions.canRequestClose);
});
}
_onLongActionEnd(type, id) {

View file

@ -0,0 +1,103 @@
import React, { Component } from "react";
import { observer, inject } from "mobx-react";
import SpreadsheetInfo from "../../view/settings/SpreadsheetInfo";
class SpreadsheetInfoController extends Component {
constructor(props) {
super(props);
this.docProps = this.getDocProps();
this.getModified = this.getModified();
this.getModifiedBy = this.getModifiedBy();
this.getCreators = this.getCreators();
this.title = this.getTitle();
this.subject = this.getSubject();
this.description = this.getDescription();
this.getCreated = this.getCreated();
}
getDocProps() {
const api = Common.EditorApi.get();
return api.asc_getCoreProps();
}
getAppProps() {
const api = Common.EditorApi.get();
const appProps = api.asc_getAppProps();
if (appProps) {
let appName =
(appProps.asc_getApplication() || "") +
(appProps.asc_getAppVersion() ? " " : "") +
(appProps.asc_getAppVersion() || "");
return appName;
}
}
getModified() {
let valueModified = this.docProps.asc_getModified();
const _lang = this.props.storeAppOptions.lang;
if (valueModified) {
return (
valueModified.toLocaleString(_lang, {
year: "numeric",
month: "2-digit",
day: "2-digit",
}) +
" " +
valueModified.toLocaleTimeString(_lang, { timeStyle: "short" })
);
}
}
getModifiedBy() {
let valueModifiedBy = this.docProps.asc_getLastModifiedBy();
if (valueModifiedBy) {
return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy);
}
}
getCreators() {
return this.docProps.asc_getCreator();
}
getTitle() {
return this.docProps.asc_getTitle();
}
getSubject() {
return this.docProps.asc_getSubject();
}
getDescription() {
return this.docProps.asc_getDescription();
}
getCreated() {
let value = this.docProps.asc_getCreated();
const _lang = this.props.storeAppOptions.lang;
if(value) {
return value.toLocaleString(_lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleTimeString(_lang, {timeStyle: 'short'});
}
}
render() {
return (
<SpreadsheetInfo
getAppProps={this.getAppProps}
getModified={this.getModified}
getModifiedBy={this.getModifiedBy}
getCreators={this.getCreators}
getCreated={this.getCreated}
title={this.title}
subject={this.subject}
description={this.description}
/>
);
}
}
export default inject("storeAppOptions")(observer(SpreadsheetInfoController));

View file

@ -0,0 +1,58 @@
import {action, observable} from 'mobx';
export class storeAppOptions {
config = {};
@action setConfigOptions (config) {
this.config = config;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
this.isDesktopApp = config.targetApp == 'desktop';
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
this.canOpenRecent = config.recent !== undefined && !this.isDesktopApp;
this.templates = config.templates;
this.recent = config.recent;
this.createUrl = config.createUrl;
this.lang = config.lang;
this.location = (typeof (config.location) == 'string') ? config.location.toLowerCase() : '';
this.region = (typeof (config.region) == 'string') ? config.region.toLowerCase() : config.region;
this.sharingSettingsUrl = config.sharingSettingsUrl;
this.fileChoiceUrl = config.fileChoiceUrl;
this.isEditDiagram = config.mode == 'editdiagram';
this.isEditMailMerge = config.mode == 'editmerge';
this.mergeFolderUrl = config.mergeFolderUrl;
this.canAnalytics = false;
this.canRequestClose = config.canRequestClose;
this.customization = config.customization;
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
this.canBack = this.canBackToFolder === true;
this.canPlugins = false;
}
@action setPermissionOptions (document, licType, params, permissions) {
permissions.edit = params.asc_getRights() !== Asc.c_oRights.Edit ? false : true;
this.canAutosave = true;
this.canAnalytics = params.asc_getIsAnalyticsEnable();
this.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
this.isLightVersion = params.asc_getIsLight();
this.canCoAuthoring = !this.isLightVersion;
this.isOffline = Common.EditorApi.get().asc_isOffline();
this.canRequestEditRights = this.config.canRequestEditRights;
this.canEdit = permissions.edit !== false && // can edit or review
(this.config.canRequestEditRights || this.config.mode !== 'view') && true; // if mode=="view" -> canRequestEditRights must be defined
// (!this.isReviewOnly || this.canLicense) && // if isReviewOnly==true -> canLicense must be true
// true /*isSupportEditFeature*/;
this.isEdit = (this.canLicense || this.isEditDiagram || this.isEditMailMerge) && permissions.edit !== false && this.config.mode !== 'view' && true;
this.canComments = this.canLicense && (permissions.comment === undefined ? this.isEdit : permissions.comment) && (this.config.mode !== 'view');
this.canComments = this.canComments && !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canViewComments = this.canComments || !((typeof (this.customization) == 'object') && this.customization.comments===false);
this.canEditComments = this.isOffline || !(typeof (this.customization) == 'object' && this.customization.commentAuthorOnly);
this.canChat = this.canLicense && !this.isOffline && !((typeof (this.customization) == 'object') && this.customization.chat === false);
this.canPrint = (permissions.print !== false);
this.isRestrictedEdit = !this.isEdit && this.canComments;
this.trialMode = params.asc_getLicenseMode();
this.canDownloadOrigin = permissions.download !== false;
this.canDownload = permissions.download !== false;
this.canBranding = params.asc_getCustomization();
this.canBrandingExt = params.asc_getCanBranding() && (typeof this.customization == 'object');
this.canUseReviewPermissions = this.canLicense && this.customization && this.customization.reviewPermissions && (typeof (this.customization.reviewPermissions) == 'object');
}
}

View file

@ -9,6 +9,8 @@ import {storeTextSettings} from "./textSettings";
import {storeApplicationSettings} from "./applicationSettings";
import {storeShapeSettings} from "./shapeSettings";
import {storeCellSettings} from "./cellSettings";
import {storeSpreadsheetInfo} from "./spreadsheetInfo";
import {storeAppOptions} from "./appOptions";
// import {storeImageSettings} from "./imageSettings";
// import {storeTableSettings} from "./tableSettings";
import {storeChartSettings} from "./chartSettings";
@ -22,6 +24,8 @@ export const stores = {
sheets: new storeWorksheets(),
storeFunctions: new storeFunctions(),
storeTextSettings: new storeTextSettings(),
storeSpreadsheetInfo: new storeSpreadsheetInfo(),
storeAppOptions: new storeAppOptions(),
// storeParagraphSettings: new storeParagraphSettings(),
storeShapeSettings: new storeShapeSettings(),
storeChartSettings: new storeChartSettings(),

View file

@ -0,0 +1,10 @@
import {action, observable, computed} from 'mobx';
export class storeSpreadsheetInfo {
@observable dataDoc;
@action setDataDoc(obj) {
this.dataDoc = obj;
}
}

View file

@ -5,6 +5,7 @@ import {f7} from 'framework7-react';
import {Device} from '../../../../../common/mobile/utils/device';
import SpreadsheetSettingsController from '../../controller/settings/SpreadsheetSettings.jsx';
import ApplicationSettingsController from '../../controller/settings/ApplicationSettings.jsx';
import SpreadsheetInfoController from '../../controller/settings/SpreadsheetInfo.jsx';
import {DownloadWithTranslation} from '../../controller/settings/Download.jsx';
import {SpreadsheetColorSchemes, SpreadsheetFormats, SpreadsheetMargins} from './SpreadsheetSettings.jsx';
import {MacrosSettings, RegionalSettings, FormulaLanguage} from './ApplicationSettings.jsx';
@ -49,6 +50,10 @@ const routes = [
{
path: '/formula-languages/',
component: FormulaLanguage
},
{
path: '/spreadsheet-info/',
component: SpreadsheetInfoController
}
];

View file

@ -0,0 +1,125 @@
import React, {Fragment} from "react";
import { observer, inject } from "mobx-react";
import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react";
import { useTranslation } from "react-i18next";
const PageSpreadsheetInfo = (props) => {
const { t } = useTranslation();
const _t = t("View.Settings", { returnObjects: true });
const storeSpreadsheetInfo = props.storeSpreadsheetInfo;
const dataApp = props.getAppProps();
const dataModified = props.getModified;
const dataModifiedBy = props.getModifiedBy;
const creators = props.getCreators;
const dataDoc = storeSpreadsheetInfo.dataDoc;
return (
<Page>
<Navbar title={_t.textSpreadsheetInfo} backLink={_t.textBack} />
{dataDoc.title ? (
<Fragment>
<BlockTitle>{_t.textSpreadsheetTitle}</BlockTitle>
<List>
<ListItem title={dataDoc.title}></ListItem>
</List>
</Fragment>
) : null}
{dataDoc.info.author || dataDoc.info.owner ? (
<Fragment>
<BlockTitle>{_t.textOwner}</BlockTitle>
<List>
<ListItem title={dataDoc.info.author || dataDoc.info.owner}></ListItem>
</List>
</Fragment>
) : null}
{dataDoc.info.folder ? (
<Fragment>
<BlockTitle>{_t.textLocation}</BlockTitle>
<List>
<ListItem title={dataDoc.info.folder}></ListItem>
</List>
</Fragment>
) : null}
{dataDoc.info.uploaded || dataDoc.info.created ? (
<Fragment>
<BlockTitle>{_t.textUploaded}</BlockTitle>
<List>
<ListItem title={dataDoc.info.uploaded || dataDoc.info.created}></ListItem>
</List>
</Fragment>
) : null}
{props.title ? (
<Fragment>
<BlockTitle>{_t.textTitle}</BlockTitle>
<List>
<ListItem title={props.title}></ListItem>
</List>
</Fragment>
) : null}
{props.subject ? (
<Fragment>
<BlockTitle>{_t.textSubject}</BlockTitle>
<List>
<ListItem title={props.subject}></ListItem>
</List>
</Fragment>
) : null}
{props.description ? (
<Fragment>
<BlockTitle>{_t.textComment}</BlockTitle>
<List>
<ListItem title={props.description}></ListItem>
</List>
</Fragment>
) : null}
{dataModified ? (
<Fragment>
<BlockTitle>{_t.textLastModified}</BlockTitle>
<List>
<ListItem title={dataModified}></ListItem>
</List>
</Fragment>
) : null}
{dataModifiedBy ? (
<Fragment>
<BlockTitle>{_t.textLastModifiedBy}</BlockTitle>
<List>
<ListItem title={dataModifiedBy}></ListItem>
</List>
</Fragment>
) : null}
{props.getCreated ? (
<Fragment>
<BlockTitle>{_t.textCreated}</BlockTitle>
<List>
<ListItem title={props.getCreated}></ListItem>
</List>
</Fragment>
) : null}
{dataApp ? (
<Fragment>
<BlockTitle>{_t.textApplication}</BlockTitle>
<List>
<ListItem title={dataApp}></ListItem>
</List>
</Fragment>
) : null}
{creators ? (
<Fragment>
<BlockTitle>{_t.textAuthor}</BlockTitle>
<List>
{
creators.split(/\s*[,;]\s*/).map(item => {
return <ListItem title={item}></ListItem>
})
}
</List>
</Fragment>
) : null}
</Page>
);
};
const SpreadsheetInfo = inject("storeSpreadsheetInfo")(observer(PageSpreadsheetInfo));
export default SpreadsheetInfo;