Skip to content

Commit

Permalink
Merge pull request #8224 from stopfstedt/thisnthat
Browse files Browse the repository at this point in the history
fixes various minor issues with course viz
  • Loading branch information
dartajax authored Nov 15, 2024
2 parents 732987f + dc4d9f2 commit 78f2bd6
Show file tree
Hide file tree
Showing 19 changed files with 251 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';

export default class CourseVisualizeInstructorSessionTypeGraph extends Component {
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class CourseVisualizeInstructorSessionTypeGraph extends Component
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.sessionType = obj.meta.sessionType.title;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
return rhett;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';

export default class CourseVisualizeInstructorTermGraph extends Component {
Expand Down Expand Up @@ -41,7 +41,7 @@ export default class CourseVisualizeInstructorTermGraph extends Component {
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.vocabularyTerm = `${obj.meta.vocabulary.title} - ${obj.meta.term.title}`;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
return rhett;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cached, tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { cleanQuery } from 'ilios-common/utils/query-utils';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeInstructorsGraph extends Component {
@service router;
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class CourseVisualizeInstructorsGraph extends Component {
return this.filteredData.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.instructor = obj.meta.user;
rhett.instructorName = obj.meta.user.fullName;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</ul>
</div>
{{/if}}
{{#if (and (not @isIcon) @showDataTable)}}
{{#if (and (not @isIcon) this.hasData @showDataTable)}}
<div class="data-table" data-test-data-table>
<table>
<thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default class CourseVisualizeObjectivesGraph extends Component {
return this.outputData.isResolved ? this.outputData.value : [];
}

get hasData() {
return this.data.length;
}
get sortedAscending() {
return this.sortBy.search(/desc/) === -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';

export default class CourseVisualizeSessionTypeGraph extends Component {
Expand Down Expand Up @@ -45,7 +45,7 @@ export default class CourseVisualizeSessionTypeGraph extends Component {
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.vocabularyTerm = `${obj.meta.vocabulary.title} - ${obj.meta.term.title}`;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
return rhett;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { action } from '@ember/object';
import { cleanQuery } from 'ilios-common/utils/query-utils';
import { map } from 'rsvp';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, uniqueValues } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy, uniqueValues } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeSessionTypesGraph extends Component {
@service router;
Expand Down Expand Up @@ -53,7 +53,7 @@ export default class CourseVisualizeSessionTypesGraph extends Component {
return this.filteredData.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.sessionType = obj.meta.sessionType;
rhett.sessionTypeTitle = obj.meta.sessionType.title;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { restartableTask, timeout } from 'ember-concurrency';
import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';
import { action } from '@ember/object';

export default class CourseVisualizeTermGraph extends Component {
Expand Down Expand Up @@ -44,7 +44,7 @@ export default class CourseVisualizeTermGraph extends Component {
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.sessionType = obj.meta.sessionType.title;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
return rhett;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy, uniqueById } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy, uniqueById } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeVocabulariesGraph extends Component {
@service router;
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class CourseVisualizeVocabulariesGraph extends Component {
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.vocabulary = obj.meta.vocabulary;
rhett.vocabularyTitle = obj.meta.vocabulary.title;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { service } from '@ember/service';
import { cached, tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { TrackedAsyncData } from 'ember-async-data';
import { findById, mapBy } from 'ilios-common/utils/array-helpers';
import { findById, mapBy, sortBy } from 'ilios-common/utils/array-helpers';

export default class CourseVisualizeVocabularyGraph extends Component {
@service router;
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class CourseVisualizeVocabularyGraph extends Component {
return this.data.map((obj) => {
const rhett = {};
rhett.minutes = obj.data;
rhett.sessions = obj.meta.sessions;
rhett.sessions = sortBy(obj.meta.sessions, 'title');
rhett.term = obj.meta.term;
rhett.termTitle = obj.meta.term.title;
rhett.sessionTitles = mapBy(rhett.sessions, 'title').join(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ module(
course: linkedCourseWithoutTime,
sessionType: sessionType3,
});
const session4 = this.server.create('session', {
title: 'Aardvark',
course: linkedCourseWithTime,
sessionType: sessionType2,
});
this.server.create('offering', {
session: session1,
startDate: new Date('2019-12-08T12:00:00'),
Expand All @@ -63,6 +68,12 @@ module(
endDate: new Date('2019-12-05T18:00:00'),
instructors: [instructor],
});
this.server.create('offering', {
session: session4,
startDate: new Date('2019-12-05T18:00:00'),
endDate: new Date('2019-12-05T18:00:00'),
instructors: [instructor],
});
this.emptyCourse = await this.owner
.lookup('service:store')
.findRecord('course', this.server.create('course').id);
Expand Down Expand Up @@ -98,13 +109,18 @@ module(
assert.strictEqual(component.chart.labels[1].text, 'Standalone');
assert.strictEqual(component.dataTable.rows.length, 2);
assert.strictEqual(component.dataTable.rows[0].sessionType, 'Campaign');
assert.strictEqual(component.dataTable.rows[0].sessions.links.length, 1);
assert.strictEqual(component.dataTable.rows[0].sessions.links.length, 2);
assert.strictEqual(component.dataTable.rows[0].sessions.links[0].text, 'Aardvark');
assert.strictEqual(
component.dataTable.rows[0].sessions.links[0].url,
'/courses/1/sessions/4',
);
assert.strictEqual(
component.dataTable.rows[0].sessions.links[0].text,
component.dataTable.rows[0].sessions.links[1].text,
'The San Leandro Horror',
);
assert.strictEqual(
component.dataTable.rows[0].sessions.links[0].url,
component.dataTable.rows[0].sessions.links[1].url,
'/courses/1/sessions/2',
);
assert.strictEqual(component.dataTable.rows[0].minutes, '180');
Expand Down Expand Up @@ -156,17 +172,29 @@ module(
@showDataTable={{true}}
/>`,
);
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'Berkeley Investigations');
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'The San Leandro Horror');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'Berkeley Investigations');
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[1].sessions.text,
'Aardvark, The San Leandro Horror',
);
await component.dataTable.header.sessions.toggle();
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
});

test('sort data-table by minutes', async function (assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ module('Integration | Component | course/visualize-instructor-term-graph', funct
terms: [term3],
sessionType: sessionType,
});
const session4 = this.server.create('session', {
title: 'Aardvark',
course: linkedCourseWithTime,
terms: [term2],
sessionType: sessionType,
});
this.server.create('offering', {
session: session1,
startDate: new Date('2019-12-08T12:00:00'),
Expand All @@ -70,6 +76,12 @@ module('Integration | Component | course/visualize-instructor-term-graph', funct
endDate: new Date('2019-12-05T18:00:00'),
instructors: [instructor],
});
this.server.create('offering', {
session: session4,
startDate: new Date('2019-12-05T18:00:00'),
endDate: new Date('2019-12-05T18:00:00'),
instructors: [instructor],
});
this.emptyCourse = await this.owner
.lookup('service:store')
.findRecord('course', this.server.create('course').id);
Expand Down Expand Up @@ -110,12 +122,14 @@ module('Integration | Component | course/visualize-instructor-term-graph', funct
assert.strictEqual(component.chart.labels[0].text, 'Vocabulary 1 - Standalone');
assert.strictEqual(component.chart.labels[1].text, 'Vocabulary 2 - Campaign');
assert.strictEqual(component.dataTable.rows[0].vocabularyTerm, 'Vocabulary 2 - Campaign');
assert.strictEqual(component.dataTable.rows[0].sessions.links.length, 1);
assert.strictEqual(component.dataTable.rows[0].sessions.links.length, 2);
assert.strictEqual(component.dataTable.rows[0].sessions.links[0].text, 'Aardvark');
assert.strictEqual(component.dataTable.rows[0].sessions.links[0].url, '/courses/1/sessions/4');
assert.strictEqual(
component.dataTable.rows[0].sessions.links[0].text,
component.dataTable.rows[0].sessions.links[1].text,
'The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[0].sessions.links[0].url, '/courses/1/sessions/2');
assert.strictEqual(component.dataTable.rows[0].sessions.links[1].url, '/courses/1/sessions/2');
assert.strictEqual(component.dataTable.rows[0].minutes, '180');
assert.strictEqual(component.dataTable.rows[1].vocabularyTerm, 'Vocabulary 1 - Standalone');
assert.strictEqual(component.dataTable.rows[1].sessions.links.length, 1);
Expand Down Expand Up @@ -159,17 +173,29 @@ module('Integration | Component | course/visualize-instructor-term-graph', funct
@showDataTable={{true}}
/>`,
);
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'Berkeley Investigations');
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'The San Leandro Horror');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
await component.dataTable.header.sessions.toggle();
assert.strictEqual(component.dataTable.rows[0].sessions.text, 'Berkeley Investigations');
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'The San Leandro Horror');
assert.strictEqual(
component.dataTable.rows[1].sessions.text,
'Aardvark, The San Leandro Horror',
);
await component.dataTable.header.sessions.toggle();
assert.strictEqual(
component.dataTable.rows[0].sessions.text,
'Aardvark, The San Leandro Horror',
);
assert.strictEqual(component.dataTable.rows[1].sessions.text, 'Berkeley Investigations');
});

test('sort data-table by minutes', async function (assert) {
Expand Down
Loading

0 comments on commit 78f2bd6

Please sign in to comment.