[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";
|
||||
|
||||
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" })
|
||||
<DocumentInfo
|
||||
getAppProps={this.getAppProps}
|
||||
getModified={this.getModified}
|
||||
getModifiedBy={this.getModifiedBy}
|
||||
getCreators={this.getCreators}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
|
@ -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 (
|
||||
<Page>
|
||||
<Navbar title={_t.textDocumentInfo} backLink={_t.textBack} />
|
||||
<BlockTitle>{_t.textDocumentTitle}</BlockTitle>
|
||||
|
@ -40,11 +40,11 @@ const PageDocumentInfo = (props) => {
|
|||
</List>
|
||||
<BlockTitle>{_t.textStatistic}</BlockTitle>
|
||||
<List>
|
||||
<ListItem title="Pages" after={isLoaded ? pageCount : _t.textLoading}></ListItem>
|
||||
<ListItem title="Paragraphs" after={isLoaded ? paragraphCount : _t.textLoading}></ListItem>
|
||||
<ListItem title="Words" after={isLoaded ? wordsCount : _t.textLoading}></ListItem>
|
||||
<ListItem title="Symbols" after={isLoaded ? symbolsCount : _t.textLoading}></ListItem>
|
||||
<ListItem title="Spaces" after={isLoaded ? symbolsWSCount : _t.textLoading}></ListItem>
|
||||
<ListItem title="Pages" after={isLoaded ? String(pageCount) : _t.textLoading}></ListItem>
|
||||
<ListItem title="Paragraphs" after={isLoaded ? String(paragraphCount) : _t.textLoading}></ListItem>
|
||||
<ListItem title="Words" after={isLoaded ? String(wordsCount) : _t.textLoading}></ListItem>
|
||||
<ListItem title="Symbols" after={isLoaded ? String(symbolsCount) : _t.textLoading}></ListItem>
|
||||
<ListItem title="Spaces" after={isLoaded ? String(symbolsWSCount) : _t.textLoading}></ListItem>
|
||||
</List>
|
||||
{dataModified && dataModifiedBy ? (
|
||||
<Fragment>
|
||||
|
|
Loading…
Reference in a new issue