From 736412ce236df26d35d4f88547d32d332b881e3f Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 24 Nov 2020 17:03:21 +0300 Subject: [PATCH] [DE mobile] Refactoring Document Info --- .../src/controller/settings/DocumentInfo.jsx | 138 ++++++++---------- .../mobile/src/view/settings/DocumentInfo.jsx | 48 +++--- 2 files changed, 86 insertions(+), 100 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 0918d223b..3f75bdcc8 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -2,90 +2,76 @@ import React, { Component } from "react"; import DocumentInfo from "../../view/settings/DocumentInfo"; class DocumentInfoController extends Component { - constructor(props) { - super(props); - } - - getDocProps() { - const api = Common.EditorApi.get(); - if (api) { - let docProps = api.asc_getCoreProps(); - // console.log(docProps); - return docProps; + constructor(props) { + super(props); + this.docProps = this.getDocProps(); + this.getModified = this.getModified(); + this.getModifiedBy = this.getModifiedBy(); + this.getCreators = this.getCreators(); } - } - getAppProps() { - const api = Common.EditorApi.get(); - if (api) { - const appProps = api.asc_getAppProps(); - // console.log(appProps); - if (appProps) { - let appName = - (appProps.asc_getApplication() || "") + - (appProps.asc_getAppVersion() ? " " : "") + - (appProps.asc_getAppVersion() || ""); - return appName; - } + getDocProps() { + const api = Common.EditorApi.get(); + return api.asc_getCoreProps(); } - } - getModified() { - const docProps = this.getDocProps(); - if (docProps) { - let valueModified = docProps.asc_getModified(); + getAppProps() { + const api = Common.EditorApi.get(); + const appProps = api.asc_getAppProps(); - if (valueModified) { + if (appProps) { + let appName = + (appProps.asc_getApplication() || "") + + (appProps.asc_getAppVersion() ? " " : "") + + (appProps.asc_getAppVersion() || ""); + return appName; + } + } + + getModified() { + let valueModified = this.docProps.asc_getModified(); + + if (valueModified) { + return ( + valueModified.toLocaleString('en', { + year: "numeric", + month: "2-digit", + day: "2-digit", + }) + + " " + + valueModified.toLocaleTimeString('en', { timeStyle: "short" }) + ); + } + } + + getModifiedBy() { + let valueModifiedBy = this.docProps.asc_getLastModifiedBy(); + + if (valueModifiedBy) { + return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); + } + } + + getCreators() { + return this.docProps.asc_getCreator(); + } + + componentDidMount() { + const api = Common.EditorApi.get(); + api.startGetDocInfo(); + } + + render() { return ( - valueModified.toLocaleString('en', { - year: "numeric", - month: "2-digit", - day: "2-digit", - }) + - " " + - valueModified.toLocaleTimeString('en', { timeStyle: "short" }) + ); - } } - } - - getModifiedBy() { - const docProps = this.getDocProps(); - if (docProps) { - let valueModifiedBy = docProps.asc_getLastModifiedBy(); - - if (valueModifiedBy) { - return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); - } - } - } - - getCreators() { - const docProps = this.getDocProps(); - if(docProps) { - let valueCreators = docProps.asc_getCreator(); - return valueCreators; - } - } - - componentDidMount() { - const api = Common.EditorApi.get(); - if (api) { - api.startGetDocInfo(); - } - } - - render() { - return ( - - ); - } } + export default DocumentInfoController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 7be3b80ff..69ac1869b 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -4,26 +4,26 @@ import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react"; import { useTranslation } from "react-i18next"; const PageDocumentInfo = (props) => { - const { t } = useTranslation(); - const _t = t("Settings", { returnObjects: true }); - const storeInfo = props.storeDocumentInfo; - const dataApp = props.getAppProps(); - const dataModified = props.getModified(); - const dataModifiedBy = props.getModifiedBy(); - const creators = props.getCreators(); - console.log(creators); - const { - pageCount, - paragraphCount, - symbolsCount, - symbolsWSCount, - wordsCount, - } = storeInfo.infoObj; - const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); - const isLoaded = storeInfo.isLoaded; - console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount); + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const storeInfo = props.storeDocumentInfo; + const dataApp = props.getAppProps(); + const dataModified = props.getModified; + const dataModifiedBy = props.getModifiedBy; + const creators = props.getCreators; + // console.log(creators); + const { + pageCount, + paragraphCount, + symbolsCount, + symbolsWSCount, + wordsCount, + } = storeInfo.infoObj; + const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); + const isLoaded = storeInfo.isLoaded; + // console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount); - return ( + return ( {_t.textDocumentTitle} @@ -40,11 +40,11 @@ const PageDocumentInfo = (props) => { {_t.textStatistic} - - - - - + + + + + {dataModified && dataModifiedBy ? (