UNPKG

@pnp/sp

Version:

pnp - provides a fluent api for working with SharePoint REST

86 lines 3.38 kB
import { _SPQueryable, SPQueryable, _SPCollection, _SPInstance, spInvokableFactory, SPInstance, } from "../spqueryable.js"; import { body } from "@pnp/queryable"; import { spPost } from "../operations.js"; export class _LimitedWebPartManager extends _SPQueryable { get scope() { return SPQueryable(this, "Scope"); } get webparts() { return WebPartDefinitions(this, "webparts"); } export(id) { return spPost(LimitedWebPartManagerCloneFactory(this, "ExportWebPart"), body({ webPartId: id })); } import(xml) { return spPost(LimitedWebPartManagerCloneFactory(this, "ImportWebPart"), body({ webPartXml: xml })); } } export const LimitedWebPartManager = (baseUrl, path) => new _LimitedWebPartManager(baseUrl, path); const LimitedWebPartManagerCloneFactory = (baseUrl, path) => LimitedWebPartManager(baseUrl, path); export class _WebPartDefinitions extends _SPCollection { /** * Gets a web part definition from the collection by id * * @param id The storage ID of the SPWebPartDefinition to retrieve */ getById(id) { return WebPartDefinition(this, `getbyid('${id}')`); } /** * Gets a web part definition from the collection by storage id * * @param id The WebPart.ID of the SPWebPartDefinition to retrieve */ getByControlId(id) { return WebPartDefinition(this, `getByControlId('${id}')`); } } export const WebPartDefinitions = spInvokableFactory(_WebPartDefinitions); export class _WebPartDefinition extends _SPInstance { /** * Gets the webpart information associated with this definition */ get webpart() { return SPInstance(this, "webpart"); } /** * Saves changes to the Web Part made using other properties and methods on the SPWebPartDefinition object */ saveChanges() { return spPost(WebPartDefinition(this, "SaveWebPartChanges")); } /** * Moves the Web Part to a different location on a Web Part Page * * @param zoneId The ID of the Web Part Zone to which to move the Web Part * @param zoneIndex A Web Part zone index that specifies the position at which the Web Part is to be moved within the destination Web Part zone */ moveTo(zoneId, zoneIndex) { return spPost(WebPartDefinition(this, `MoveWebPartTo(zoneID='${zoneId}', zoneIndex=${zoneIndex})`)); } /** * Closes the Web Part. If the Web Part is already closed, this method does nothing */ close() { return spPost(WebPartDefinition(this, "CloseWebPart")); } /** * Opens the Web Part. If the Web Part is already closed, this method does nothing */ open() { return spPost(WebPartDefinition(this, "OpenWebPart")); } /** * Removes a webpart from a page, all settings will be lost */ delete() { return spPost(WebPartDefinition(this, "DeleteWebPart")); } } export const WebPartDefinition = spInvokableFactory(_WebPartDefinition); export var WebPartsPersonalizationScope; (function (WebPartsPersonalizationScope) { WebPartsPersonalizationScope[WebPartsPersonalizationScope["User"] = 0] = "User"; WebPartsPersonalizationScope[WebPartsPersonalizationScope["Shared"] = 1] = "Shared"; })(WebPartsPersonalizationScope || (WebPartsPersonalizationScope = {})); //# sourceMappingURL=types.js.map