[SSE mobile] Correct protection sheet v.2

This commit is contained in:
SergeyEzhin 2021-10-11 23:47:39 +04:00
parent d1072fd3f9
commit 1508b2ee64
7 changed files with 19 additions and 29 deletions

View file

@ -409,33 +409,29 @@ class MainController extends Component {
const storeWorksheets = this.props.storeWorksheets; const storeWorksheets = this.props.storeWorksheets;
let props = this.getWSProps(true); let props = this.getWSProps(true);
storeWorksheets.setWorksheetProtection(props); storeWorksheets.setWsProps(props);
} }
getWSProps(update) { getWSProps(update) {
const storeAppOptions = this.props.storeAppOptions; const storeAppOptions = this.props.storeAppOptions;
let protection = {}; let wsProps = {};
if (!storeAppOptions.config || !storeAppOptions.isEdit && !storeAppOptions.isRestrictedEdit) return; if (!storeAppOptions.config || !storeAppOptions.isEdit && !storeAppOptions.isRestrictedEdit) return;
if (update) { if (update) {
let wsProtected = !!this.api.asc_isProtectedSheet(); let wsProtected = !!this.api.asc_isProtectedSheet();
let arr = {};
if (wsProtected) { if (wsProtected) {
// arr = [];
let props = this.api.asc_getProtectedSheet(); let props = this.api.asc_getProtectedSheet();
props && this.wsLockOptions.forEach(function(item){ props && this.wsLockOptions.forEach(function(item){
arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; wsProps[item] = props['asc_get' + item] ? props['asc_get' + item]() : false;
}); });
} else { } else {
this.wsLockOptions.forEach(function(item){ this.wsLockOptions.forEach(function(item){
arr[item] = false; wsProps[item] = false;
}); });
} }
protection = {wsLock: wsProtected, wsProps: arr};
} }
return protection; return wsProps;
} }
_onLongActionEnd(type, id) { _onLongActionEnd(type, id) {

View file

@ -9,7 +9,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
const _t = t("Toolbar", { returnObjects: true }); const _t = t("Toolbar", { returnObjects: true });
const storeWorksheets = props.storeWorksheets; const storeWorksheets = props.storeWorksheets;
const worksheetProtection = storeWorksheets.worksheetProtection; const wsProps = storeWorksheets.wsProps;
const appOptions = props.storeAppOptions; const appOptions = props.storeAppOptions;
const isDisconnected = props.users.isDisconnected; const isDisconnected = props.users.isDisconnected;
@ -157,7 +157,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
showEditDocument={showEditDocument} showEditDocument={showEditDocument}
onEditDocument={onEditDocument} onEditDocument={onEditDocument}
isDisconnected={isDisconnected} isDisconnected={isDisconnected}
worksheetProtection={worksheetProtection} wsProps={wsProps}
focusOn={focusOn} focusOn={focusOn}
/> />
) )

View file

@ -89,9 +89,7 @@ class MainPage extends Component {
render() { render() {
const appOptions = this.props.storeAppOptions; const appOptions = this.props.storeAppOptions;
const storeWorksheets = this.props.storeWorksheets; const storeWorksheets = this.props.storeWorksheets;
const worksheetProtection = storeWorksheets.worksheetProtection; const wsProps = storeWorksheets.wsProps;
const wsLock = worksheetProtection.wsLock;
const wsProps = worksheetProtection.wsProps;
const config = appOptions.config; const config = appOptions.config;
const showLogo = !(appOptions.canBrandingExt && (config.customization && (config.customization.loaderName || config.customization.loaderLogo))); const showLogo = !(appOptions.canBrandingExt && (config.customization && (config.customization.loaderName || config.customization.loaderLogo)));
const showPlaceholder = !appOptions.isDocReady && (!config.customization || !(config.customization.loaderName || config.customization.loaderLogo)); const showPlaceholder = !appOptions.isDocReady && (!config.customization || !(config.customization.loaderName || config.customization.loaderLogo));

View file

@ -38,8 +38,8 @@ export class storeWorksheets {
isProtectedWorkbook: observable, isProtectedWorkbook: observable,
setProtectedWorkbook: action, setProtectedWorkbook: action,
worksheetProtection: observable, wsProps: observable,
setWorksheetProtection: action setWsProps: action
}); });
this.sheets = []; this.sheets = [];
} }
@ -101,8 +101,8 @@ export class storeWorksheets {
this.isProtectedWorkbook = value; this.isProtectedWorkbook = value;
} }
worksheetProtection = {wsLock: false, wsProps: ''}; wsProps;
setWorksheetProtection(value) { setWsProps(value) {
this.worksheetProtection = value; this.wsProps = value;
} }
} }

View file

@ -5,7 +5,7 @@ import EditorUIController from '../lib/patch'
const ToolbarView = props => { const ToolbarView = props => {
const isDisconnected = props.isDisconnected; const isDisconnected = props.isDisconnected;
const worksheetProtection = props.worksheetProtection; const wsProps = props.wsProps;
const focusOn = props.focusOn; const focusOn = props.focusOn;
const undo_box = props.isEdit && EditorUIController.toolbarOptions ? EditorUIController.toolbarOptions.getUndoRedo({ const undo_box = props.isEdit && EditorUIController.toolbarOptions ? EditorUIController.toolbarOptions.getUndoRedo({
disabledUndo: !props.isCanUndo || isDisconnected, disabledUndo: !props.isCanUndo || isDisconnected,
@ -28,7 +28,7 @@ const ToolbarView = props => {
} }
{props.isEdit && EditorUIController.toolbarOptions && EditorUIController.toolbarOptions.getEditOptions({ {props.isEdit && EditorUIController.toolbarOptions && EditorUIController.toolbarOptions.getEditOptions({
disabled: props.disabledEditControls || props.disabledControls || isDisconnected, disabled: props.disabledEditControls || props.disabledControls || isDisconnected,
worksheetProtection, wsProps,
focusOn, focusOn,
onEditClick: () => props.openOptions('edit'), onEditClick: () => props.openOptions('edit'),
onAddClick: () => props.openOptions('add') onAddClick: () => props.openOptions('add')

View file

@ -12,9 +12,7 @@ const EditCell = props => {
const _t = t('View.Edit', {returnObjects: true}); const _t = t('View.Edit', {returnObjects: true});
const storeCellSettings = props.storeCellSettings; const storeCellSettings = props.storeCellSettings;
const storeWorksheets = props.storeWorksheets; const storeWorksheets = props.storeWorksheets;
const worksheetProtection = storeWorksheets.worksheetProtection; const wsProps = storeWorksheets.wsProps;
const wsLock = worksheetProtection.wsLock;
const wsProps = worksheetProtection.wsProps;
const cellStyles = storeCellSettings.cellStyles; const cellStyles = storeCellSettings.cellStyles;
const styleName = storeCellSettings.styleName; const styleName = storeCellSettings.styleName;
@ -44,7 +42,7 @@ const EditCell = props => {
onFontSize: props.onFontSize, onFontSize: props.onFontSize,
onFontClick: props.onFontClick onFontClick: props.onFontClick
}}/> }}/>
{(!wsLock || !wsProps.FormatCells) && {!wsProps.FormatCells &&
<> <>
<List> <List>
<ListItem className='buttons'> <ListItem className='buttons'>

View file

@ -198,9 +198,7 @@ const PageSpreadsheetSettings = props => {
const _t = t('View.Settings', {returnObjects: true}); const _t = t('View.Settings', {returnObjects: true});
const storeSpreadsheetSettings = props.storeSpreadsheetSettings; const storeSpreadsheetSettings = props.storeSpreadsheetSettings;
const storeWorksheets = props.storeWorksheets; const storeWorksheets = props.storeWorksheets;
const worksheetProtection = storeWorksheets.worksheetProtection; const wsProps = storeWorksheets.wsProps;
const wsLock = worksheetProtection.wsLock;
const wsProps = worksheetProtection.wsProps;
const isPortrait = storeSpreadsheetSettings.isPortrait; const isPortrait = storeSpreadsheetSettings.isPortrait;
const isHideHeadings = storeSpreadsheetSettings.isHideHeadings; const isHideHeadings = storeSpreadsheetSettings.isHideHeadings;
const isHideGridlines = storeSpreadsheetSettings.isHideGridlines; const isHideGridlines = storeSpreadsheetSettings.isHideGridlines;
@ -257,7 +255,7 @@ const PageSpreadsheetSettings = props => {
</ListItem> </ListItem>
</List> </List>
<List> <List>
<ListItem title={_t.textColorSchemes} className={wsLock && wsProps.FormatCells ? 'disabled' : ''} link="/color-schemes/" routeProps={{ <ListItem title={_t.textColorSchemes} className={wsProps.FormatCells ? 'disabled' : ''} link="/color-schemes/" routeProps={{
onColorSchemeChange: props.onColorSchemeChange, onColorSchemeChange: props.onColorSchemeChange,
initPageColorSchemes: props.initPageColorSchemes initPageColorSchemes: props.initPageColorSchemes
}}></ListItem> }}></ListItem>