diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 545629359..97ef0aa2e 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -31,7 +31,8 @@ import { StatusbarController } from "./Statusbar"; "storeSpreadsheetSettings", "storeSpreadsheetInfo", "storeApplicationSettings", - "storeToolbarSettings" + "storeToolbarSettings", + "storeWorksheets" ) class MainController extends Component { constructor(props) { @@ -47,6 +48,9 @@ class MainController extends Component { licenseType: false, isDocModified: false }; + + this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns', + 'DeleteRows', 'Sort', 'AutoFilter', 'PivotTables', 'Objects', 'Scenarios']; this.defaultTitleText = __APP_TITLE_TEXT__; @@ -396,6 +400,42 @@ class MainController extends Component { } } }); + + this.api.asc_registerCallback('asc_onChangeProtectWorksheet', this.onChangeProtectSheet.bind(this)); + this.api.asc_registerCallback('asc_onActiveSheetChanged', this.onChangeProtectSheet.bind(this)); + } + + onChangeProtectSheet() { + const storeWorksheets = this.props.storeWorksheets; + let props = this.getWSProps(true); + + storeWorksheets.setWorksheetProtection(props); + } + + getWSProps(update) { + const storeAppOptions = this.props.storeAppOptions; + let protection = {}; + if (!storeAppOptions.config || !storeAppOptions.isEdit && !storeAppOptions.isRestrictedEdit) return; + + if (update) { + let wsProtected = !!this.api.asc_isProtectedSheet(); + let arr = {}; + if (wsProtected) { + // arr = []; + let props = this.api.asc_getProtectedSheet(); + props && this.wsLockOptions.forEach(function(item){ + arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; + }); + } else { + this.wsLockOptions.forEach(function(item){ + arr[item] = false; + }); + } + + protection = {wsLock: wsProtected, wsProps: arr}; + } + + return protection; } _onLongActionEnd(type, id) { diff --git a/apps/spreadsheeteditor/mobile/src/store/mainStore.js b/apps/spreadsheeteditor/mobile/src/store/mainStore.js index 93742a6c4..33fe3da4a 100644 --- a/apps/spreadsheeteditor/mobile/src/store/mainStore.js +++ b/apps/spreadsheeteditor/mobile/src/store/mainStore.js @@ -38,6 +38,7 @@ export const stores = { // storeImageSettings: new storeImageSettings(), // storeTableSettings: new storeTableSettings() storeComments: new storeComments(), - storeToolbarSettings: new storeToolbarSettings() + storeToolbarSettings: new storeToolbarSettings(), + storeWorksheets: new storeWorksheets() }; diff --git a/apps/spreadsheeteditor/mobile/src/store/sheets.js b/apps/spreadsheeteditor/mobile/src/store/sheets.js index 3a9f98ac9..47f6d7339 100644 --- a/apps/spreadsheeteditor/mobile/src/store/sheets.js +++ b/apps/spreadsheeteditor/mobile/src/store/sheets.js @@ -36,7 +36,10 @@ export class storeWorksheets { setWorksheetLocked: action, isProtectedWorkbook: observable, - setProtectedWorkbook: action + setProtectedWorkbook: action, + + worksheetProtection: observable, + setWorksheetProtection: action }); this.sheets = []; } @@ -97,4 +100,9 @@ export class storeWorksheets { setProtectedWorkbook(value) { this.isProtectedWorkbook = value; } + + worksheetProtection; + setWorksheetProtection(value) { + this.worksheetProtection = value; + } } diff --git a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx index d271bb892..ff0124eab 100644 --- a/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/edit/EditCell.jsx @@ -11,6 +11,10 @@ const EditCell = props => { const { t } = useTranslation(); const _t = t('View.Edit', {returnObjects: true}); const storeCellSettings = props.storeCellSettings; + const storeWorksheets = props.storeWorksheets; + const worksheetProtection = storeWorksheets.worksheetProtection; + const wsLock = worksheetProtection.wsLock; + const wsProps = worksheetProtection.wsProps; const cellStyles = storeCellSettings.cellStyles; const styleName = storeCellSettings.styleName; @@ -40,79 +44,82 @@ const EditCell = props => { onFontSize: props.onFontSize, onFontClick: props.onFontClick }}/> - - - {props.toggleBold(!isBold)}}>B - {props.toggleItalic(!isItalic)}}>I - {props.toggleUnderline(!isUnderline)}} style={{textDecoration: "underline"}}>U - - - - {!isAndroid ? - {fontColorPreview} : - fontColorPreview - } - - - {!isAndroid ? - {fillColorPreview} : - fillColorPreview - } - - - {!isAndroid ? - : null - } - - - {!isAndroid ? - : null - } - - - {!isAndroid ? - : null - } - - - - - {!isAndroid ? - : null - } - - - {_t.textCellStyles} - {cellStyles.length ? ( - - {cellStyles.map((elem, index) => { - return ( - props.onStyleClick(elem.name)}> -
-
- ) - })} -
- ) : null} + {!wsLock && !wsProps.FormatCells && + <> + + + {props.toggleBold(!isBold)}}>B + {props.toggleItalic(!isItalic)}}>I + {props.toggleUnderline(!isUnderline)}} style={{textDecoration: "underline"}}>U + + + + {!isAndroid ? + {fontColorPreview} : + fontColorPreview + } + + + {!isAndroid ? + {fillColorPreview} : + fillColorPreview + } + + + {!isAndroid ? + : null + } + + + {!isAndroid ? + : null + } + + + {!isAndroid ? + : null + } + + + + {!isAndroid ? + : null + } + + + {_t.textCellStyles} + {cellStyles.length ? ( + + {cellStyles.map((elem, index) => { + return ( + props.onStyleClick(elem.name)}> +
+
+ ) + })} +
+ ) : null} + } + ) }; @@ -977,7 +984,7 @@ const PageTimeFormatCell = props => { } -const PageEditCell = inject("storeCellSettings")(observer(EditCell)); +const PageEditCell = inject("storeCellSettings", "storeWorksheets")(observer(EditCell)); const TextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageTextColorCell)); const FillColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageFillColorCell)); const CustomTextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageCustomTextColorCell));