|
5 | 5 | * ------------------------------------------------------------------------------------------- |
6 | 6 | */ |
7 | 7 |
|
8 | | -import { EducationalActivity, PersonAnnualEvent, PersonInterest, Profile } from '@microsoft/microsoft-graph-types-beta'; |
9 | | -import { html, TemplateResult } from 'lit'; |
| 8 | +import { |
| 9 | + EducationalActivity, |
| 10 | + PersonAnnualEvent, |
| 11 | + PersonInterest, |
| 12 | + PhysicalAddress, |
| 13 | + Profile |
| 14 | +} from '@microsoft/microsoft-graph-types-beta'; |
| 15 | +import { html, TemplateResult, nothing } from 'lit'; |
10 | 16 | import { BasePersonCardSection } from '../BasePersonCardSection'; |
11 | 17 | import { getSvg, SvgIcon } from '../../utils/SvgHelper'; |
12 | 18 | import { styles } from './mgt-profile-css'; |
@@ -306,7 +312,7 @@ export class MgtProfile extends BasePersonCardSection { |
306 | 312 | ${position?.detail?.company?.displayName} |
307 | 313 | </div> |
308 | 314 | <div class="work-position__location" tabindex="0"> |
309 | | - ${position?.detail?.company?.address?.city}, ${position?.detail?.company?.address?.state} |
| 315 | + ${this.displayLocation(position?.detail?.company?.address)} |
310 | 316 | </div> |
311 | 317 | </div> |
312 | 318 | </div> |
@@ -351,11 +357,14 @@ export class MgtProfile extends BasePersonCardSection { |
351 | 357 | ${this.getDisplayDateRange(educationalActivity)} |
352 | 358 | </div> |
353 | 359 | </div> |
354 | | - <div class="data-list__item__content"> |
355 | | - <div class="educational-activity__degree" tabindex="0"> |
356 | | - ${educationalActivity.program.displayName || 'Bachelors Degree'} |
357 | | - </div> |
358 | | - </div> |
| 360 | + ${ |
| 361 | + educationalActivity.program.displayName |
| 362 | + ? html`<div class="data-list__item__content"> |
| 363 | + <div class="educational-activity__degree" tabindex="0"> |
| 364 | + ${educationalActivity.program.displayName} |
| 365 | + </div>` |
| 366 | + : nothing |
| 367 | + } |
359 | 368 | </div> |
360 | 369 | `); |
361 | 370 | } |
@@ -492,16 +501,32 @@ export class MgtProfile extends BasePersonCardSection { |
492 | 501 | }); |
493 | 502 | } |
494 | 503 |
|
495 | | - private getDisplayDateRange(event: EducationalActivity): string { |
| 504 | + private getDisplayDateRange(event: EducationalActivity): string | symbol { |
| 505 | + // if startMonthYear is not defined, we do not show the date range (otherwise it will always start with 1970) |
| 506 | + if (!event.startMonthYear) { |
| 507 | + return nothing; |
| 508 | + } |
| 509 | + |
496 | 510 | const start = new Date(event.startMonthYear).getFullYear(); |
497 | | - if (start === 0) { |
498 | | - return null; |
| 511 | + // if the start year is 0 or 1 - it's probably an error or a strange "undefined"-value |
| 512 | + if (start === 0 || start === 1) { |
| 513 | + return nothing; |
499 | 514 | } |
500 | 515 |
|
501 | 516 | const end = event.endMonthYear ? new Date(event.endMonthYear).getFullYear() : this.strings.currentYearSubtitle; |
502 | 517 | return `${start} — ${end}`; |
503 | 518 | } |
504 | 519 |
|
| 520 | + private displayLocation(address: PhysicalAddress | undefined): string | symbol { |
| 521 | + if (address?.city) { |
| 522 | + if (address.state) { |
| 523 | + return `${address.city}, ${address.state}`; |
| 524 | + } |
| 525 | + return address.city; |
| 526 | + } |
| 527 | + return nothing; |
| 528 | + } |
| 529 | + |
505 | 530 | private initPostRenderOperations(): void { |
506 | 531 | setTimeout(() => { |
507 | 532 | try { |
|
0 commit comments