Skip to content

Commit 4738657

Browse files
committed
feat: expose updated event
makes updated event of MgtBaseTaskComponent accessible on Person control
1 parent ab1ee20 commit 4738657

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

packages/mgt-components/src/components/mgt-person/mgt-person.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const registerMgtPersonComponent = () => {
7575
* @class MgtPerson
7676
* @extends {MgtTemplatedComponent}
7777
*
78+
* @fires {CustomEvent<null>} updated - Fired when the component is updated
7879
* @fires {CustomEvent<IDynamicPerson>} line1clicked - Fired when line1 is clicked
7980
* @fires {CustomEvent<IDynamicPerson>} line2clicked - Fired when line2 is clicked
8081
* @fires {CustomEvent<IDynamicPerson>} line3clicked - Fired when line3 is clicked
@@ -952,7 +953,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
952953
}
953954

954955
// if we have more than one line we add the second line
955-
if (this.view !== 'oneline') {
956+
if (!this.isOneLine()) {
956957
const text = this.getTextFromProperty(person, this.line2Property);
957958
if (this.hasTemplate('line2')) {
958959
// Render the line2 template
@@ -973,7 +974,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
973974
}
974975

975976
// if we have a third or fourth line we add the third line
976-
if (this.view === 'threelines' || this.view === 'fourlines') {
977+
if (this.isThreeLines() || this.isFourLines()) {
977978
const text = this.getTextFromProperty(person, this.line3Property);
978979
if (this.hasTemplate('line3')) {
979980
// Render the line3 template
@@ -994,7 +995,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
994995
}
995996

996997
// add the fourth line if necessary
997-
if (this.view === 'fourlines') {
998+
if (this.isFourLines()) {
998999
const text = this.getTextFromProperty(person, this.line4Property);
9991000
if (this.hasTemplate('line4')) {
10001001
// Render the line4 template

packages/mgt-react/src/generated/person.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type PersonProps = {
3737
line4Property?: string;
3838
view?: ViewType;
3939
templateContext?: TemplateContext;
40+
updated?: (e: CustomEvent<null>) => void;
4041
line1clicked?: (e: CustomEvent<IDynamicPerson>) => void;
4142
line2clicked?: (e: CustomEvent<IDynamicPerson>) => void;
4243
line3clicked?: (e: CustomEvent<IDynamicPerson>) => void;

stories/components/person/person.html.stories.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const events = () => html`
3636
3737
<script>
3838
const person = document.querySelector('mgt-person');
39+
person.addEventListener('updated', e => {
40+
console.log('updated', e);
41+
});
42+
3943
person.addEventListener('line1clicked', e => {
4044
const output = document.querySelector('.output');
4145

stories/components/person/person.react.stories.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export const events = () => html`
8282
import { Person, IDynamicPerson } from '@microsoft/mgt-react';
8383
8484
export default () => {
85+
const onUpdated = useCallback((e: CustomEvent<null>) => {
86+
console.log('component updated', e);
87+
}, []);
88+
8589
const onLineClicked = useCallback((e: CustomEvent<IDynamicPerson>) => {
8690
console.log(e.detail);
8791
}, []);
@@ -90,6 +94,7 @@ export const events = () => html`
9094
<Person
9195
personQuery="me"
9296
view="fourlines"
97+
updated={onUpdated}
9398
line1clicked={onLineClicked}
9499
line2clicked={onLineClicked}
95100
line3clicked={onLineClicked}

0 commit comments

Comments
 (0)