From 2c44e7f3a3ca87b6fe660676c02f317404bd16e5 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 25 Feb 2021 17:10:28 +0300 Subject: [PATCH] [SSE mobile] Added Spreadsheet Info and App Options --- apps/spreadsheeteditor/mobile/locale/en.json | 14 +- .../mobile/src/controller/Main.jsx | 27 +++- .../controller/settings/SpreadsheetInfo.jsx | 103 +++++++++++++++ .../mobile/src/store/appOptions.js | 58 ++++++++ .../mobile/src/store/mainStore.js | 4 + .../mobile/src/store/spreadsheetInfo.js | 10 ++ .../mobile/src/view/settings/Settings.jsx | 5 + .../src/view/settings/SpreadsheetInfo.jsx | 125 ++++++++++++++++++ 8 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 apps/spreadsheeteditor/mobile/src/controller/settings/SpreadsheetInfo.jsx create mode 100644 apps/spreadsheeteditor/mobile/src/store/appOptions.js create mode 100644 apps/spreadsheeteditor/mobile/src/store/spreadsheetInfo.js create mode 100644 apps/spreadsheeteditor/mobile/src/view/settings/SpreadsheetInfo.jsx diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 0f7ab8d02..b5fa8b4a1 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -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": { diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 4a834e813..f92f57a99 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -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) { diff --git a/apps/spreadsheeteditor/mobile/src/controller/settings/SpreadsheetInfo.jsx b/apps/spreadsheeteditor/mobile/src/controller/settings/SpreadsheetInfo.jsx new file mode 100644 index 000000000..238036bcd --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/controller/settings/SpreadsheetInfo.jsx @@ -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 ( + + ); + } +} + + +export default inject("storeAppOptions")(observer(SpreadsheetInfoController)); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/store/appOptions.js b/apps/spreadsheeteditor/mobile/src/store/appOptions.js new file mode 100644 index 000000000..16cb50352 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/store/appOptions.js @@ -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'); + } +} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/store/mainStore.js b/apps/spreadsheeteditor/mobile/src/store/mainStore.js index c7d17b90d..c5b523722 100644 --- a/apps/spreadsheeteditor/mobile/src/store/mainStore.js +++ b/apps/spreadsheeteditor/mobile/src/store/mainStore.js @@ -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(), diff --git a/apps/spreadsheeteditor/mobile/src/store/spreadsheetInfo.js b/apps/spreadsheeteditor/mobile/src/store/spreadsheetInfo.js new file mode 100644 index 000000000..c1c4b27f6 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/store/spreadsheetInfo.js @@ -0,0 +1,10 @@ +import {action, observable, computed} from 'mobx'; + +export class storeSpreadsheetInfo { + + @observable dataDoc; + + @action setDataDoc(obj) { + this.dataDoc = obj; + } +} \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx index 2d79a71e9..a994ff86c 100644 --- a/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/settings/Settings.jsx @@ -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 } ]; diff --git a/apps/spreadsheeteditor/mobile/src/view/settings/SpreadsheetInfo.jsx b/apps/spreadsheeteditor/mobile/src/view/settings/SpreadsheetInfo.jsx new file mode 100644 index 000000000..294e5ac43 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/src/view/settings/SpreadsheetInfo.jsx @@ -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 ( + + + {dataDoc.title ? ( + + {_t.textSpreadsheetTitle} + + + + + ) : null} + {dataDoc.info.author || dataDoc.info.owner ? ( + + {_t.textOwner} + + + + + ) : null} + {dataDoc.info.folder ? ( + + {_t.textLocation} + + + + + ) : null} + {dataDoc.info.uploaded || dataDoc.info.created ? ( + + {_t.textUploaded} + + + + + ) : null} + {props.title ? ( + + {_t.textTitle} + + + + + ) : null} + {props.subject ? ( + + {_t.textSubject} + + + + + ) : null} + {props.description ? ( + + {_t.textComment} + + + + + ) : null} + {dataModified ? ( + + {_t.textLastModified} + + + + + ) : null} + {dataModifiedBy ? ( + + {_t.textLastModifiedBy} + + + + + ) : null} + {props.getCreated ? ( + + {_t.textCreated} + + + + + ) : null} + {dataApp ? ( + + {_t.textApplication} + + + + + ) : null} + {creators ? ( + + {_t.textAuthor} + + { + creators.split(/\s*[,;]\s*/).map(item => { + return + }) + } + + + ) : null} + + ); +}; + +const SpreadsheetInfo = inject("storeSpreadsheetInfo")(observer(PageSpreadsheetInfo)); + +export default SpreadsheetInfo; \ No newline at end of file