Skip to content

Commit

Permalink
Merge pull request #8278 from stopfstedt/cleanup
Browse files Browse the repository at this point in the history
rm unnecessary loading of sessions from component.
  • Loading branch information
dartajax authored Dec 19, 2024
2 parents daa1d76 + d098108 commit 35e928c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 54 deletions.
66 changes: 32 additions & 34 deletions packages/ilios-common/addon/components/course/objective-list.hbs
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
<div class="course-objective-list" data-test-course-objective-list>
{{#if this.courseSessionsLoaded}}
{{#if this.isSorting}}
<ObjectiveSortManager @subject={{@course}} @close={{set this "isSorting" false}} />
{{/if}}
{{#if this.isSorting}}
<ObjectiveSortManager @subject={{@course}} @close={{set this "isSorting" false}} />
{{/if}}

{{#if (and this.courseObjectiveCount (not this.isSorting))}}
{{#if (and @editable (gt this.courseObjectiveCount 1))}}
<button
class="sort-button"
type="button"
{{on "click" (set this "isSorting" true)}}
data-test-sort
>
{{t "general.sortObjectives"}}
</button>
{{/if}}
<div class="grid-row headers" data-test-headers>
<span class="grid-item" data-test-header>{{t "general.description"}}</span>
<span class="grid-item" data-test-header>{{t "general.parentObjectives"}}</span>
<span class="grid-item" data-test-header>{{t "general.vocabularyTerms"}}</span>
<span class="grid-item" data-test-header>{{t "general.meshTerms"}}</span>
<span class="actions grid-item" data-test-header>{{t "general.actions"}}</span>
</div>
{{#if (and (is-array this.courseObjectives) this.cohortObjectivesLoaded)}}
{{#each this.courseObjectives as |courseObjective|}}
<Course::ObjectiveListItem
@courseObjective={{courseObjective}}
@editable={{@editable}}
@cohortObjectives={{this.cohortObjectives}}
@course={{@course}}
/>
{{/each}}
{{else}}
<Course::ObjectiveListLoading @count={{this.courseObjectiveCount}} />
{{/if}}
{{#if (and this.courseObjectiveCount (not this.isSorting))}}
{{#if (and @editable (gt this.courseObjectiveCount 1))}}
<button
class="sort-button"
type="button"
{{on "click" (set this "isSorting" true)}}
data-test-sort
>
{{t "general.sortObjectives"}}
</button>
{{/if}}
<div class="grid-row headers" data-test-headers>
<span class="grid-item" data-test-header>{{t "general.description"}}</span>
<span class="grid-item" data-test-header>{{t "general.parentObjectives"}}</span>
<span class="grid-item" data-test-header>{{t "general.vocabularyTerms"}}</span>
<span class="grid-item" data-test-header>{{t "general.meshTerms"}}</span>
<span class="actions grid-item" data-test-header>{{t "general.actions"}}</span>
</div>
{{#if (and (is-array this.courseObjectives) this.cohortObjectivesLoaded)}}
{{#each this.courseObjectives as |courseObjective|}}
<Course::ObjectiveListItem
@courseObjective={{courseObjective}}
@editable={{@editable}}
@cohortObjectives={{this.cohortObjectives}}
@course={{@course}}
/>
{{/each}}
{{else}}
<Course::ObjectiveListLoading @count={{this.courseObjectiveCount}} />
{{/if}}
{{/if}}
</div>
22 changes: 2 additions & 20 deletions packages/ilios-common/addon/components/course/objective-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,8 @@ import { findById } from 'ilios-common/utils/array-helpers';
export default class CourseObjectiveListComponent extends Component {
@service store;
@service intl;
@service dataLoader;
@tracked isSorting = false;

@cached
get courseSessionsData() {
return new TrackedAsyncData(this.getCourseSessions(this.args.course));
}

get courseSessions() {
return this.courseSessionsData.isResolved ? this.courseSessionsData.value : null;
}

get courseSessionsLoaded() {
return this.courseSessionsData.isResolved;
}

@cached
get courseObjectivesAsyncData() {
return new TrackedAsyncData(this.args.course.courseObjectives);
Expand All @@ -39,7 +25,7 @@ export default class CourseObjectiveListComponent extends Component {
}

get courseObjectives() {
if (this.courseSessionsLoaded && this.courseObjectivesAsync) {
if (this.courseObjectivesAsync) {
return this.courseObjectivesAsync.slice().sort(sortableByPosition);
}

Expand All @@ -51,7 +37,7 @@ export default class CourseObjectiveListComponent extends Component {
}

get courseCohorts() {
if (this.courseSessionsLoaded && this.courseCohortsAsync) {
if (this.courseCohortsAsync) {
return this.courseCohortsAsync;
}

Expand Down Expand Up @@ -79,10 +65,6 @@ export default class CourseObjectiveListComponent extends Component {
return this.args.course.hasMany('courseObjectives').ids().length;
}

async getCourseSessions(course) {
await this.dataLoader.loadCourseSessions(course.id);
}

async getCohortObjectives(cohorts, intl) {
return await map(cohorts, async (cohort) => {
const programYear = await cohort.programYear;
Expand Down

0 comments on commit 35e928c

Please sign in to comment.