From 25d6f46863d36ef47db470d87bb923b7b4e4cb01 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 15 Dec 2020 00:13:38 +0300 Subject: [PATCH] [PE mobile] Maked Presentation Info --- apps/presentationeditor/mobile/locale/en.json | 15 ++- .../mobile/src/controller/Main.jsx | 7 + .../controller/settings/PresentationInfo.jsx | 101 ++++++++++++++ .../mobile/src/store/mainStore.js | 4 +- .../mobile/src/store/presentationInfo.js | 10 ++ .../src/view/settings/PresentationInfo.jsx | 125 ++++++++++++++++++ .../mobile/src/view/settings/Settings.jsx | 5 + 7 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 apps/presentationeditor/mobile/src/controller/settings/PresentationInfo.jsx create mode 100644 apps/presentationeditor/mobile/src/store/presentationInfo.js create mode 100644 apps/presentationeditor/mobile/src/view/settings/PresentationInfo.jsx diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json index 4988d8b44..d05255db3 100644 --- a/apps/presentationeditor/mobile/locale/en.json +++ b/apps/presentationeditor/mobile/locale/en.json @@ -48,7 +48,20 @@ "textShowNotification": "Show Notification", "textDisableAllMacrosWithNotification": "Disable all macros with notification", "textEnableAll": "Enable All", - "textEnableAllMacrosWithoutNotification": "Enable all macros without notification" + "textEnableAllMacrosWithoutNotification": "Enable all macros without notification", + "textLocation": "Location", + "textTitle": "Title", + "textSubject": "Subject", + "textComment": "Comment", + "textCreated": "Created", + "textLastModifiedBy": "Last Modified By", + "textLastModified": "Last Modified", + "textApplication": "Application", + "textLoading": "Loading...", + "textAuthor": "Author", + "textPresentationTitle": "Presentation Title", + "textOwner": "Owner", + "textUploaded": "Uploaded" } } } \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 06c2b87c1..3c48de037 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -4,6 +4,7 @@ import { inject } from "mobx-react"; import { withTranslation } from 'react-i18next'; import CollaborationController from '../../../../common/mobile/lib/controller/Collaboration.jsx' +@inject("storePresentationInfo") class MainController extends Component { constructor(props) { super(props) @@ -81,6 +82,12 @@ class MainController extends Component { this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); + // Presentation Info + + const storePresentationInfo = this.props.storePresentationInfo; + + storePresentationInfo.setDataDoc(this.document); + // Common.SharedSettings.set('document', data.doc); // if (data.doc) { diff --git a/apps/presentationeditor/mobile/src/controller/settings/PresentationInfo.jsx b/apps/presentationeditor/mobile/src/controller/settings/PresentationInfo.jsx new file mode 100644 index 000000000..720a9d815 --- /dev/null +++ b/apps/presentationeditor/mobile/src/controller/settings/PresentationInfo.jsx @@ -0,0 +1,101 @@ +import React, { Component } from "react"; +import PresentationInfo from "../../view/settings/PresentationInfo"; + +class PresentationInfoController 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("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(); + } + + 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(); + + if(value) { + return value.toLocaleString("en", {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleTimeString("en", {timeStyle: 'short'}); + } + } + + render() { + return ( + + ); + } +} + + +export default PresentationInfoController; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/store/mainStore.js b/apps/presentationeditor/mobile/src/store/mainStore.js index 3a22172b7..759968b72 100644 --- a/apps/presentationeditor/mobile/src/store/mainStore.js +++ b/apps/presentationeditor/mobile/src/store/mainStore.js @@ -3,6 +3,7 @@ // import {storeFocusObjects} from "./focusObjects"; import {storeUsers} from '../../../../common/mobile/lib/store/users'; import {storeApplicationSettings} from './applicationSettings'; +import {storePresentationInfo} from './presentationInfo'; // import {storeTextSettings} from "./textSettings"; // import {storeParagraphSettings} from "./paragraphSettings"; // import {storeShapeSettings} from "./shapeSettings"; @@ -14,7 +15,8 @@ export const stores = { // storeFocusObjects: new storeFocusObjects(), // storeDocumentSettings: new storeDocumentSettings(), users: new storeUsers(), - storeApplicationSettings: new storeApplicationSettings() + storeApplicationSettings: new storeApplicationSettings(), + storePresentationInfo: new storePresentationInfo() // storeTextSettings: new storeTextSettings(), // storeParagraphSettings: new storeParagraphSettings(), // storeShapeSettings: new storeShapeSettings(), diff --git a/apps/presentationeditor/mobile/src/store/presentationInfo.js b/apps/presentationeditor/mobile/src/store/presentationInfo.js new file mode 100644 index 000000000..a46d0ef5a --- /dev/null +++ b/apps/presentationeditor/mobile/src/store/presentationInfo.js @@ -0,0 +1,10 @@ +import { action, observable } from "mobx"; + +export class storePresentationInfo { + + @observable dataDoc; + + @action setDataDoc(obj) { + this.dataDoc = obj; + } +} \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/settings/PresentationInfo.jsx b/apps/presentationeditor/mobile/src/view/settings/PresentationInfo.jsx new file mode 100644 index 000000000..0bc1207b3 --- /dev/null +++ b/apps/presentationeditor/mobile/src/view/settings/PresentationInfo.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 PagePresentationInfo = (props) => { + const { t } = useTranslation(); + const _t = t("View.Settings", { returnObjects: true }); + const storeInfo = props.storePresentationInfo; + const dataApp = props.getAppProps(); + const dataModified = props.getModified; + const dataModifiedBy = props.getModifiedBy; + const creators = props.getCreators; + const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); + + return ( + + + {dataDoc.title ? ( + + {_t.textPresentationTitle} + + + + + ) : 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 PresentationInfo = inject("storePresentationInfo")(observer(PagePresentationInfo)); + +export default PresentationInfo; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/settings/Settings.jsx b/apps/presentationeditor/mobile/src/view/settings/Settings.jsx index fb1e66dbf..e5dce7ba1 100644 --- a/apps/presentationeditor/mobile/src/view/settings/Settings.jsx +++ b/apps/presentationeditor/mobile/src/view/settings/Settings.jsx @@ -5,6 +5,7 @@ import {f7} from 'framework7-react'; import {Device} from '../../../../../common/mobile/utils/device'; import ApplicationSettingsController from "../../controller/settings/ApplicationSettings"; import { MacrosSettings } from "./ApplicationSettings"; +import PresentationInfoController from "../../controller/settings/PresentationInfo"; const routes = [ { @@ -18,6 +19,10 @@ const routes = [ { path: '/macros-settings/', component: MacrosSettings + }, + { + path: '/presentation-info/', + component: PresentationInfoController } /*{ path: '/presentation-settings/',