Skip to content

Commit

Permalink
Merge pull request #2910 from juliemturner/version-4
Browse files Browse the repository at this point in the history
Graph Planner Update
  • Loading branch information
juliemturner authored Jan 18, 2024
2 parents d064d44 + 54a72bc commit 61bfde9
Show file tree
Hide file tree
Showing 5 changed files with 552 additions and 245 deletions.
90 changes: 71 additions & 19 deletions docs/graph/planner.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ you can add, update and delete items in Planner.

More information can be found in the official Graph documentation:

- [Planner Resource Type](https://docs.microsoft.com/en-us/graph/api/resources/plannertask?view=graph-rest-1.0)
- [Tasks and plans](https://learn.microsoft.com/en-us/graph/api/resources/planner-overview?view=graph-rest-1.0)

## IInvitations

Expand All @@ -22,7 +22,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const plan = await graph.planner.plans.getById('planId')();
const plan = await graph.planner.plans.getById({planId})();

```

Expand All @@ -36,7 +36,14 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const newPlan = await graph.planner.plans.add('groupObjectId', 'title');
const planTemplate: IPlanAdd = {
container: {
url: "",
},
title: "",
};

const plan = await graph.planner.plans.add(planTemplate);

```

Expand All @@ -50,7 +57,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const planTasks = await graph.planner.plans.getById('planId').tasks();
const planTasks = await graph.planner.plans.getById({planId}).tasks();

```

Expand All @@ -64,7 +71,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const planBuckets = await graph.planner.plans.getById('planId').buckets();
const planBuckets = await graph.planner.plans.getById({planId}).buckets();

```

Expand All @@ -78,7 +85,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const planDetails = await graph.planner.plans.getById('planId').details();
const planDetails = await graph.planner.plans.getById({planId}).details();

```

Expand All @@ -92,7 +99,8 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const delPlan = await graph.planner.plans.getById('planId').delete('planEtag');
// Note the planETag cannot be "*" and is required.
const delPlan = await graph.planner.plans.getById({planId}).delete({planEtag});

```

Expand All @@ -106,7 +114,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const updPlan = await graph.planner.plans.getById('planId').update({title: 'New Title', eTag: 'planEtag'});
const updPlan = await graph.planner.plans.getById({planId}).update({title: 'New Title', eTag: {planEtag}});

```

Expand All @@ -116,11 +124,13 @@ Using the tasks() you can get the Tasks across all plans

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/planner";

const graph = graphfi(...);

const planTasks = await graph.me.tasks()
const planTasks = await graph.me.tasks();
const planTasks = await graph.users.getById({userId}).tasks();

```

Expand All @@ -135,7 +145,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const task = await graph.planner.tasks.getById('taskId')();
const task = await graph.planner.tasks.getById({taskId})();

```

Expand All @@ -149,7 +159,17 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const newTask = await graph.planner.tasks.add('planId', 'title');
const taskTemplate = {
planId: {planId},
title: "My New Task",
assignments: {
{userId}: {
"@odata.type": "#microsoft.graph.plannerAssignment",
orderHint: " !",
}
},
};
const newTask = await graph.planner.tasks.add({taskTemplate});

```

Expand All @@ -163,7 +183,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const taskDetails = await graph.planner.tasks.getById('taskId').details();
const taskDetails = await graph.planner.tasks.getById({taskId}).details();

```

Expand All @@ -177,7 +197,8 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const delTask = await graph.planner.tasks.getById('taskId').delete('taskEtag');
// Note the taskEtag cannot be "*" and is required.
const delTask = await graph.planner.tasks.getById({taskId}).delete({taskEtag});

```

Expand All @@ -191,7 +212,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const updTask = await graph.planner.tasks.getById('taskId').update({properties, eTag:'taskEtag'});
const updTask = await graph.planner.tasks.getById({taskId}).update({properties, eTag: {taskEtag}});

```

Expand All @@ -206,7 +227,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const bucket = await graph.planner.buckets.getById('bucketId')();
const bucket = await graph.planner.buckets.getById({bucketId})();

```

Expand All @@ -220,7 +241,11 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const newBucket = await graph.planner.buckets.add('name', 'planId');
const bucketTemplate = {
planId: {planId},
name: "My Task Bucket",
};
const newBucket = await graph.planner.buckets.add(bucketTemplate);

```

Expand All @@ -234,7 +259,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const updBucket = await graph.planner.buckets.getById('bucketId').update({name: "Name", eTag:'bucketEtag'});
const updBucket = await graph.planner.buckets.getById({bucketId}).update({name: "New Name", eTag: {bucketEtag}});

```

Expand All @@ -248,7 +273,8 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const delBucket = await graph.planner.buckets.getById('bucketId').delete(eTag:'bucketEtag');
// Note the bucketEtag cannot be "*" and is required.
const delBucket = await graph.planner.buckets.getById({bucketId}).delete(eTag: {bucketEtag});

```

Expand All @@ -262,7 +288,7 @@ import "@pnp/graph/planner";

const graph = graphfi(...);

const bucketTasks = await graph.planner.buckets.getById('bucketId').tasks();
const bucketTasks = await graph.planner.buckets.getById({bucketId}).tasks();

```

Expand All @@ -280,3 +306,29 @@ const graph = graphfi(...);
const plans = await graph.groups.getById("b179a282-9f94-4bb5-a395-2a80de5a5a78").plans();

```

## Get AssignedToTaskBoardFormat, BucketTaskBoardFormat, ProgressTaskBoardTaskFormat

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/planner";

const graph = graphfi(...);

const assignedToTaskBoardFormat = await this.pnp.graph.planner.tasks.getById({taskId}).assignedToTaskBoardFormat();
const bucketTaskBoardFormat = await this.pnp.graph.planner.tasks.getById({taskId}).assignedToTaskBoardFormat();
const progressTaskBoardTaskFormat = await this.pnp.graph.planner.tasks.getById({taskId}).progressTaskBoardTaskFormat();
```

## Update AssignedToTaskBoardFormat, BucketTaskBoardFormat, ProgressTaskBoardTaskFormat

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/planner";

const graph = graphfi(...);

await this.pnp.graph.planner.tasks.getById({taskId}).assignedToTaskBoardFormat.update({ unassignedOrderHint: " abc!" }, {taskETag});
await this.pnp.graph.planner.tasks.getById({taskId}).assignedToTaskBoardFormat.update({orderHint: " abc!" }, {taskETag});
await this.pnp.graph.planner.tasks.getById({taskId}).progressTaskBoardTaskFormat.update({orderHint: " abc!" }, {taskETag});
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"scripts": {
"build": "npm run pnp-buildsystem-init && pnpbuild -n build",
"build-localresolver": "npx tsc -p tsconfig.localresolver.json",
"buildDebug": "npm run pnp-buildsystem-init && pnpbuild -n build-debug",
"buildDebug": "npm run clean && npm run pnp-buildsystem-init && pnpbuild -n build-debug",
"clean": "del-cli \"./?(dist|site|build|buildsystem-config.js)\"",
"lint": "eslint ./packages ./test --ext .ts",
"package": "npm run pnp-buildsystem-init && pnpbuild -n package",
Expand Down
4 changes: 1 addition & 3 deletions packages/graph/planner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ export {
Bucket,
Buckets,
IBucket,
IBucketAddResult,
IBuckets,
IPlan,
IPlanAddResult,
IPlanAdd,
IPlanner,
IPlans,
ITask,
ITaskAddResult,
ITasks,
ITaskDetails,
Plan,
Expand Down
Loading

0 comments on commit 61bfde9

Please sign in to comment.