Skip to content

Commit

Permalink
Merge pull request #8279 from stopfstedt/rm_ember_render_modifiers_in…
Browse files Browse the repository at this point in the history
…_program_year_components

replaces ember-render-modifiers with getters in program-year components.
  • Loading branch information
dartajax authored Dec 20, 2024
2 parents 55641e6 + 4ff1ba5 commit cf2b8c6
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 114 deletions.
4 changes: 0 additions & 4 deletions packages/frontend/.lint-todo
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|cb6d7acb9879902b89a
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|2bdc98d02ac5ea2a4bd5bac6a0f9e880abafdcbe|1731542400000|1762646400000|1793750400000|app/components/learner-group/instructor-manager.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|4|4|4|170987df2d1e4c134a0ac459fc0bdd8dd91b9929|1731542400000|1762646400000|1793750400000|app/components/learner-group/root.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|4|5|4|7c59a55b95fd159dd99afa6b20e5f05b5b68def0|1731542400000|1762646400000|1793750400000|app/components/learner-group/root.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|12f77ac1f8c43640397b771ba2c9830dd2041f23|1731542400000|1762646400000|1793750400000|app/components/program-year/collapsed-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|6|2|6|2|87dcba868bd23c9305b095ffbda9e90ab5b4918e|1731542400000|1762646400000|1793750400000|app/components/program-year/collapsed-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|b759467cf4c3dc1d7e39d4bed1d085d51090d363|1731542400000|1762646400000|1793750400000|app/components/program-year/objective-list-item-expanded.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|c4f87a15e0dbf28e3a3b95d7b8259a419f93b29d|1731542400000|1762646400000|1793750400000|app/components/program-year/objective-list-item-expanded.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/academic-year.hbs
add|ember-template-lint|no-at-ember-render-modifiers|11|6|11|6|940005188b476a060b0e5d3f05baea24ba178878|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/academic-year.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/competency.hbs
Expand Down
149 changes: 69 additions & 80 deletions packages/frontend/app/components/program-year/collapsed-objectives.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
class="program-year-collapsed-objectives"
data-test-program-year-collapsed-objectives
...attributes
{{did-insert (perform this.load) @programYear.programYearObjectives}}
{{did-update (perform this.load) @programYear.programYearObjectives}}
>
<div>
<button
Expand All @@ -18,82 +16,73 @@
<FaIcon @icon="caret-right" />
</button>
</div>
{{#if this.load.lastSuccessful.value}}
<div class="content">
<table>
<thead>
<tr>
<th class="text-left">
{{t "general.summary"}}
</th>
<th class="text-center">
{{t "general.linkedCompetencies"}}
</th>
<th class="text-center">
{{t "general.vocabularyTerms"}}
</th>
<th class="text-center">
{{t "general.meshTerms"}}
</th>
</tr>
</thead>
<tbody>
<tr>
<td data-test-objective-count>
{{t "general.objectiveCount" count=(get this.objectives "length")}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-parent-status>
{{#if
(eq (get this.objectivesWithCompetency "length") (get this.objectives "length"))
}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithCompetency "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-term-status>
{{#if (eq (get this.objectivesWithTerms "length") (get this.objectives "length"))}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithTerms "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-mesh-status>
{{#if (eq (get this.objectivesWithMesh "length") (get this.objectives "length"))}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithMesh "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
</tr>
<tr>
<td data-test-parent-count>
{{t
"general.linkedCompetencyCount"
count=(get this.objectivesWithCompetency "length")
}}
</td>
</tr>
<tr>
<td data-test-term-count>
{{t "general.termCount" count=(get this.objectivesWithTerms "length")}}
</td>
</tr>
<tr>
<td data-test-mesh-count>
{{t "general.meshCount" count=(get this.objectivesWithMesh "length")}}
</td>
</tr>
</tbody>
</table>
</div>
{{else}}
<LoadingSpinner @tagName="h3" />
{{/if}}
<div class="content">
<table>
<thead>
<tr>
<th class="text-left">
{{t "general.summary"}}
</th>
<th class="text-center">
{{t "general.linkedCompetencies"}}
</th>
<th class="text-center">
{{t "general.vocabularyTerms"}}
</th>
<th class="text-center">
{{t "general.meshTerms"}}
</th>
</tr>
</thead>
<tbody>
<tr>
<td data-test-objective-count>
{{t "general.objectiveCount" count=(get this.objectives "length")}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-parent-status>
{{#if (eq (get this.objectivesWithCompetency "length") (get this.objectives "length"))}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithCompetency "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-term-status>
{{#if (eq (get this.objectivesWithTerms "length") (get this.objectives "length"))}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithTerms "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
<td class="text-middle text-center" rowspan="3" data-test-mesh-status>
{{#if (eq (get this.objectivesWithMesh "length") (get this.objectives "length"))}}
<FaIcon @icon="circle" class="yes" />
{{else if (gte (get this.objectivesWithMesh "length") 1)}}
<FaIcon @icon="circle" class="maybe" />
{{else}}
<FaIcon @icon="ban" class="no" />
{{/if}}
</td>
</tr>
<tr>
<td data-test-parent-count>
{{t "general.linkedCompetencyCount" count=(get this.objectivesWithCompetency "length")}}
</td>
</tr>
<tr>
<td data-test-term-count>
{{t "general.termCount" count=(get this.objectivesWithTerms "length")}}
</td>
</tr>
<tr>
<td data-test-mesh-count>
{{t "general.meshCount" count=(get this.objectivesWithMesh "length")}}
</td>
</tr>
</tbody>
</table>
</div>
</section>
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { restartableTask } from 'ember-concurrency';
import { cached } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';

export default class ProgramYearCollapsedObjectivesComponent extends Component {
@tracked objectives;
@tracked objectivesWithCompetency;
@tracked objectivesWithMesh;
@tracked objectivesWithTerms;
@cached
get objectivesData() {
return new TrackedAsyncData(this.args.programYear.programYearObjectives);
}

load = restartableTask(async (element, [objectivePromise]) => {
if (!objectivePromise) {
return false;
}
this.objectives = await objectivePromise;
get objectives() {
return this.objectivesData.isResolved ? this.objectivesData.value : [];
}

this.objectivesWithCompetency = this.objectives.filter((objective) => {
get objectivesWithCompetency() {
return this.objectives.filter((objective) => {
return !!objective.belongsTo('competency').id();
});
this.objectivesWithMesh = this.objectives.filter((objective) => {
}

get objectivesWithMesh() {
return this.objectives.filter((objective) => {
const meshDescriptorIds = objective.hasMany('meshDescriptors').ids();
return meshDescriptorIds.length > 0;
});
this.objectivesWithTerms = this.objectives.filter((objective) => {
}

get objectivesWithTerms() {
return this.objectives.filter((objective) => {
const termIds = objective.hasMany('terms').ids();
return termIds.length > 0;
});

return true;
});
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<table
class="program-year-objective-list-item-expanded"
{{did-insert (perform this.load) @objective}}
{{did-update (perform this.load) @objective @objective.courses}}
data-test-program-year-objective-list-item-expanded
>
<thead>
<th>{{t "general.courses"}}</th>
<th>{{t "general.objectives"}}</th>
</thead>
<tbody>
{{#if (is-array this.courseObjects)}}
{{#if this.courseObjectsLoaded}}
{{#each (sort-by "title" this.courseObjects) as |obj|}}
<tr data-test-program-year-objective-list-item-expanded-course>
<td class="text-top" data-test-title>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import Component from '@glimmer/component';
import { restartableTask } from 'ember-concurrency';
import { map } from 'rsvp';
import { cached } from '@glimmer/tracking';
import { htmlSafe } from '@ember/template';
import { tracked } from '@glimmer/tracking';
import { TrackedAsyncData } from 'ember-async-data';
import { map } from 'rsvp';
import { findById } from 'ilios-common/utils/array-helpers';

export default class ProgramYearObjectiveListItemExpandedComponent extends Component {
@tracked courseObjects;
@cached
get courseObjectsData() {
return new TrackedAsyncData(this.getCourseObjects(this.args.objective));
}

get courseObjects() {
return this.courseObjectsData.isResolved ? this.courseObjectsData.value : [];
}

get courseObjectsLoaded() {
return this.courseObjectsData.isResolved;
}

load = restartableTask(async (element, [programYearObjective]) => {
if (!programYearObjective) {
return;
}
async getCourseObjects(programYearObjective) {
const courseObjectives = await programYearObjective.courseObjectives;
const objectiveObjects = await map(courseObjectives, async (courseObjective) => {
const course = await courseObjective.course;
Expand All @@ -22,7 +30,7 @@ export default class ProgramYearObjectiveListItemExpandedComponent extends Compo
courseExternalId: course.externalId,
};
});
this.courseObjects = objectiveObjects.reduce((set, obj) => {
return objectiveObjects.reduce((set, obj) => {
let existing = findById(set, obj.courseId);
if (!existing) {
let title = obj.courseTitle;
Expand All @@ -41,5 +49,5 @@ export default class ProgramYearObjectiveListItemExpandedComponent extends Compo
});
return set;
}, []);
});
}
}

0 comments on commit cf2b8c6

Please sign in to comment.