From 1db0b046cf550be37e3ddaa00981657bb6bc35d0 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 28 Jun 2024 11:42:00 -0700 Subject: [PATCH 01/18] Replace modifiers in component --- .../school-competencies-collapsed.hbs | 56 +++++++++---------- .../school-competencies-collapsed.js | 19 ++++--- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/packages/frontend/app/components/school-competencies-collapsed.hbs b/packages/frontend/app/components/school-competencies-collapsed.hbs index 2910a5ce7d..494294256b 100644 --- a/packages/frontend/app/components/school-competencies-collapsed.hbs +++ b/packages/frontend/app/components/school-competencies-collapsed.hbs @@ -1,8 +1,6 @@
@@ -19,34 +17,30 @@
- {{#if this.load.isRunning}} - - {{else}} -
- - - - - +
+
- {{t "general.competencyDomain"}} - - {{t "general.summary"}} -
+ + + + + + + + {{#each (sort-by "title" this.domains) as |domain|}} + + + - - - {{#each (sort-by "title" this.domains) as |domain|}} - - - - - {{/each}} - -
+ {{t "general.competencyDomain"}} + + {{t "general.summary"}} +
+ {{domain.title}} + + {{t "general.subCompetencyCount" count=domain.childCount}} +
- {{domain.title}} - - {{t "general.subCompetencyCount" count=domain.childCount}} -
-
- {{/if}} + {{/each}} + + +
diff --git a/packages/frontend/app/components/school-competencies-collapsed.js b/packages/frontend/app/components/school-competencies-collapsed.js index c83d67f252..cca97d62c6 100644 --- a/packages/frontend/app/components/school-competencies-collapsed.js +++ b/packages/frontend/app/components/school-competencies-collapsed.js @@ -1,12 +1,21 @@ import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { restartableTask } from 'ember-concurrency'; +import { cached, tracked } from '@glimmer/tracking'; +import { TrackedAsyncData } from 'ember-async-data'; export default class SchoolCompetenciesCollapsedComponent extends Component { @tracked competenciesRelationship; + @cached + get schoolCompetenciesData() { + return new TrackedAsyncData(this.args.school.competencies); + } + get competencies() { - return this.competenciesRelationship ? this.competenciesRelationship.slice() : []; + if (this.schoolCompetenciesData.isResolved) { + return this.schoolCompetenciesData.value; + } + + return []; } get domains() { @@ -20,8 +29,4 @@ export default class SchoolCompetenciesCollapsedComponent extends Component { return competency.belongsTo('parent').id(); }); } - - load = restartableTask(async () => { - this.competenciesRelationship = await this.args.school.competencies; - }); } From 2e88e6b1eaaf0d27feb75579471840bd6bb916d6 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 28 Jun 2024 11:47:44 -0700 Subject: [PATCH 02/18] Remove modifiers from component --- packages/frontend/.lint-todo | 4 ++-- .../school-competencies-expanded.hbs | 2 -- .../components/school-competencies-expanded.js | 18 +++++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/frontend/.lint-todo b/packages/frontend/.lint-todo index d8e55f85d5..4c07c2b0a7 100644 --- a/packages/frontend/.lint-todo +++ b/packages/frontend/.lint-todo @@ -1,6 +1,6 @@ +add|ember-template-lint|no-at-ember-render-modifiers|16|4|16|4|46d995f60904f6b6f4b1b6b24bb65b9c97441bc1|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs +add|ember-template-lint|no-at-ember-render-modifiers|28|6|28|6|df94e6558ff62dea69f6f656f668f29b56bcc378|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/new-directory-user.hbs -add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/school-competencies-collapsed.hbs -add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|d0274adc777d08699935bd8c5f7a4a3346d93065|1719360000000|1734915600000|1750464000000|app/components/school-competencies-collapsed.hbs add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/school-competencies-expanded.hbs add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|d0274adc777d08699935bd8c5f7a4a3346d93065|1719360000000|1734915600000|1750464000000|app/components/school-competencies-expanded.hbs add|ember-template-lint|no-at-ember-render-modifiers|5|4|5|4|7312526529ca39ed820819d1478d8e1b8f555279|1719360000000|1734915600000|1750464000000|app/components/school-curriculum-inventory-institution-manager.hbs diff --git a/packages/frontend/app/components/school-competencies-expanded.hbs b/packages/frontend/app/components/school-competencies-expanded.hbs index d8132f6d9a..539e6dccd2 100644 --- a/packages/frontend/app/components/school-competencies-expanded.hbs +++ b/packages/frontend/app/components/school-competencies-expanded.hbs @@ -1,7 +1,5 @@
diff --git a/packages/frontend/app/components/school-competencies-expanded.js b/packages/frontend/app/components/school-competencies-expanded.js index 02103e7736..9f96147345 100644 --- a/packages/frontend/app/components/school-competencies-expanded.js +++ b/packages/frontend/app/components/school-competencies-expanded.js @@ -1,27 +1,27 @@ import Component from '@glimmer/component'; import { service } from '@ember/service'; import { all } from 'rsvp'; -import { tracked } from '@glimmer/tracking'; +import { cached, tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; -import { dropTask, restartableTask } from 'ember-concurrency'; +import { dropTask } from 'ember-concurrency'; import { filterBy, uniqueValues } from 'ilios-common/utils/array-helpers'; +import { TrackedAsyncData } from 'ember-async-data'; export default class SchoolCompetenciesExpandedComponent extends Component { @service store; @tracked competenciesToAdd = []; @tracked competenciesToRemove = []; - @tracked schoolCompetencies; - load = restartableTask(async () => { - this.cleanup(); - this.schoolCompetencies = await this.args.school.competencies; - }); + @cached + get schoolCompetenciesData() { + return new TrackedAsyncData(this.args.school.competencies); + } get competencies() { - if (!this.schoolCompetencies) { + if (!this.schoolCompetenciesData.isResolved) { return []; } - const arr = [...this.schoolCompetencies.slice(), ...this.competenciesToAdd]; + const arr = [...this.schoolCompetenciesData.value, ...this.competenciesToAdd]; return uniqueValues( arr.filter((competency) => !this.competenciesToRemove.includes(competency)), ); From a55e3172c1c2b05ac5ab3d40a48b8534d78c2b94 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 28 Jun 2024 11:52:43 -0700 Subject: [PATCH 03/18] Replace element modifiers with straight load The @institution passed here won't ever change without the component being destroyed first so instead of reacting to changes in that data we can just set all these values when it first loads. --- packages/frontend/.lint-todo | 2 - ...rriculum-inventory-institution-manager.hbs | 2 - ...urriculum-inventory-institution-manager.js | 38 +++++-------------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/packages/frontend/.lint-todo b/packages/frontend/.lint-todo index 4c07c2b0a7..52c56ae89a 100644 --- a/packages/frontend/.lint-todo +++ b/packages/frontend/.lint-todo @@ -1,8 +1,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|16|4|16|4|46d995f60904f6b6f4b1b6b24bb65b9c97441bc1|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs add|ember-template-lint|no-at-ember-render-modifiers|28|6|28|6|df94e6558ff62dea69f6f656f668f29b56bcc378|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/new-directory-user.hbs -add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/school-competencies-expanded.hbs -add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|d0274adc777d08699935bd8c5f7a4a3346d93065|1719360000000|1734915600000|1750464000000|app/components/school-competencies-expanded.hbs add|ember-template-lint|no-at-ember-render-modifiers|5|4|5|4|7312526529ca39ed820819d1478d8e1b8f555279|1719360000000|1734915600000|1750464000000|app/components/school-curriculum-inventory-institution-manager.hbs add|ember-template-lint|no-at-ember-render-modifiers|6|4|6|4|58a8dc317204df6b5fac13a4349906b0c7b1db7b|1719360000000|1734915600000|1750464000000|app/components/school-curriculum-inventory-institution-manager.hbs add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|7312526529ca39ed820819d1478d8e1b8f555279|1719360000000|1734915600000|1750464000000|app/components/school-manager.hbs diff --git a/packages/frontend/app/components/school-curriculum-inventory-institution-manager.hbs b/packages/frontend/app/components/school-curriculum-inventory-institution-manager.hbs index f3c517f998..b795645a37 100644 --- a/packages/frontend/app/components/school-curriculum-inventory-institution-manager.hbs +++ b/packages/frontend/app/components/school-curriculum-inventory-institution-manager.hbs @@ -2,8 +2,6 @@
{ this.addErrorDisplaysFor([ From 93837f8413d799e8dc086a47ed05963037b535f6 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 28 Jun 2024 13:13:46 -0700 Subject: [PATCH 04/18] Replace element modifier We can load this value in the constructor as it doesn't need to be reactive, anytime the school here changes the component will have been destroyed. --- packages/frontend/.lint-todo | 2 -- packages/frontend/app/components/school-manager.hbs | 1 - packages/frontend/app/components/school-manager.js | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/frontend/.lint-todo b/packages/frontend/.lint-todo index 52c56ae89a..73ea254165 100644 --- a/packages/frontend/.lint-todo +++ b/packages/frontend/.lint-todo @@ -1,8 +1,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|16|4|16|4|46d995f60904f6b6f4b1b6b24bb65b9c97441bc1|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs add|ember-template-lint|no-at-ember-render-modifiers|28|6|28|6|df94e6558ff62dea69f6f656f668f29b56bcc378|1719360000000|1734915600000|1750464000000|app/components/locale-chooser.hbs add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1719360000000|1734915600000|1750464000000|app/components/new-directory-user.hbs -add|ember-template-lint|no-at-ember-render-modifiers|5|4|5|4|7312526529ca39ed820819d1478d8e1b8f555279|1719360000000|1734915600000|1750464000000|app/components/school-curriculum-inventory-institution-manager.hbs -add|ember-template-lint|no-at-ember-render-modifiers|6|4|6|4|58a8dc317204df6b5fac13a4349906b0c7b1db7b|1719360000000|1734915600000|1750464000000|app/components/school-curriculum-inventory-institution-manager.hbs add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|7312526529ca39ed820819d1478d8e1b8f555279|1719360000000|1734915600000|1750464000000|app/components/school-manager.hbs add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|66a5b0f89c3a88a7c0b541518f72e20531cd4be7|1719360000000|1734915600000|1750464000000|app/components/school-session-attributes.hbs add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|1d825ec0c79a15f259a520b8cd57683cbcbef5a2|1719360000000|1734915600000|1750464000000|app/components/school-session-attributes.hbs diff --git a/packages/frontend/app/components/school-manager.hbs b/packages/frontend/app/components/school-manager.hbs index 430b788c67..90ca0db3d8 100644 --- a/packages/frontend/app/components/school-manager.hbs +++ b/packages/frontend/app/components/school-manager.hbs @@ -1,7 +1,6 @@