Skip to content

Commit

Permalink
chore: add sheet permission facade api (#2604)
Browse files Browse the repository at this point in the history
* chore: add sheet permission facade api

* chore: add jsdoc

* chore: add param type

* Update packages/facade/src/apis/sheets/f-workbook.ts

---------

Co-authored-by: Wenzhao Hu <wzhudev@gmail.com>
  • Loading branch information
ybzky and wzhudev authored Jul 3, 2024
1 parent 62e5b64 commit 9ca077f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/facade/src/apis/sheets/f-workbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import type { CommandListener, ICommandInfo, IRange, IWorkbookData, Workbook } from '@univerjs/core';
import {
ICommandService,
IPermissionService,
IResourceLoaderService,
IUniverInstanceService,
mergeWorksheetSnapshotWithDefault,
Expand All @@ -28,7 +29,7 @@ import {
import type {
ISheetCommandSharedParams,
} from '@univerjs/sheets';
import { InsertSheetCommand, RemoveSheetCommand, SelectionManagerService, SetWorksheetActiveOperation } from '@univerjs/sheets';
import { InsertSheetCommand, RemoveSheetCommand, SelectionManagerService, SetWorksheetActiveOperation, WorkbookEditablePermission } from '@univerjs/sheets';
import type { IDisposable } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';

Expand All @@ -43,7 +44,8 @@ export class FWorkbook {
@Inject(IResourceLoaderService) private readonly _resourceLoaderService: IResourceLoaderService,
@Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
@ICommandService private readonly _commandService: ICommandService
@ICommandService private readonly _commandService: ICommandService,
@IPermissionService private readonly _permissionService: IPermissionService

) {
this.id = this._workbook.getUnitId();
Expand Down Expand Up @@ -260,5 +262,18 @@ export class FWorkbook {
);
}

/**
* Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
* @param {boolean} value editable value want to set
*/
setEditable(value: boolean): void {
const instance = new WorkbookEditablePermission(this._workbook.getUnitId());
const editPermissionPoint = this._permissionService.getPermissionPoint(instance.id);
if (!editPermissionPoint) {
this._permissionService.addPermissionPoint(instance);
}
this._permissionService.updatePermissionPoint(instance.id, value);
}

// #region callbacks
}

0 comments on commit 9ca077f

Please sign in to comment.