[DE mobile] Add protection
This commit is contained in:
parent
b6971521c4
commit
20a949da7e
|
@ -19,6 +19,7 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
|
|||
import EncodingController from "./Encoding";
|
||||
import DropdownListController from "./DropdownList";
|
||||
import { Device } from '../../../../common/mobile/utils/device';
|
||||
|
||||
@inject(
|
||||
"users",
|
||||
"storeAppOptions",
|
||||
|
@ -46,7 +47,8 @@ class MainController extends Component {
|
|||
this._state = {
|
||||
licenseType: false,
|
||||
isFromGatewayDownloadAs: false,
|
||||
isDocModified: false
|
||||
isDocModified: false,
|
||||
docProtection: false
|
||||
};
|
||||
|
||||
this.defaultTitleText = __APP_TITLE_TEXT__;
|
||||
|
@ -762,6 +764,10 @@ class MainController extends Component {
|
|||
}
|
||||
});
|
||||
|
||||
// Protection document
|
||||
this.api.asc_registerCallback('asc_onChangeDocumentProtection', this.onChangeProtectDocument.bind(this));
|
||||
// this.api.asc_registerCallback('asc_onLockDocumentProtection', this.onLockDocumentProtection.bind(this));
|
||||
|
||||
// Toolbar settings
|
||||
|
||||
const storeToolbarSettings = this.props.storeToolbarSettings;
|
||||
|
@ -783,6 +789,56 @@ class MainController extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
onChangeProtectDocument() {
|
||||
const storeAppOptions = this.props.storeAppOptions;
|
||||
const props = this.getDocProps(true);
|
||||
const isProtected = props && (props.isReadOnly || props.isCommentsOnly || props.isFormsOnly || props.isReviewOnly);
|
||||
|
||||
storeAppOptions.setProtection(isProtected);
|
||||
props && this.applyRestrictions(props.type);
|
||||
Common.Notifications.trigger('protect:doclock', props);
|
||||
}
|
||||
|
||||
applyRestrictions(type) {
|
||||
const storeAppOptions = this.props.storeAppOptions;
|
||||
|
||||
if (type === Asc.c_oAscEDocProtect.ReadOnly) {
|
||||
this.api.asc_setRestriction(Asc.c_oAscRestrictionType.View);
|
||||
} else if (type === Asc.c_oAscEDocProtect.Comments) {
|
||||
this.api.asc_setRestriction(storeAppOptions.canComments ? Asc.c_oAscRestrictionType.OnlyComments : Asc.c_oAscRestrictionType.View);
|
||||
} else if (type === Asc.c_oAscEDocProtect.Forms) {
|
||||
this.api.asc_setRestriction(storeAppOptions.canFillForms ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.View);
|
||||
} else {
|
||||
if (storeAppOptions?.isRestrictedEdit) {
|
||||
storeAppOptions.canComments && this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyComments);
|
||||
storeAppOptions.canFillForms && this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms);
|
||||
} else {
|
||||
this.api.asc_setRestriction(Asc.c_oAscRestrictionType.None);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getDocProps(isUpdate) {
|
||||
const storeAppOptions = this.props.storeAppOptions;
|
||||
|
||||
if (!storeAppOptions || !storeAppOptions.isEdit && !storeAppOptions.isRestrictedEdit) return;
|
||||
|
||||
if (isUpdate || !this.state.docProtection) {
|
||||
const props = this.api.asc_getDocumentProtection();
|
||||
const type = props ? props.asc_getEditType() : Asc.c_oAscEDocProtect.None;
|
||||
|
||||
this._state.docProtection = {
|
||||
type: type,
|
||||
isReadOnly: type === Asc.c_oAscEDocProtect.ReadOnly,
|
||||
isCommentsOnly: type === Asc.c_oAscEDocProtect.Comments,
|
||||
isReviewOnly: type === Asc.c_oAscEDocProtect.TrackedChanges,
|
||||
isFormsOnly: type === Asc.c_oAscEDocProtect.Forms
|
||||
};
|
||||
}
|
||||
|
||||
return this._state.docProtection;
|
||||
}
|
||||
|
||||
onApiTextReplaced(found, replaced) {
|
||||
const { t } = this.props;
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ class MainPage extends Component {
|
|||
const disabledControls = storeToolbarSettings.disabledControls;
|
||||
const disabledSettings = storeToolbarSettings.disabledSettings;
|
||||
const config = appOptions.config;
|
||||
const isProtected = appOptions.isProtected;
|
||||
|
||||
let showLogo = !(config.customization && (config.customization.loaderName || config.customization.loaderLogo));
|
||||
if (!Object.keys(config).length) {
|
||||
|
@ -250,7 +251,7 @@ class MainPage extends Component {
|
|||
text={isMobileView ? t("Toolbar.textSwitchedMobileView") : t("Toolbar.textSwitchedStandardView")}/>
|
||||
</CSSTransition>
|
||||
}
|
||||
{isViewer && !disabledSettings && !disabledControls && !isDisconnected && isAvailableExt && isEdit &&
|
||||
{isViewer && !disabledSettings && !disabledControls && !isDisconnected && isAvailableExt && isEdit && !isProtected &&
|
||||
<Fab position="right-bottom" slot="fixed" onClick={() => this.turnOffViewerMode()}>
|
||||
<Icon icon="icon-edit-mode"/>
|
||||
</Fab>
|
||||
|
|
|
@ -29,12 +29,20 @@ export class storeAppOptions {
|
|||
changeViewerMode: action,
|
||||
|
||||
isMobileView: observable,
|
||||
changeMobileView: action
|
||||
changeMobileView: action,
|
||||
|
||||
isProtected: observable,
|
||||
setProtection: action
|
||||
});
|
||||
}
|
||||
|
||||
isEdit = false;
|
||||
|
||||
isProtected = false;
|
||||
setProtection(value) {
|
||||
this.isProtected = value;
|
||||
}
|
||||
|
||||
isMobileView = true;
|
||||
changeMobileView() {
|
||||
this.isMobileView = !this.isMobileView;
|
||||
|
|
Loading…
Reference in a new issue