[DE mobile] Refactoring Document Info
This commit is contained in:
parent
0402a93aaf
commit
736412ce23
|
@ -4,22 +4,21 @@ 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();
|
||||||
|
this.getModifiedBy = this.getModifiedBy();
|
||||||
|
this.getCreators = this.getCreators();
|
||||||
}
|
}
|
||||||
|
|
||||||
getDocProps() {
|
getDocProps() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
if (api) {
|
return api.asc_getCoreProps();
|
||||||
let docProps = api.asc_getCoreProps();
|
|
||||||
// console.log(docProps);
|
|
||||||
return docProps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppProps() {
|
getAppProps() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
if (api) {
|
|
||||||
const appProps = api.asc_getAppProps();
|
const appProps = api.asc_getAppProps();
|
||||||
// console.log(appProps);
|
|
||||||
if (appProps) {
|
if (appProps) {
|
||||||
let appName =
|
let appName =
|
||||||
(appProps.asc_getApplication() || "") +
|
(appProps.asc_getApplication() || "") +
|
||||||
|
@ -28,12 +27,9 @@ class DocumentInfoController extends Component {
|
||||||
return appName;
|
return appName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getModified() {
|
getModified() {
|
||||||
const docProps = this.getDocProps();
|
let valueModified = this.docProps.asc_getModified();
|
||||||
if (docProps) {
|
|
||||||
let valueModified = docProps.asc_getModified();
|
|
||||||
|
|
||||||
if (valueModified) {
|
if (valueModified) {
|
||||||
return (
|
return (
|
||||||
|
@ -47,33 +43,23 @@ class DocumentInfoController extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getModifiedBy() {
|
getModifiedBy() {
|
||||||
const docProps = this.getDocProps();
|
let valueModifiedBy = this.docProps.asc_getLastModifiedBy();
|
||||||
if (docProps) {
|
|
||||||
let valueModifiedBy = docProps.asc_getLastModifiedBy();
|
|
||||||
|
|
||||||
if (valueModifiedBy) {
|
if (valueModifiedBy) {
|
||||||
return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy);
|
return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getCreators() {
|
getCreators() {
|
||||||
const docProps = this.getDocProps();
|
return this.docProps.asc_getCreator();
|
||||||
if(docProps) {
|
|
||||||
let valueCreators = docProps.asc_getCreator();
|
|
||||||
return valueCreators;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const api = Common.EditorApi.get();
|
const api = Common.EditorApi.get();
|
||||||
if (api) {
|
|
||||||
api.startGetDocInfo();
|
api.startGetDocInfo();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
@ -81,11 +67,11 @@ class DocumentInfoController extends Component {
|
||||||
getAppProps={this.getAppProps}
|
getAppProps={this.getAppProps}
|
||||||
getModified={this.getModified}
|
getModified={this.getModified}
|
||||||
getModifiedBy={this.getModifiedBy}
|
getModifiedBy={this.getModifiedBy}
|
||||||
getDocProps={this.getDocProps}
|
|
||||||
getCreators={this.getCreators}
|
getCreators={this.getCreators}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default DocumentInfoController;
|
export default DocumentInfoController;
|
|
@ -8,10 +8,10 @@ const PageDocumentInfo = (props) => {
|
||||||
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,
|
||||||
|
@ -21,7 +21,7 @@ const PageDocumentInfo = (props) => {
|
||||||
} = 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>
|
||||||
|
@ -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