Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for assigning people in tasks and much more #188

Merged
merged 54 commits into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
419781b
people-picker in task component basic functionality. TODO: filter people
vogtn Oct 16, 2019
1723cbd
[mgt-task] fixing styles of picker
vogtn Oct 16, 2019
9e99158
[mgt-tasks] default state if nobody is assigned
vogtn Oct 16, 2019
3b006ab
fixing errors
vogtn Oct 16, 2019
3de1d39
Merge branch 'master' into nivogt/task-people-picker
vogtn Oct 16, 2019
1fe8ee2
[mgt-tasks] adding deletion or removing selected people
vogtn Oct 16, 2019
46ef440
[Graph] adding assign people promise to planner
vogtn Oct 16, 2019
0d57af7
always show assigned to me
nmetulev Oct 17, 2019
5c8d134
renamed drawers and dressers
nmetulev Oct 18, 2019
b983850
Merge branch 'nmetulev/tasks' into nmetulev/v2/task-peoplepicker
nmetulev Oct 18, 2019
2fd537e
filtering of tasks when target-id is set and clean up of mgt-tasks
nmetulev Oct 18, 2019
6bcc629
added tasks templates and fied styles and utils
nmetulev Oct 18, 2019
9a30c07
[mgt-tasks] updating method for handling people picker hiding
vogtn Oct 18, 2019
c4a928a
merge
vogtn Oct 18, 2019
2e77eb8
updating picker styles
vogtn Oct 18, 2019
53b59c1
[mgt-task] fixing null selected people case
vogtn Oct 18, 2019
b980b19
Merge branch 'master' into nivogt/v2/task-peoplepicker
nmetulev Oct 18, 2019
45dc99a
[mgt-tasks] updating styles for better scss scaffolding and new logic…
vogtn Oct 19, 2019
4345a6a
Merge branch 'nivogt/v2/task-peoplepicker' of https://github.com/micr…
vogtn Oct 19, 2019
5cc4106
task source documentation
vogtn Oct 22, 2019
b1fb969
[mgt-tasks] assings to default if no people are provided
vogtn Oct 25, 2019
b00af85
[mgt-tasks] picker on new task issue
vogtn Oct 25, 2019
d0d31e1
adding property to mgt-people for user id selectionfor use in tasks
vogtn Oct 25, 2019
8ad3216
minor layout fix for new task
nmetulev Oct 28, 2019
857b6ad
Merge branch 'master' into nivogt/v2/task-peoplepicker
vogtn Oct 28, 2019
2387f54
merged master
nmetulev Oct 28, 2019
6fe23c9
[mgt-people] adding personCardInteraction property to people
vogtn Oct 28, 2019
635dd8a
Merge branch 'nivogt/v2/task-peoplepicker' of https://github.com/micr…
vogtn Oct 28, 2019
1d67f9d
restoring index.html
nmetulev Oct 28, 2019
15392ab
[mgt-people] adding 'no-people' template
vogtn Oct 28, 2019
24f4d69
Merge branch 'nivogt/v2/task-peoplepicker' of https://github.com/micr…
vogtn Oct 28, 2019
d0a7d85
[mgt-tasks] updating task and picker to inherit people from each other
vogtn Oct 28, 2019
7defefd
[PersonCardInteraction] refactoring personcard interactions for speci…
vogtn Oct 29, 2019
e54c1c2
removing and updating necessary imports
vogtn Oct 29, 2019
87cbf3b
[mgt-people] refactor peopleid promise into promise.all
vogtn Oct 31, 2019
b26bcd3
[mgt-tasks mgt-people] removed default html for no-people and moved t…
vogtn Oct 31, 2019
cb7b149
[mgt-tasks] adding taskClick custom event
vogtn Oct 31, 2019
329c39f
fixed default person card on people
nmetulev Oct 31, 2019
001c3a2
Added setter and getter for property isNewTaskVisible
BenjiFischman Oct 31, 2019
1c3221a
Merge branch 'nivogt/v2/task-peoplepicker' of https://github.com/micr…
nmetulev Nov 1, 2019
c1b04e8
[Graph.ts] changing order of assignPeopleToTask parameters
vogtn Nov 1, 2019
fa32cdc
[mgt-tasks] fixing mgt-people styles
vogtn Nov 1, 2019
933c4bc
[mgt-tasks] disabled person-card inside of newTask people
vogtn Nov 1, 2019
240d371
[mgt-tasks] adding isEqual if picker chosen people aren't different n…
vogtn Nov 1, 2019
02aa630
assingPeopletoTask rather than person
vogtn Nov 1, 2019
00897b2
rename nopeople template and click handler
vogtn Nov 1, 2019
c4e0373
Fix for images in people and people-picker not updating when people c…
nmetulev Nov 1, 2019
db03d9b
fix for person card in tasks
nmetulev Nov 1, 2019
76741d3
[mgt-tasks] refactor show and hid picker, removing self assigned task
vogtn Nov 1, 2019
3d33dd2
[mgt-tasks] refactor peopleObj
vogtn Nov 1, 2019
566e22e
[mgt-tasks] fixing typing in assign people and sort
vogtn Nov 1, 2019
ef2c2d9
[mgt-tasks] re-work of taskClick event
vogtn Nov 2, 2019
bc6bf22
[mgt-tasks] allowing click on people to save and hide people-picker
vogtn Nov 2, 2019
c7b984f
update taskClick event with raw task results, and minor fixes
nmetulev Nov 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ export class Graph {
);
}

/**
* async promise, allows developer to assign people to task
*
* @param {string} taskId
* @param {*} people
* @param {string} eTag
* @returns {Promise<any>}
* @memberof Graph
*/
public async planner_assignPeopleToTask(taskId: string, people: any, eTag: string): Promise<any> {
return this.planner_setTaskDetails(
taskId,
{
assignments: people
},
eTag
);
}

/**
* async promise, allows developer to create new Planner task
*
Expand Down
30 changes: 30 additions & 0 deletions src/components/PersonCardInteraction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/

/**
* Defines how a person card is shown when a user interacts with
* a person component
*
* @export
* @enum {number}
*/
export enum PersonCardInteraction {
/**
* Don't show person card
*/
none,

/**
* Show person card on hover
*/
hover,

/**
* Show person card on click
*/
click
}
19 changes: 2 additions & 17 deletions src/components/mgt-agenda/mgt-agenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { styles } from './mgt-agenda-css';

import '../../styles/fabric-icon-font';
import { prepScopes } from '../../utils/GraphHelpers';
import { getDayOfWeekString, getMonthString } from '../../utils/Utils';
import '../mgt-person/mgt-person';
import { MgtTemplatedComponent } from '../templatedComponent';

Expand Down Expand Up @@ -428,29 +429,13 @@ export class MgtAgenda extends MgtTemplatedComponent {
private getDateHeaderFromDateTimeString(dateTimeString: string) {
const date = new Date(dateTimeString);
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
const monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];

const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];

const dayIndex = date.getDay();
const monthIndex = date.getMonth();
const day = date.getDate();
const year = date.getFullYear();

return `${dayNames[dayIndex]}, ${monthNames[monthIndex]} ${day}, ${year}`;
return `${getDayOfWeekString(dayIndex)}, ${getMonthString(monthIndex)} ${day}, ${year}`;
}

private getEventDuration(event: MicrosoftGraph.Event) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/mgt-people-picker/mgt-people-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $avatar-size: var(--avatar-size, 48px);
$initials-color: var(--initials-color, white);
$initials-background-color: var(--initials-background-color, #{$ms-color-magenta});
$accent-color: var(--accent-color, #0078d4);
$separator-margin: var(--separator-margin, 0px 0px 0px 0px);

$people-list-background-color: var(--people-list-background-color, white);

Expand Down Expand Up @@ -56,6 +57,7 @@ mgt-people-picker .people-list {
}
:host .people-list-separator,
mgt-people-picker .people-list-separator {
margin: $separator-margin;
height: 2px;
background: $accent-color;
margin-top: 5px;
Expand Down Expand Up @@ -105,7 +107,7 @@ mgt-people-picker .SearchIcon {
:host .people-person,
mgt-people-picker .people-person {
display: flex;
margin: 4px 5px 0 0;
margin: 4px 5px 0px 0;
align-items: center;
background-color: rgba(196, 196, 196, 0.24);
border-radius: 15px;
Expand Down
97 changes: 70 additions & 27 deletions src/components/mgt-people/mgt-people.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { Providers } from '../../Providers';
import { ProviderState } from '../../providers/IProvider';
import '../../styles/fabric-icon-font';
import '../mgt-person/mgt-person';
import { PersonCardInteraction } from '../mgt-person/mgt-person';
import { MgtTemplatedComponent } from '../templatedComponent';
import { PersonCardInteraction } from './../PersonCardInteraction';
import { styles } from './mgt-people-css';

/**
Expand Down Expand Up @@ -62,6 +62,39 @@ export class MgtPeople extends MgtTemplatedComponent {
})
public groupId: string;

/**
* user id array
*
* @memberof MgtPeople
*/
@property({
attribute: 'user-ids',
converter: (value, type) => {
return value.split(',');
}
})
public userIds: string[];

/**
* Sets how the person-card is invoked
* Set to PersonCardInteraction.none to not show the card
*
* @type {PersonCardInteraction}
* @memberof MgtPerson
*/
@property({
attribute: 'person-card',
converter: (value, type) => {
value = value.toLowerCase();
if (typeof PersonCardInteraction[value] === 'undefined') {
return PersonCardInteraction.hover;
} else {
return PersonCardInteraction[value];
}
}
})
public personCardInteraction: PersonCardInteraction = PersonCardInteraction.hover;

private _firstUpdated = false;

/**
Expand All @@ -87,31 +120,35 @@ export class MgtPeople extends MgtTemplatedComponent {

protected render() {
if (this.people) {
return (
this.renderTemplate('default', { people: this.people }) ||
html`
<ul class="people-list">
${this.people.slice(0, this.showMax).map(
person =>
html`
<li class="people-person">
${this.renderTemplate('person', { person }, person.displayName) || this.renderPerson(person)}
</li>
`
)}
${this.people.length > this.showMax
? this.renderTemplate('overflow', {
extra: this.people.length - this.showMax,
max: this.showMax,
people: this.people
}) ||
html`
<li>+${this.people.length - this.showMax}</li>
`
: null}
</ul>
`
);
if (this.people.length) {
return (
this.renderTemplate('default', { people: this.people }) ||
html`
<ul class="people-list">
${this.people.slice(0, this.showMax).map(
person =>
html`
<li class="people-person">
${this.renderTemplate('person', { person }, person.displayName) || this.renderPerson(person)}
</li>
`
)}
${this.people.length > this.showMax
? this.renderTemplate('overflow', {
extra: this.people.length - this.showMax,
max: this.showMax,
people: this.people
}) ||
html`
<li>+${this.people.length - this.showMax}</li>
`
: null}
</ul>
`
);
} else {
return this.renderTemplate('no-people', null) || html``;
}
} else {
return this.renderTemplate('no-data', null) || html``;
}
Expand All @@ -130,6 +167,12 @@ export class MgtPeople extends MgtTemplatedComponent {

if (this.groupId) {
this.people = await client.getPeopleFromGroup(this.groupId);
} else if (this.userIds) {
this.people = await Promise.all(
this.userIds.map(async userId => {
return await client.getUser(userId);
})
);
} else {
this.people = await client.getPeople();
}
Expand All @@ -144,7 +187,7 @@ export class MgtPeople extends MgtTemplatedComponent {
<mgt-person
.personDetails=${person}
.personImage=${'@'}
.personCardInteraction=${PersonCardInteraction.hover}
.personCardInteraction=${this.personCardInteraction}
></mgt-person>
`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/mgt-person-card/mgt-person-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Providers } from '../../Providers';
import { ProviderState } from '../../providers/IProvider';
import { getEmailFromGraphEntity } from '../../utils/GraphHelpers';
import { getSvg, SvgIcon } from '../../utils/SvgHelper';
import { MgtPerson, PersonCardInteraction } from '../mgt-person/mgt-person';
import { MgtPerson } from '../mgt-person/mgt-person';
import { MgtTemplatedComponent } from '../templatedComponent';
import { styles } from './mgt-person-card-css';
/**
Expand Down
31 changes: 6 additions & 25 deletions src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,9 @@ import '../../styles/fabric-icon-font';
import { getEmailFromGraphEntity } from '../../utils/GraphHelpers';
import { MgtPersonCard } from '../mgt-person-card/mgt-person-card';
import { MgtTemplatedComponent } from '../templatedComponent';
import { PersonCardInteraction } from './../PersonCardInteraction';
import { styles } from './mgt-person-css';

/**
* Defines how a person card is shown when a user interacts with
* a person component
*
* @export
* @enum {number}
*/
export enum PersonCardInteraction {
/**
* Don't show person card
*/
none,

/**
* Show person card on hover
*/
hover,

/**
* Show person card on click
*/
click
}

/**
* The person component is used to display a person or contact by using their photo, name, and/or email address.
*
Expand Down Expand Up @@ -121,7 +98,11 @@ export class MgtPerson extends MgtTemplatedComponent {
attribute: 'person-card',
converter: (value, type) => {
value = value.toLowerCase();
return PersonCardInteraction[value] || PersonCardInteraction.none;
if (typeof PersonCardInteraction[value] === 'undefined') {
return PersonCardInteraction.none;
} else {
return PersonCardInteraction[value];
}
}
})
public personCardInteraction: PersonCardInteraction = PersonCardInteraction.none;
Expand Down
Loading