@@ -5,6 +5,7 @@ import { cached, tracked } from '@glimmer/tracking';
55import { task , timeout } from ' ember-concurrency' ;
66import { modifier } from ' ember-modifier' ;
77import { TrackedAsyncData } from ' ember-async-data' ;
8+ import { mapBy , sortBy } from ' ilios-common/utils/array-helpers' ;
89import OfferingForm from ' ilios-common/components/offering-form' ;
910import toggle from ' ilios-common/helpers/toggle' ;
1011import mouseHoverToggle from ' ilios-common/modifiers/mouse-hover-toggle' ;
@@ -14,12 +15,11 @@ import t from 'ember-intl/helpers/t';
1415import and from ' ember-truth-helpers/helpers/and' ;
1516import includes from ' ilios-common/helpers/includes' ;
1617import IliosTooltip from ' ilios-common/components/ilios-tooltip' ;
18+ import mapBy0 from ' ilios-common/helpers/map-by' ;
1719import eq from ' ember-truth-helpers/helpers/eq' ;
1820import join from ' ilios-common/helpers/join' ;
1921import reverse from ' ilios-common/helpers/reverse' ;
20- import mapBy from ' ilios-common/helpers/map-by' ;
21- import sortBy from ' ilios-common/helpers/sort-by' ;
22- import truncate from ' ilios-common/helpers/truncate' ;
22+ import FadeText from ' ilios-common/components/fade-text' ;
2323import TruncateText from ' ilios-common/components/truncate-text' ;
2424import OfferingUrlDisplay from ' ilios-common/components/offering-url-display' ;
2525import UserStatus from ' ilios-common/components/user-status' ;
@@ -42,33 +42,63 @@ export default class OfferingManagerComponent extends Component {
4242 return new TrackedAsyncData (this .args .offering .learnerGroups );
4343 }
4444
45- @cached
46- get sessionData () {
47- return new TrackedAsyncData (this .args .offering ? .session );
45+ get learnerGroups () {
46+ return this .learnerGroupsData .isResolved ? this .learnerGroupsData .value : null ;
4847 }
4948
50- @cached
51- get courseData () {
52- return new TrackedAsyncData (this .session ? .course );
49+ get sortedLearnerGroups () {
50+ if (! this .learnerGroups ) {
51+ return [];
52+ }
53+ return this .learnerGroups .slice ().sort ((learnerGroupA , learnerGroupB ) => {
54+ const locale = this .intl .get (' locale' );
55+ if (' title:desc' === this .sortBy ) {
56+ return learnerGroupB .title .localeCompare (learnerGroupA .title , locale, { numeric: true });
57+ }
58+ return learnerGroupA .title .localeCompare (learnerGroupB .title , locale, { numeric: true });
59+ });
5360 }
5461
5562 @cached
56- get cohortsData () {
57- return new TrackedAsyncData (this .course ? . cohorts );
63+ get individualLearnersData () {
64+ return new TrackedAsyncData (this .args . offering . learners );
5865 }
5966
60- get learnerGroups () {
61- return this .learnerGroupsData .isResolved ? this .learnerGroupsData .value : null ;
67+ get individualLearners () {
68+ return this .individualLearnersData .isResolved ? this .individualLearnersData .value : [];
69+ }
70+
71+ get sortedIndividualLearners () {
72+ if (! this .individualLearners ) {
73+ return ' ' ;
74+ }
75+
76+ return mapBy (sortBy (this .individualLearners , ' fullName' ), ' fullName' ).join (' , ' );
77+ }
78+
79+ @cached
80+ get sessionData () {
81+ return new TrackedAsyncData (this .args .offering ? .session );
6282 }
6383
6484 get session () {
6585 return this .sessionData .isResolved ? this .sessionData .value : null ;
6686 }
6787
88+ @cached
89+ get courseData () {
90+ return new TrackedAsyncData (this .session ? .course );
91+ }
92+
6893 get course () {
6994 return this .courseData .isResolved ? this .courseData .value : null ;
7095 }
7196
97+ @cached
98+ get cohortsData () {
99+ return new TrackedAsyncData (this .course ? .cohorts );
100+ }
101+
72102 get cohorts () {
73103 return this .cohortsData .isResolved ? this .cohortsData .value : null ;
74104 }
@@ -93,19 +123,6 @@ export default class OfferingManagerComponent extends Component {
93123 return this .args .offering .save ();
94124 }
95125
96- get sortedLearnerGroups () {
97- if (! this .learnerGroups ) {
98- return [];
99- }
100- return this .learnerGroups .slice ().sort ((learnerGroupA , learnerGroupB ) => {
101- const locale = this .intl .get (' locale' );
102- if (' title:desc' === this .sortBy ) {
103- return learnerGroupB .title .localeCompare (learnerGroupA .title , locale, { numeric: true });
104- }
105- return learnerGroupA .title .localeCompare (learnerGroupB .title , locale, { numeric: true });
106- });
107- }
108-
109126 @action
110127 toggleHover (id ) {
111128 if (this .hoveredGroups .includes (id)) {
@@ -140,14 +157,19 @@ export default class OfferingManagerComponent extends Component {
140157 @ scrollToBottom ={{ false }}
141158 />
142159 {{else }}
143- <div
144- class =" offering-manager-learners"
145- title ={{join " , " ( mapBy " fullName" ( sortBy " fullName" @ offering.allLearners) ) }}
146- >
147- {{#if @ offering.allLearners.length }}
148- <strong >({{@ offering.allLearners.length }} )</strong >
149- {{/if }}
150- {{truncate ( join " , " ( mapBy " fullName" ( sortBy " fullName" @ offering.allLearners) ) ) 25 }}
160+ <div class =" offering-manager-learners" >
161+ <FadeText
162+ @ text ={{this .sortedIndividualLearners }}
163+ @ forceExpanded ={{@ fadeTextExpanded }}
164+ @ setExpanded ={{@ setFadeTextExpanded }}
165+ as | ft |
166+ >
167+ {{#if this . individualLearners.length }}
168+ <strong >({{this .individualLearners.length }} )</strong >
169+ {{/if }}
170+ {{ft.text }}
171+ {{ft.controls }}
172+ </FadeText >
151173 </div >
152174 <div class =" offering-manager-learner-groups" >
153175 <ul >
@@ -180,7 +202,7 @@ export default class OfferingManagerComponent extends Component {
180202 ( t " general.parentGroups" )
181203 }} :
182204 </strong >
183- {{join " » " ( reverse ( mapBy " title" learnerGroup.allParents ) ) }}
205+ {{join " » " ( reverse ( mapBy0 " title" learnerGroup.allParents ) ) }}
184206 </IliosTooltip >
185207 {{/if }}
186208 {{/unless }}
0 commit comments