[SSE mobile] Add protection sheet

This commit is contained in:
SergeyEzhin 2021-10-07 16:10:18 +04:00
parent d46607d350
commit da148ca430
4 changed files with 133 additions and 77 deletions

View file

@ -31,7 +31,8 @@ import { StatusbarController } from "./Statusbar";
"storeSpreadsheetSettings", "storeSpreadsheetSettings",
"storeSpreadsheetInfo", "storeSpreadsheetInfo",
"storeApplicationSettings", "storeApplicationSettings",
"storeToolbarSettings" "storeToolbarSettings",
"storeWorksheets"
) )
class MainController extends Component { class MainController extends Component {
constructor(props) { constructor(props) {
@ -48,6 +49,9 @@ class MainController extends Component {
isDocModified: 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__; this.defaultTitleText = __APP_TITLE_TEXT__;
const { t } = this.props; const { t } = this.props;
@ -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) { _onLongActionEnd(type, id) {

View file

@ -38,6 +38,7 @@ export const stores = {
// storeImageSettings: new storeImageSettings(), // storeImageSettings: new storeImageSettings(),
// storeTableSettings: new storeTableSettings() // storeTableSettings: new storeTableSettings()
storeComments: new storeComments(), storeComments: new storeComments(),
storeToolbarSettings: new storeToolbarSettings() storeToolbarSettings: new storeToolbarSettings(),
storeWorksheets: new storeWorksheets()
}; };

View file

@ -36,7 +36,10 @@ export class storeWorksheets {
setWorksheetLocked: action, setWorksheetLocked: action,
isProtectedWorkbook: observable, isProtectedWorkbook: observable,
setProtectedWorkbook: action setProtectedWorkbook: action,
worksheetProtection: observable,
setWorksheetProtection: action
}); });
this.sheets = []; this.sheets = [];
} }
@ -97,4 +100,9 @@ export class storeWorksheets {
setProtectedWorkbook(value) { setProtectedWorkbook(value) {
this.isProtectedWorkbook = value; this.isProtectedWorkbook = value;
} }
worksheetProtection;
setWorksheetProtection(value) {
this.worksheetProtection = value;
}
} }

View file

@ -11,6 +11,10 @@ const EditCell = props => {
const { t } = useTranslation(); const { t } = useTranslation();
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 worksheetProtection = storeWorksheets.worksheetProtection;
const wsLock = worksheetProtection.wsLock;
const wsProps = worksheetProtection.wsProps;
const cellStyles = storeCellSettings.cellStyles; const cellStyles = storeCellSettings.cellStyles;
const styleName = storeCellSettings.styleName; const styleName = storeCellSettings.styleName;
@ -40,6 +44,8 @@ const EditCell = props => {
onFontSize: props.onFontSize, onFontSize: props.onFontSize,
onFontClick: props.onFontClick onFontClick: props.onFontClick
}}/> }}/>
{!wsLock && !wsProps.FormatCells &&
<>
<ListItem className='buttons'> <ListItem className='buttons'>
<Row> <Row>
<a className={'button' + (isBold ? ' active' : '')} onClick={() => {props.toggleBold(!isBold)}}><b>B</b></a> <a className={'button' + (isBold ? ' active' : '')} onClick={() => {props.toggleBold(!isBold)}}><b>B</b></a>
@ -86,7 +92,6 @@ const EditCell = props => {
<Icon slot="media" icon="icon-table-borders-all"></Icon> : null <Icon slot="media" icon="icon-table-borders-all"></Icon> : null
} }
</ListItem> </ListItem>
</List>
<List> <List>
<ListItem title={_t.textFormat} link="/edit-format-cell/" routeProps={{ <ListItem title={_t.textFormat} link="/edit-format-cell/" routeProps={{
onCellFormat: props.onCellFormat, onCellFormat: props.onCellFormat,
@ -113,6 +118,8 @@ const EditCell = props => {
})} })}
</List> </List>
) : null} ) : null}
</>}
</List>
</Fragment> </Fragment>
) )
}; };
@ -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 TextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageTextColorCell));
const FillColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageFillColorCell)); const FillColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageFillColorCell));
const CustomTextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageCustomTextColorCell)); const CustomTextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageCustomTextColorCell));