Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #459 from patrick-rodgers/dev
Browse files Browse the repository at this point in the history
add additional WebPartDefinition methods, fix linting errors
  • Loading branch information
patrick-rodgers committed May 16, 2017
2 parents e09d5e0 + 781a428 commit c6e14f6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/sharepoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export {
ViewUpdateResult
} from "./views";

export {
WebPartDefinitions,
WebPartDefinition,
WebPart
} from "./webparts";

export {
Web,
WebAddResult,
Expand Down
2 changes: 1 addition & 1 deletion src/sharepoint/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export interface RoleDefinitionAddResult {
*
*/
export class RoleDefinitionBindings extends QueryableCollection {

/**
* Creates a new instance of the RoleDefinitionBindings class
*
Expand Down
45 changes: 44 additions & 1 deletion src/sharepoint/webparts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ export class WebPartDefinitions extends QueryableCollection {
/**
* Gets a web part definition from the collection by id
*
* @param id GUID id of the web part definition to get
* @param id The storage ID of the SPWebPartDefinition to retrieve
*/
public getById(id: string): WebPartDefinition {

return new 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
*/
public getByControlId(id: string): WebPartDefinition {
return new WebPartDefinition(this, `getByControlId('${id}')`);
}
}

export class WebPartDefinition extends QueryableInstance {
Expand All @@ -55,6 +64,40 @@ export class WebPartDefinition extends QueryableInstance {
return new WebPart(this);
}

/**
* Saves changes to the Web Part made using other properties and methods on the SPWebPartDefinition object
*/
public saveChanges(): Promise<any> {

return this.clone(WebPartDefinition, "SaveWebPartChanges", true).post();
}

/**
* 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
*/
public moveTo(zoneId: string, zoneIndex: number): Promise<void> {

return this.clone(WebPartDefinition, `MoveWebPartTo(zoneID='${zoneId}', zoneIndex=${zoneIndex})`, true).post();
}

/**
* Closes the Web Part. If the Web Part is already closed, this method does nothing
*/
public close(): Promise<void> {
return this.clone(WebPartDefinition, "CloseWebPart", true).post();
}

/**
* Opens the Web Part. If the Web Part is already closed, this method does nothing
*/
public open(): Promise<void> {
return this.clone(WebPartDefinition, "OpenWebPart", true).post();

}

/**
* Removes a webpart from a page, all settings will be lost
*/
Expand Down
4 changes: 2 additions & 2 deletions src/sharepoint/webs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { RelatedItemManger, RelatedItemManagerImpl } from "./relateditems";
*
*/
export class Webs extends QueryableCollection {

/**
* Creates a new instance of the Webs class
*
Expand Down Expand Up @@ -84,7 +84,7 @@ export class Webs extends QueryableCollection {
*
*/
export class WebInfos extends QueryableCollection {

/**
* Creates a new instance of the WebInfos class
*
Expand Down

0 comments on commit c6e14f6

Please sign in to comment.