UNPKG

3.38 kBJavaScriptView Raw
1import { _SPQueryable, SPQueryable, _SPCollection, _SPInstance, spInvokableFactory, SPInstance, } from "../spqueryable.js";
2import { body } from "@pnp/queryable";
3import { spPost } from "../operations.js";
4export class _LimitedWebPartManager extends _SPQueryable {
5 get scope() {
6 return SPQueryable(this, "Scope");
7 }
8 get webparts() {
9 return WebPartDefinitions(this, "webparts");
10 }
11 export(id) {
12 return spPost(LimitedWebPartManagerCloneFactory(this, "ExportWebPart"), body({ webPartId: id }));
13 }
14 import(xml) {
15 return spPost(LimitedWebPartManagerCloneFactory(this, "ImportWebPart"), body({ webPartXml: xml }));
16 }
17}
18export const LimitedWebPartManager = (baseUrl, path) => new _LimitedWebPartManager(baseUrl, path);
19const LimitedWebPartManagerCloneFactory = (baseUrl, path) => LimitedWebPartManager(baseUrl, path);
20export class _WebPartDefinitions extends _SPCollection {
21 /**
22 * Gets a web part definition from the collection by id
23 *
24 * @param id The storage ID of the SPWebPartDefinition to retrieve
25 */
26 getById(id) {
27 return WebPartDefinition(this, `getbyid('${id}')`);
28 }
29 /**
30 * Gets a web part definition from the collection by storage id
31 *
32 * @param id The WebPart.ID of the SPWebPartDefinition to retrieve
33 */
34 getByControlId(id) {
35 return WebPartDefinition(this, `getByControlId('${id}')`);
36 }
37}
38export const WebPartDefinitions = spInvokableFactory(_WebPartDefinitions);
39export class _WebPartDefinition extends _SPInstance {
40 /**
41 * Gets the webpart information associated with this definition
42 */
43 get webpart() {
44 return SPInstance(this, "webpart");
45 }
46 /**
47 * Saves changes to the Web Part made using other properties and methods on the SPWebPartDefinition object
48 */
49 saveChanges() {
50 return spPost(WebPartDefinition(this, "SaveWebPartChanges"));
51 }
52 /**
53 * Moves the Web Part to a different location on a Web Part Page
54 *
55 * @param zoneId The ID of the Web Part Zone to which to move the Web Part
56 * @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
57 */
58 moveTo(zoneId, zoneIndex) {
59 return spPost(WebPartDefinition(this, `MoveWebPartTo(zoneID='${zoneId}', zoneIndex=${zoneIndex})`));
60 }
61 /**
62 * Closes the Web Part. If the Web Part is already closed, this method does nothing
63 */
64 close() {
65 return spPost(WebPartDefinition(this, "CloseWebPart"));
66 }
67 /**
68 * Opens the Web Part. If the Web Part is already closed, this method does nothing
69 */
70 open() {
71 return spPost(WebPartDefinition(this, "OpenWebPart"));
72 }
73 /**
74 * Removes a webpart from a page, all settings will be lost
75 */
76 delete() {
77 return spPost(WebPartDefinition(this, "DeleteWebPart"));
78 }
79}
80export const WebPartDefinition = spInvokableFactory(_WebPartDefinition);
81export var WebPartsPersonalizationScope;
82(function (WebPartsPersonalizationScope) {
83 WebPartsPersonalizationScope[WebPartsPersonalizationScope["User"] = 0] = "User";
84 WebPartsPersonalizationScope[WebPartsPersonalizationScope["Shared"] = 1] = "Shared";
85})(WebPartsPersonalizationScope || (WebPartsPersonalizationScope = {}));
86//# sourceMappingURL=types.js.map
\No newline at end of file