Test Enterprise-Class Web CMS Scrivito Free for 30 Days
Test Scrivito Free for 30 Days
New in 1.25.0

canEdit(obj)

Determines whether a CMS object can be altered by the editor in the current working copy.

await Scrivito.load(() => Scrivito.canEdit(Scrivito.currentPage())) //=> true or false

Scrivito.canEdit works like Scrivito.canWrite in that it determines whether the content in a working copy can be changed by the current editor. For this to be the case, the UI must be present, and the editor must be on a working copy as its owner, or have the “can edit” permission for it. Additionally, canEdit takes account of the workflow to which the passed-in CMS object is subject. This check can be used, for example, to prevent editors from rendering a working copy unpublishable by changing content through custom editing components or custom dialogs.

Params

obj (Obj) – The Obj instance to be checked.

Returns

booleantrue if the CMS object is editable, otherwise false.

Example

Scrivito.registerComponent('YesOrNoTab', ({ page }) => ( // ... <input type="checkbox" checked={page.get('yesOrNo') === 'yes'} disabled={!Scrivito.canEdit(page)} onChange={e => page.update({ yesOrNo: e.target.checked ? 'yes' : 'no' })} /> // ... ));