Skip to content

Commit

Permalink
Minor updates for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bp-cos committed Oct 8, 2024
1 parent 3860594 commit ed86aaa
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { click, render } from '@ember/test-helpers';
import { click, pauseTest, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setupIntl } from 'ember-intl/test-support';
Expand Down Expand Up @@ -47,7 +47,9 @@ module('Integration | institutions | dashboard | -components | chart-kpi', hooks

// Finally the expanded data is not visible
assert.dom('[data-test-expansion-data]')
.doesNotExist('The expansion data is not visible');
.hasStyle({display: 'none'});
// eslint-disable-next-line ember/no-pause-test
await pauseTest();

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface DataModel {
export default class ChartKpi extends Component<KPIChartWrapperArgs> {
@service intl!: Intl;

@tracked expanded = false;
@tracked collapsed = true;
@tracked expandedData = [] as DataModel[];

/**
Expand Down Expand Up @@ -107,6 +107,6 @@ export default class ChartKpi extends Component<KPIChartWrapperArgs> {

@action
public toggleExpandedData() {
this.expanded = !this.expanded;
this.collapsed = !this.collapsed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@
flex-direction: row;
justify-content: center;
align-items: center;

.facet-expand-button {
display: flex;
justify-content: space-between;
align-items: center;

&:active {
box-shadow: none;
}
}
}
}

Expand All @@ -75,6 +65,10 @@
justify-content: center;
align-items: flex-start;

&.collapsed {
display: none;
}

.data-list {
list-style: none;
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,32 @@
</div>
</div>
<div local-class='bottom-container'>
<div local-class='title-container'>
<div data-test-chart-title local-class='title'>{{@data.title}}</div>
<div local-class='button-container'>
<Button
data-analytics-name='Expand additional data'
data-test-expand-additional-data
@layout='fake-link'
aria-expanded={{this.expanded}}
{{on 'click' this.toggleExpandedData}}
>
<FaIcon data-test-toggle-icon @icon={{if this.expanded 'caret-up' 'caret-down'}} />
</Button>
{{#let (unique-id 'expanded-data') as |expandedDataId|}}
<div local-class='title-container'>
<div data-test-chart-title local-class='title'>{{@data.title}}</div>
<div local-class='button-container'>
<Button
data-analytics-name='Expand additional data'
data-test-expand-additional-data
@layout='fake-link'
aria-controls={{expandedDataId}}
aria-expanded={{this.expanded}}
aria-label={{if this.expanded
(t 'institutions.dashboard.kpi-chart.close-expanded-data')
(t 'institutions.dashboard.kpi-chart.open-expanded-data')
}}
{{on 'click' this.toggleExpandedData}}
>
<FaIcon data-test-toggle-icon @icon={{if this.collapsed 'caret-down' 'caret-up'}} />
</Button>
</div>
</div>
</div>
{{#if this.expanded }}
<div local-class='expanded-data-container'>
<ul local-class='data-list' data-test-expansion-data>
<div
local-class='expanded-data-container {{if this.collapsed 'collapsed'}}'
data-test-expansion-data
id={{expandedDataId}}
>
<ul local-class='data-list'>
{{#each this.expandedData as |data index |}}
<li
local-class='data-container'
Expand All @@ -55,6 +64,6 @@
{{/each}}
</ul>
</div>
{{/if}}
{{/let}}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class ChartKpiWrapperComponent extends Component<TotalCountChartW
private calculateUsersByDepartment(departmentMetrics: InstitutionDepartmentModel[]): ChartDataModel[] {
const departmentData = [] as ChartDataModel[];

departmentMetrics.map((metric: InstitutionDepartmentModel ) => {
departmentMetrics.forEach((metric: InstitutionDepartmentModel ) => {
departmentData.push(
{
label: metric.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module('Integration | institutions | dashboard | -components | total-count-kpi-w
.hasText('10 Total Users');

assert.dom('[data-test-total-count-kpi="0"] [data-test-kpi-icon]')
.hasAttribute('data-icon', 'building');
.hasAttribute('data-icon', 'users');

// And the second total kpi is tested
assert.dom('[data-test-total-count-kpi="1"]')
Expand All @@ -51,7 +51,7 @@ module('Integration | institutions | dashboard | -components | total-count-kpi-w
.hasText('20 OSF Public and Private Projects');

assert.dom('[data-test-total-count-kpi="1"] [data-test-kpi-icon]')
.hasAttribute('data-icon', 'atom');
.hasAttribute('data-icon', 'flask');

// And the third total kpi is tested
assert.dom('[data-test-total-count-kpi="2"]')
Expand All @@ -61,7 +61,7 @@ module('Integration | institutions | dashboard | -components | total-count-kpi-w
.hasText('100 OSF Registrations');

assert.dom('[data-test-total-count-kpi="2"] [data-test-kpi-icon]')
.hasAttribute('data-icon', 'flag');
.hasAttribute('data-icon', 'archive');

// And the fourth total kpi is tested
assert.dom('[data-test-total-count-kpi="3"]')
Expand Down
2 changes: 2 additions & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ institutions:
registrations: 'OSF Registrations'
preprints: 'OSF Preprints'
kpi-chart:
open-expanded-data: 'Expand Additionnal Data'
close-expanded-data: 'Collapse Additionnal Data'
users-by-department: 'Total Users by Department'
public-vs-private-projects:
title: 'Public vs Private Projects'
Expand Down

0 comments on commit ed86aaa

Please sign in to comment.