Skip to content

Commit 9601f9b

Browse files
authored
[person-card] Removes sections when there's no data (#1435)
* removes sections in person card when there is no valid data * removes all subsections when there's no data
1 parent cd4e000 commit 9601f9b

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

packages/mgt-components/src/components/mgt-person-card/sections/mgt-person-card-profile/mgt-person-card-profile.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
213213
`);
214214
}
215215

216+
const languageTitle = languageItems.length ? this.strings.LanguagesSubSectionTitle : '';
217+
216218
return html`
217219
<section>
218-
<div class="section__title">${this.strings.LanguagesSubSectionTitle}</div>
220+
<div class="section__title">${languageTitle}</div>
219221
<div class="section__content">
220222
<div class="token-list">
221223
${languageItems}
@@ -248,9 +250,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
248250
`);
249251
}
250252

253+
const skillsTitle = skillItems.length ? this.strings.SkillsSubSectionTitle : '';
254+
251255
return html`
252256
<section>
253-
<div class="section__title">${this.strings.SkillsSubSectionTitle}</div>
257+
<div class="section__title">${skillsTitle}</div>
254258
<div class="section__content">
255259
<div class="token-list">
256260
${skillItems}
@@ -268,13 +272,15 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
268272
* @memberof MgtPersonCardProfile
269273
*/
270274
protected renderWorkExperience(): TemplateResult {
271-
if (!this._profile || !this._profile.positions) {
275+
const { positions } = this._profile;
276+
277+
if (!(positions && positions.length)) {
272278
return null;
273279
}
274280

275281
const positionItems: TemplateResult[] = [];
276282
for (const position of this._profile.positions) {
277-
if (position.detail) {
283+
if (position.detail.description || position.detail.jobTitle !== '') {
278284
positionItems.push(html`
279285
<div class="data-list__item work-position">
280286
<div class="data-list__item__header">
@@ -295,10 +301,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
295301
`);
296302
}
297303
}
304+
const workExperienceTitle = positionItems.length ? this.strings.WorkExperienceSubSectionTitle : '';
298305

299306
return html`
300307
<section>
301-
<div class="section__title">${this.strings.WorkExperienceSubSectionTitle}</div>
308+
<div class="section__title">${workExperienceTitle}</div>
302309
<div class="section__content">
303310
<div class="data-list">
304311
${positionItems}
@@ -341,9 +348,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
341348
`);
342349
}
343350

351+
const educationTitle = positionItems.length ? this.strings.EducationSubSectionTitle : '';
352+
344353
return html`
345354
<section>
346-
<div class="section__title">${this.strings.EducationSubSectionTitle}</div>
355+
<div class="section__title">${educationTitle}</div>
347356
<div class="section__content">
348357
<div class="data-list">
349358
${positionItems}
@@ -374,9 +383,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
374383
`);
375384
}
376385

386+
const professionalInterests = interestItems.length ? this.strings.professionalInterestsSubSectionTitle : '';
387+
377388
return html`
378389
<section>
379-
<div class="section__title">${this.strings.professionalInterestsSubSectionTitle}</div>
390+
<div class="section__title">${professionalInterests}</div>
380391
<div class="section__content">
381392
<div class="token-list">
382393
${interestItems}
@@ -407,9 +418,11 @@ export class MgtPersonCardProfile extends BasePersonCardSection {
407418
`);
408419
}
409420

421+
const personalInterests = interestItems.length ? this.strings.personalInterestsSubSectionTitle : '';
422+
410423
return html`
411424
<section>
412-
<div class="section__title">${this.strings.personalInterestsSubSectionTitle}</div>
425+
<div class="section__title">${personalInterests}</div>
413426
<div class="section__content">
414427
<div class="token-list">
415428
${interestItems}

0 commit comments

Comments
 (0)