diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index c414be24b..b2f1b3823 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -658,6 +658,17 @@ "textRightToLeft": "Right To Left", "textSearch": "Search", "textSettings": "Settings", + "textProtectDocument": "Protect Document", + "textUnprotect": "Unprotect", + "textSetPassword": "Set Password", + "textTypeEditing": "Type Of Editing", + "textNoChanges": "No changes (Read only)", + "textFillingForms": "Filling forms", + "textTrackedChanges": "Tracked changes", + "textPassword": "Password", + "textVerify": "Verify", + "textSave": "Save", + "textRequired": "Required", "textShowNotification": "Show Notification", "textSpaces": "Spaces", "textSpellcheck": "Spell Checking", diff --git a/apps/documenteditor/mobile/src/controller/settings/Protection.jsx b/apps/documenteditor/mobile/src/controller/settings/Protection.jsx new file mode 100644 index 000000000..d41b9e8ff --- /dev/null +++ b/apps/documenteditor/mobile/src/controller/settings/Protection.jsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { Device } from '../../../../../common/mobile/utils/device'; +// import { withTranslation } from 'react-i18next'; +import { f7 } from "framework7-react"; +import ProtectionView from '../../view/settings/Protection'; + +class ProtectionController extends React.Component { + constructor(props) { + super(props); + this.onProtectDocument = this.onProtectDocument.bind(this); + } + + closeModal() { + if (Device.phone) { + f7.sheet.close('.settings-popup', false); + } else { + f7.popover.close('#settings-popover', false); + } + }; + + onProtectDocument(typeProtection, password) { + const api = Common.EditorApi.get(); + const protection = api.asc_getDocumentProtection() || new AscCommonWord.CDocProtect(); + + protection.asc_setEditType(typeProtection); + protection.asc_setPassword(password); + api.asc_setDocumentProtection(protection); + + this.closeModal(); + }; + + render() { + return + } +} + +export default ProtectionController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/less/icons-common.less b/apps/documenteditor/mobile/src/less/icons-common.less index 6d834af08..8651a11b2 100644 --- a/apps/documenteditor/mobile/src/less/icons-common.less +++ b/apps/documenteditor/mobile/src/less/icons-common.less @@ -54,4 +54,10 @@ i.icon { height: 22px; .encoded-svg-background(''); } + + &.icon-protect-document { + width: 22px; + height: 22px; + .encoded-svg-mask('') + } } \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/less/icons-material.less b/apps/documenteditor/mobile/src/less/icons-material.less index 2110bff3c..9d3adb474 100644 --- a/apps/documenteditor/mobile/src/less/icons-material.less +++ b/apps/documenteditor/mobile/src/less/icons-material.less @@ -79,7 +79,7 @@ height: 24px; .encoded-svg-mask('', @toolbar-icons); } - &.icon-back-reader-mode { + &.icon-check { width: 24px; height: 24px; .encoded-svg-mask('', @toolbar-icons); @@ -92,6 +92,11 @@ height: 24px; .encoded-svg-mask('', @fill-white); } + &.icon-check { + width: 24px; + height: 24px; + .encoded-svg-mask(''); + } &.icon-expand-down { width: 17px; height: 17px; diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index 8d4fae065..851635800 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -32,7 +32,10 @@ export class storeAppOptions { changeMobileView: action, isProtected: observable, - setProtection: action + setProtection: action, + + typeProtection: observable, + setTypeProtection: action }); } @@ -43,6 +46,11 @@ export class storeAppOptions { this.isProtected = value; } + typeProtection = 3; + setTypeProtection(type) { + this.typeProtection = type; + } + isMobileView = true; changeMobileView() { this.isMobileView = !this.isMobileView; diff --git a/apps/documenteditor/mobile/src/view/Toolbar.jsx b/apps/documenteditor/mobile/src/view/Toolbar.jsx index 619ee7f69..540ecc6ae 100644 --- a/apps/documenteditor/mobile/src/view/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/view/Toolbar.jsx @@ -44,7 +44,7 @@ const ToolbarView = props => { return ( - {!isViewer && props.turnOnViewerMode()}>} + {!isViewer && props.turnOnViewerMode()}>} {(props.isShowBack && isViewer) && } {(Device.ios && props.isEdit && !isViewer) && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({ disabledUndo: !props.isCanUndo || isDisconnected, diff --git a/apps/documenteditor/mobile/src/view/settings/Protection.jsx b/apps/documenteditor/mobile/src/view/settings/Protection.jsx new file mode 100644 index 000000000..db9d984e3 --- /dev/null +++ b/apps/documenteditor/mobile/src/view/settings/Protection.jsx @@ -0,0 +1,83 @@ +import React, { useState } from 'react'; +import { observer, inject } from "mobx-react"; +import { Device } from '../../../../../common/mobile/utils/device'; +import { Page, Navbar, List, ListItem, BlockTitle, Toggle, NavRight, f7, Link, ListInput, Icon, Block } from "framework7-react"; +import { useTranslation } from "react-i18next"; + +const ProtectionView = inject("storeAppOptions")(observer(props => { + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const isIos = Device.ios; + const appOptions = props.storeAppOptions; + const typeProtection = appOptions.typeProtection; + const [isPassword, setPassword] = useState(false); + const [password, changePassword] = useState(''); + const [passwordRepeat, repeatPassword] = useState(''); + const isDisabledProtection = isPassword && ((!password.length || !passwordRepeat.length) || password !== passwordRepeat); + + return ( + + + + { + props.onProtectDocument(typeProtection, password); + }}> + {Device.android && } + + + + + + { + setPassword(!isPassword); + }} /> + + + {isPassword && + <> + + changePassword(e.target.value)} + className={isIos ? 'list-input-right' : ''} + /> + repeatPassword(e.target.value)} + className={isIos ? 'list-input-right' : ''} + /> + + +

If the password is forgotten or lost, it cannot be recovered.

+
+ + } + {t('Settings.textTypeEditing')} + + { + appOptions.setTypeProtection(Asc.c_oAscEDocProtect.ReadOnly); + }}> + { + appOptions.setTypeProtection(Asc.c_oAscEDocProtect.Forms); + }}> + { + appOptions.setTypeProtection(Asc.c_oAscEDocProtect.TrackedChanges); + }}> + { + appOptions.setTypeProtection(Asc.c_oAscEDocProtect.Comments); + }}> + + +

Allow only this type of editing in the document.

+
+
+ ) +})); + +export default ProtectionView; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Settings.jsx b/apps/documenteditor/mobile/src/view/settings/Settings.jsx index 9ffb8d90a..d6cf9d98a 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -14,6 +14,7 @@ import { MacrosSettings, Direction } from "./ApplicationSettings"; import About from '../../../../../common/mobile/lib/view/About'; import NavigationController from '../../controller/settings/Navigation'; import SharingSettings from "../../../../../common/mobile/lib/view/SharingSettings"; +import ProtectionController from '../../controller/settings/Protection'; const routes = [ { @@ -65,17 +66,21 @@ const routes = [ }, // Direction - { path: '/direction/', component: Direction }, // Sharing Settings - { path: '/sharing-settings/', component: SharingSettings + }, + + // Protection + { + path: '/protection-document/', + component: ProtectionController } ]; @@ -150,6 +155,9 @@ const SettingsList = inject("storeAppOptions", "storeReview")(observer(props => } + + + { if(Device.phone) { onOpenNavigation();