Skip to content

Commit e904ce8

Browse files
committed
refactor(docs): execute permission commands directly
1 parent 8e201de commit e904ce8

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

packages/docs/src/facade/f-document-permission.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ export class FDocumentPermission {
8585
* @returns {Promise<void>} Resolves after the permission command finishes.
8686
*/
8787
async setEditable(editable = true): Promise<void> {
88-
await this.setPoint(UnitAction.Edit, editable);
88+
await this._commandService.executeCommand(SetDocumentPermissionCommand.id, {
89+
unitId: this._unitId,
90+
objectId: this._unitId,
91+
action: UnitAction.Edit,
92+
value: editable,
93+
});
8994
}
9095

9196
/**
@@ -99,15 +104,25 @@ export class FDocumentPermission {
99104
* ```
100105
*/
101106
async setReadOnly(): Promise<void> {
102-
await this.setEditable(false);
107+
await this._commandService.executeCommand(SetDocumentPermissionCommand.id, {
108+
unitId: this._unitId,
109+
objectId: this._unitId,
110+
action: UnitAction.Edit,
111+
value: false,
112+
});
103113
}
104114

105115
/**
106116
* Returns whether the whole Document is currently editable.
107117
* @returns {boolean} Whether Document editing is allowed.
108118
*/
109119
canEdit(): boolean {
110-
return this.getPoint(UnitAction.Edit);
120+
return getDocumentPermissionValue(
121+
this._permissionService,
122+
this._unitId,
123+
this._unitId,
124+
UnitAction.Edit
125+
);
111126
}
112127
}
113128

@@ -161,7 +176,12 @@ export class FDocumentObjectPermission {
161176
* ```
162177
*/
163178
async setReadOnly(): Promise<void> {
164-
await this.setEditable(false);
179+
await this._commandService.executeCommand(SetDocumentPermissionCommand.id, {
180+
unitId: this._unitId,
181+
objectId: this._objectId,
182+
action: UnitAction.Edit,
183+
value: false,
184+
});
165185
}
166186

167187
/**

0 commit comments

Comments
 (0)