Skip to content

Commit

Permalink
Merge pull request #393 from patrick-rodgers/dev
Browse files Browse the repository at this point in the history
Update to remove restriction on update object for folders, add docs p…
  • Loading branch information
patrick-rodgers committed Nov 27, 2018
2 parents c870677 + 01f09c2 commit 89fe1f4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ nav:
- configuration: 'config-store/docs/configuration.md'
- providers: 'config-store/docs/providers.md'
- graph: 'graph/docs/index.md'
- contacts: 'graph/docs/contacts.md'
- 'directory objects': 'graph/docs/directoryobjects.md'
- onedrive: 'graph/docs/onedrive.md'
- planner: 'graph/docs/planner.md'
- teams: 'graph/docs/teams.md'
- logging: 'logging/docs/index.md'
- nodejs:
- nodejs: 'nodejs/docs/index.md'
Expand All @@ -57,6 +62,7 @@ nav:
- 'ALM api': 'sp/docs/alm.md'
- Attachments: 'sp/docs/attachments.md'
- 'Client-side Pages': 'sp/docs/client-side-pages.md'
- 'Content Types': 'sp/docs/content-types.md'
- 'Entity Merging': 'sp/docs/entity-merging.md'
- Features: 'sp/docs/features.md'
- Fields: 'sp/docs/fields.md'
Expand Down
28 changes: 28 additions & 0 deletions packages/sp/docs/content-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# @pnp/sp/content types

## Set Folder Unique Content Type Order

```TypeScript
interface OrderData {
ContentTypeOrder: { StringValue: string }[];
UniqueContentTypeOrder?: { StringValue: string }[];
}

const folder = sp.web.lists.getById("{list id guid}").rootFolder;

// here you need to see if there are unique content type orders already or just the default
const existingOrders = await folder.select("ContentTypeOrder", "UniqueContentTypeOrder").get<OrderData>();

const activeOrder = existingOrders.UniqueContentTypeOrder ? existingOrders.UniqueContentTypeOrder : existingOrders.ContentTypeOrder;

// manipulate the order here however you want (I am just reversing the array as an example)
const newOrder = activeOrder.reverse();

// update the content type order thusly:
await folder.update({
UniqueContentTypeOrder: {
__metadata: { type: "Collection(SP.ContentTypeId)" },
results: newOrder,
},
});
```
2 changes: 1 addition & 1 deletion packages/sp/src/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class Folder extends SharePointQueryableShareableFolder {
return new SharePointQueryableCollection(this, "uniqueContentTypeOrder");
}

public update = this._update<FolderUpdateResult, TypedHash<string | number | boolean>>("SP.Folder", data => ({ data, folder: this }));
public update = this._update<FolderUpdateResult, TypedHash<any>>("SP.Folder", data => ({ data, folder: this }));

/**
* Delete this folder
Expand Down

0 comments on commit 89fe1f4

Please sign in to comment.