[SSE mobile] Add protection sheet
This commit is contained in:
		
							parent
							
								
									d46607d350
								
							
						
					
					
						commit
						da148ca430
					
				| 
						 | 
				
			
			@ -31,7 +31,8 @@ import { StatusbarController } from "./Statusbar";
 | 
			
		|||
    "storeSpreadsheetSettings",
 | 
			
		||||
    "storeSpreadsheetInfo",
 | 
			
		||||
    "storeApplicationSettings",
 | 
			
		||||
    "storeToolbarSettings"
 | 
			
		||||
    "storeToolbarSettings",
 | 
			
		||||
    "storeWorksheets"
 | 
			
		||||
    )
 | 
			
		||||
class MainController extends Component {
 | 
			
		||||
    constructor(props) {
 | 
			
		||||
| 
						 | 
				
			
			@ -48,6 +49,9 @@ class MainController extends Component {
 | 
			
		|||
            isDocModified: false
 | 
			
		||||
        };
 | 
			
		||||
        
 | 
			
		||||
        this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns',
 | 
			
		||||
                'DeleteRows', 'Sort', 'AutoFilter', 'PivotTables', 'Objects', 'Scenarios'];
 | 
			
		||||
 | 
			
		||||
        this.defaultTitleText = __APP_TITLE_TEXT__;
 | 
			
		||||
 | 
			
		||||
        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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,6 +44,8 @@ const EditCell = props => {
 | 
			
		|||
                    onFontSize: props.onFontSize,
 | 
			
		||||
                    onFontClick: props.onFontClick
 | 
			
		||||
                }}/>
 | 
			
		||||
                {!wsLock && !wsProps.FormatCells && 
 | 
			
		||||
                <>
 | 
			
		||||
                    <ListItem className='buttons'>
 | 
			
		||||
                        <Row>
 | 
			
		||||
                            <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
 | 
			
		||||
                        }
 | 
			
		||||
                    </ListItem>
 | 
			
		||||
            </List>
 | 
			
		||||
                    <List>
 | 
			
		||||
                        <ListItem title={_t.textFormat} link="/edit-format-cell/" routeProps={{
 | 
			
		||||
                            onCellFormat: props.onCellFormat,
 | 
			
		||||
| 
						 | 
				
			
			@ -113,6 +118,8 @@ const EditCell = props => {
 | 
			
		|||
                            })}
 | 
			
		||||
                        </List>
 | 
			
		||||
                    ) : null}
 | 
			
		||||
                </>}
 | 
			
		||||
            </List>    
 | 
			
		||||
        </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 FillColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageFillColorCell));
 | 
			
		||||
const CustomTextColorCell = inject("storeCellSettings", "storePalette", "storeFocusObjects")(observer(PageCustomTextColorCell));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue