[DE mobile] Refactoring Document Info
This commit is contained in:
parent
0402a93aaf
commit
736412ce23
|
@ -2,90 +2,76 @@ import React, { Component } from "react";
|
||||||
import DocumentInfo from "../../view/settings/DocumentInfo";
|
import DocumentInfo from "../../view/settings/DocumentInfo";
|
||||||
|
|
||||||
class DocumentInfoController extends Component {
|
class DocumentInfoController extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
this.docProps = this.getDocProps();
|
||||||
|
this.getModified = this.getModified();
|
||||||
getDocProps() {
|
this.getModifiedBy = this.getModifiedBy();
|
||||||
const api = Common.EditorApi.get();
|
this.getCreators = this.getCreators();
|
||||||
if (api) {
|
|
||||||
let docProps = api.asc_getCoreProps();
|
|
||||||
// console.log(docProps);
|
|
||||||
return docProps;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getAppProps() {
|
getDocProps() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
if (api) {
|
return api.asc_getCoreProps();
|
||||||
const appProps = api.asc_getAppProps();
|
|
||||||
// console.log(appProps);
|
|
||||||
if (appProps) {
|
|
||||||
let appName =
|
|
||||||
(appProps.asc_getApplication() || "") +
|
|
||||||
(appProps.asc_getAppVersion() ? " " : "") +
|
|
||||||
(appProps.asc_getAppVersion() || "");
|
|
||||||
return appName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getModified() {
|
getAppProps() {
|
||||||
const docProps = this.getDocProps();
|
const api = Common.EditorApi.get();
|
||||||
if (docProps) {
|
const appProps = api.asc_getAppProps();
|
||||||
let valueModified = docProps.asc_getModified();
|
|
||||||
|
|
||||||
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 (
|
return (
|
||||||
valueModified.toLocaleString('en', {
|
<DocumentInfo
|
||||||
year: "numeric",
|
getAppProps={this.getAppProps}
|
||||||
month: "2-digit",
|
getModified={this.getModified}
|
||||||
day: "2-digit",
|
getModifiedBy={this.getModifiedBy}
|
||||||
}) +
|
getCreators={this.getCreators}
|
||||||
" " +
|
/>
|
||||||
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 (
|
|
||||||
<DocumentInfo
|
|
||||||
getAppProps={this.getAppProps}
|
|
||||||
getModified={this.getModified}
|
|
||||||
getModifiedBy={this.getModifiedBy}
|
|
||||||
getDocProps={this.getDocProps}
|
|
||||||
getCreators={this.getCreators}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default DocumentInfoController;
|
export default DocumentInfoController;
|
|
@ -4,26 +4,26 @@ import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const PageDocumentInfo = (props) => {
|
const PageDocumentInfo = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const _t = t("Settings", { returnObjects: true });
|
const _t = t("Settings", { returnObjects: true });
|
||||||
const storeInfo = props.storeDocumentInfo;
|
const storeInfo = props.storeDocumentInfo;
|
||||||
const dataApp = props.getAppProps();
|
const dataApp = props.getAppProps();
|
||||||
const dataModified = props.getModified();
|
const dataModified = props.getModified;
|
||||||
const dataModifiedBy = props.getModifiedBy();
|
const dataModifiedBy = props.getModifiedBy;
|
||||||
const creators = props.getCreators();
|
const creators = props.getCreators;
|
||||||
console.log(creators);
|
// console.log(creators);
|
||||||
const {
|
const {
|
||||||
pageCount,
|
pageCount,
|
||||||
paragraphCount,
|
paragraphCount,
|
||||||
symbolsCount,
|
symbolsCount,
|
||||||
symbolsWSCount,
|
symbolsWSCount,
|
||||||
wordsCount,
|
wordsCount,
|
||||||
} = storeInfo.infoObj;
|
} = storeInfo.infoObj;
|
||||||
const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc));
|
const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc));
|
||||||
const isLoaded = storeInfo.isLoaded;
|
const isLoaded = storeInfo.isLoaded;
|
||||||
console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount);
|
// console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Navbar title={_t.textDocumentInfo} backLink={_t.textBack} />
|
<Navbar title={_t.textDocumentInfo} backLink={_t.textBack} />
|
||||||
<BlockTitle>{_t.textDocumentTitle}</BlockTitle>
|
<BlockTitle>{_t.textDocumentTitle}</BlockTitle>
|
||||||
|
@ -40,11 +40,11 @@ const PageDocumentInfo = (props) => {
|
||||||
</List>
|
</List>
|
||||||
<BlockTitle>{_t.textStatistic}</BlockTitle>
|
<BlockTitle>{_t.textStatistic}</BlockTitle>
|
||||||
<List>
|
<List>
|
||||||
<ListItem title="Pages" after={isLoaded ? pageCount : _t.textLoading}></ListItem>
|
<ListItem title="Pages" after={isLoaded ? String(pageCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title="Paragraphs" after={isLoaded ? paragraphCount : _t.textLoading}></ListItem>
|
<ListItem title="Paragraphs" after={isLoaded ? String(paragraphCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title="Words" after={isLoaded ? wordsCount : _t.textLoading}></ListItem>
|
<ListItem title="Words" after={isLoaded ? String(wordsCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title="Symbols" after={isLoaded ? symbolsCount : _t.textLoading}></ListItem>
|
<ListItem title="Symbols" after={isLoaded ? String(symbolsCount) : _t.textLoading}></ListItem>
|
||||||
<ListItem title="Spaces" after={isLoaded ? symbolsWSCount : _t.textLoading}></ListItem>
|
<ListItem title="Spaces" after={isLoaded ? String(symbolsWSCount) : _t.textLoading}></ListItem>
|
||||||
</List>
|
</List>
|
||||||
{dataModified && dataModifiedBy ? (
|
{dataModified && dataModifiedBy ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|
Loading…
Reference in a new issue