diff --git a/apps/common/mobile/resources/less/comments.less b/apps/common/mobile/resources/less/comments.less index d74217ad02..38aa914e0e 100644 --- a/apps/common/mobile/resources/less/comments.less +++ b/apps/common/mobile/resources/less/comments.less @@ -233,7 +233,7 @@ overflow: auto; .item-content .item-input-wrap::after { - background-color: @text-normal; + background-color: @brandColor; } } diff --git a/apps/common/mobile/resources/less/common.less b/apps/common/mobile/resources/less/common.less index aa23c23cae..0fef8ea349 100644 --- a/apps/common/mobile/resources/less/common.less +++ b/apps/common/mobile/resources/less/common.less @@ -1111,7 +1111,10 @@ input[type="number"]::-webkit-inner-spin-button { line-height: 16px; } - +// Inputs List +.block-title + .list, .block-title + .block, .block-title + .card, .block-title + .timeline, .block-title + .block-header { + margin: 0; +} diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 8100e5426e..40d6c4b376 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -800,14 +800,18 @@ class MainController extends Component { let textWarningDialog; switch(props.type) { - case Asc.c_oAscEDocProtect.ReadOnly: - textWarningDialog = t('Main.textDialogProtectedOnlyView') + case Asc.c_oAscEDocProtect.ReadOnly: + textWarningDialog = t('Main.textDialogProtectedOnlyView'); + break; case Asc.c_oAscEDocProtect.Comments: - textWarningDialog = t('Main.textDialogProtectedEditComments') + textWarningDialog = t('Main.textDialogProtectedEditComments'); + break; case Asc.c_oAscEDocProtect.TrackedChanges: textWarningDialog = t('Main.textDialogProtectedChangesTracked') + break; case Asc.c_oAscEDocProtect.Forms: - textWarningDialog = t('Main.textDialogProtectedFillForms') + textWarningDialog = t('Main.textDialogProtectedFillForms'); + break; } storeAppOptions.setProtection(isProtected); diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx index 1a7743e453..2fd08ed41d 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentProtection.jsx @@ -25,6 +25,7 @@ class ProtectionDocumentController extends React.Component { const protection = api.asc_getDocumentProtection() || new AscCommonWord.CDocProtect(); appOptions.setProtection(true); + appOptions.setTypeProtection(typeProtection); if(typeProtection !== Asc.c_oAscEDocProtect.TrackedChanges && !isViewer) { appOptions.changeViewerMode(); diff --git a/apps/documenteditor/mobile/src/controller/settings/Protection.jsx b/apps/documenteditor/mobile/src/controller/settings/Protection.jsx index 36f72d3edb..cf95904e25 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Protection.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Protection.jsx @@ -49,6 +49,7 @@ class ProtectionController extends React.Component { if (!propsProtection) propsProtection = new AscCommonWord.CDocProtect(); + appOptions.setTypeProtection(null); propsProtection.asc_setEditType(Asc.c_oAscEDocProtect.None); api.asc_setDocumentProtection(propsProtection); } diff --git a/apps/documenteditor/mobile/src/controller/settings/Settings.jsx b/apps/documenteditor/mobile/src/controller/settings/Settings.jsx index 8a319d35b6..eac911dbab 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Settings.jsx @@ -3,11 +3,12 @@ import { useTranslation } from 'react-i18next'; import {f7} from 'framework7-react'; import { observer, inject } from "mobx-react"; import {Device} from '../../../../../common/mobile/utils/device'; - import SettingsView from "../../view/settings/Settings"; import {LocalStorage} from "../../../../../common/mobile/utils/LocalStorage.mjs"; const Settings = props => { + const { t } = useTranslation(); + useEffect(() => { if ( Device.phone ) { f7.popup.open('.settings-popup'); @@ -92,6 +93,52 @@ const Settings = props => { api.ChangeReaderMode(); }; + const onProtectClick = () => { + const api = Common.EditorApi.get(); + const appOptions = props.storeAppOptions; + const isProtected = appOptions.isProtected; + let propsProtection = api.asc_getDocumentProtection(); + const isPassword = propsProtection?.asc_getIsPassword(); + + if(isProtected) { + if(propsProtection && isPassword) { + f7.dialog.create({ + title: t('Settings.titleDialogUnprotect'), + text: t('Settings.textDialogUnprotect'), + content: Device.ios ? + '
' : '
', + cssClass: 'dlg-adv-options', + buttons: [ + { + text: t('Settings.textCancel') + }, + { + text: t('Settings.textOk'), + onClick: () => { + const passwordValue = document.querySelector('#protection-password')?.value; + + if(passwordValue) { + propsProtection.asc_setEditType(Asc.c_oAscEDocProtect.None); + propsProtection.asc_setPassword(passwordValue); + api.asc_setDocumentProtection(propsProtection); + } + } + } + ] + }).open(); + } else { + if (!propsProtection) + propsProtection = new AscCommonWord.CDocProtect(); + + appOptions.setTypeProtection(null); + propsProtection.asc_setEditType(Asc.c_oAscEDocProtect.None); + api.asc_setDocumentProtection(propsProtection); + } + } else { + f7.views.current.router.navigate('/protect'); + } + } + return { onOrthographyCheck={onOrthographyCheck} onDownloadOrigin={onDownloadOrigin} onChangeMobileView={onChangeMobileView} + onProtectClick={onProtectClick} /> }; diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index d633d96fd7..5dd0e887a0 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -54,7 +54,7 @@ export class storeAppOptions { this.isProtected = value; } - typeProtection; + typeProtection = null; setTypeProtection(type) { this.typeProtection = type; } diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentProtection.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentProtection.jsx index ef0c274175..8e6a4d7bf0 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentProtection.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentProtection.jsx @@ -10,10 +10,11 @@ const ProtectionDocumentView = inject("storeAppOptions")(observer(props => { const isIos = Device.ios; const appOptions = props.storeAppOptions; const typeProtection = appOptions.typeProtection; - const [isPassword, setPassword] = useState(false); + const [stateTypeProtection, setStateTypeProtection] = useState(typeProtection); + const [isRequirePassword, setRequirePassword] = useState(false); const [password, changePassword] = useState(''); - const [passwordRepeat, repeatPassword] = useState(''); - const isDisabledProtection = isPassword && (!password.length || !passwordRepeat.length); + const [passwordRepeat, changeRepeationPassword] = useState(''); + const isDisabledProtection = isRequirePassword ? ((!password.length || !passwordRepeat.length) || stateTypeProtection === null) : stateTypeProtection === null; const showErrorDialog = () => { f7.dialog.create({ @@ -26,29 +27,33 @@ const ProtectionDocumentView = inject("storeAppOptions")(observer(props => { }).open(); }; + const changeHanlder = () => { + if(isRequirePassword && password !== passwordRepeat) { + showErrorDialog(); + } else { + props.onProtectDocument(stateTypeProtection, password); + } + } + return ( - { - if(password !== passwordRepeat) { - showErrorDialog(); - } else { - props.onProtectDocument(typeProtection, password); - } - }}> + {Device.android && } - { - setPassword(!isPassword); + { + setRequirePassword(!isRequirePassword); + changePassword(''); + changeRepeationPassword(''); }} /> - {isPassword && + {isRequirePassword && <> { type="password" placeholder={t('Settings.textRequired')} value={passwordRepeat} - onInput={e => repeatPassword(e.target.value)} + onInput={e => changeRepeationPassword(e.target.value)} className={isIos ? 'list-input-right' : ''} /> @@ -75,17 +80,17 @@ const ProtectionDocumentView = inject("storeAppOptions")(observer(props => { } {t('Settings.textTypeEditing')} - { - appOptions.setTypeProtection(Asc.c_oAscEDocProtect.ReadOnly); + { + setStateTypeProtection(Asc.c_oAscEDocProtect.ReadOnly); }}> - { - appOptions.setTypeProtection(Asc.c_oAscEDocProtect.Forms); + { + setStateTypeProtection(Asc.c_oAscEDocProtect.Forms); }}> - { - appOptions.setTypeProtection(Asc.c_oAscEDocProtect.TrackedChanges); + { + setStateTypeProtection(Asc.c_oAscEDocProtect.TrackedChanges); }}> - { - appOptions.setTypeProtection(Asc.c_oAscEDocProtect.Comments); + { + setStateTypeProtection(Asc.c_oAscEDocProtect.Comments); }}> diff --git a/apps/documenteditor/mobile/src/view/settings/FileEncryption.jsx b/apps/documenteditor/mobile/src/view/settings/FileEncryption.jsx index 947cb1c44f..afe88bafb0 100644 --- a/apps/documenteditor/mobile/src/view/settings/FileEncryption.jsx +++ b/apps/documenteditor/mobile/src/view/settings/FileEncryption.jsx @@ -56,9 +56,11 @@ const EncryptionView = inject("storeAppOptions")(observer(props => { } + {isFileEncrypted && isRequiredPassword && + {t('Settings.textChangePassword')} + } {(isFileEncrypted && isRequiredPassword || !isFileEncrypted) && <> - {t('Settings.textChangePassword')} // set mode const isViewer = appOptions.isViewer; const isMobileView = appOptions.isMobileView; + const isProtected = appOptions.isProtected; let _isEdit = false, _canDownload = false, @@ -166,9 +167,16 @@ const SettingsList = inject("storeAppOptions", "storeReview")(observer(props => } - - - + {_isEdit && !isViewer && + + + + } + {_isEdit && isViewer && + props.onProtectClick()} link="#"> + + + } { if(Device.phone) { onOpenNavigation(); @@ -257,13 +265,14 @@ class SettingsView extends Component { render() { const show_popover = this.props.usePopover; + return ( show_popover ? this.props.closeOptions('settings')}> - + : this.props.closeOptions('settings')}> - + ) }