-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8039 from jrjohnson/i5374-some-stuff
Replace Some Modifier Loaders
- Loading branch information
Showing
14 changed files
with
198 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 52 additions & 21 deletions
73
packages/frontend/app/components/unassigned-students-summary.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,66 @@ | ||
import Component from '@glimmer/component'; | ||
import { service } from '@ember/service'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { restartableTask } from 'ember-concurrency'; | ||
import { cached, tracked } from '@glimmer/tracking'; | ||
import { findById } from 'ilios-common/utils/array-helpers'; | ||
import { TrackedAsyncData } from 'ember-async-data'; | ||
|
||
export default class UnassignedStudentsSummaryComponent extends Component { | ||
@service currentUser; | ||
@service store; | ||
|
||
@tracked schoolId; | ||
@tracked selectedSchool; | ||
@tracked unassignedStudents; | ||
|
||
get hasUnassignedStudents() { | ||
return this.unassignedStudents?.length > 0; | ||
@cached | ||
get userModelData() { | ||
return new TrackedAsyncData(this.currentUser.getModel()); | ||
} | ||
|
||
get currentUserModel() { | ||
return this.userModelData.isResolved ? this.userModelData.value : null; | ||
} | ||
|
||
@cached | ||
get userSchoolData() { | ||
return new TrackedAsyncData(this.currentUserModel?.school); | ||
} | ||
get userSchool() { | ||
return this.userSchoolData.isResolved ? this.userSchoolData.value : null; | ||
} | ||
|
||
load = restartableTask(async (element, [schoolId]) => { | ||
if (schoolId) { | ||
this.selectedSchool = findById(this.args.schools.slice(), schoolId); | ||
} else { | ||
const user = await this.currentUser.getModel(); | ||
this.selectedSchool = await user.school; | ||
get selectedSchool() { | ||
if (this.schoolId) { | ||
return findById(this.args.schools, this.schoolId); | ||
} | ||
this.unassignedStudents = await this.store.query('user', { | ||
filters: { | ||
cohorts: null, | ||
enabled: true, | ||
roles: [4], | ||
school: this.selectedSchool.id, | ||
}, | ||
}); | ||
}); | ||
return this.userSchool; | ||
} | ||
|
||
@cached | ||
get unassignedStudentsData() { | ||
return new TrackedAsyncData( | ||
this.store.query('user', { | ||
filters: { | ||
cohorts: null, | ||
enabled: true, | ||
roles: [4], | ||
school: this.selectedSchool.id, | ||
}, | ||
}), | ||
); | ||
} | ||
|
||
get unassignedStudents() { | ||
return this.unassignedStudentsData.isResolved ? this.unassignedStudentsData.value : []; | ||
} | ||
|
||
get hasUnassignedStudents() { | ||
return this.isLoaded && this.unassignedStudents?.length > 0; | ||
} | ||
|
||
get isLoaded() { | ||
return ( | ||
this.userModelData.isResolved && | ||
this.userSchoolData.isResolved && | ||
this.unassignedStudentsData.isResolved | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
packages/ilios-common/addon/components/dashboard/filter-tags.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 10 additions & 11 deletions
21
packages/ilios-common/addon/components/session/collapsed-objectives.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
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 SessionCollapsedObjectivesComponent extends Component { | ||
@tracked objectivesRelationship; | ||
|
||
load = restartableTask(async () => { | ||
this.objectivesRelationship = await this.args.session.sessionObjectives; | ||
}); | ||
@cached | ||
get objectivesData() { | ||
return new TrackedAsyncData(this.args.session.sessionObjectives); | ||
} | ||
|
||
get objectives() { | ||
return this.objectivesRelationship ? this.objectivesRelationship.slice() : []; | ||
return this.objectivesData.isResolved ? this.objectivesData.value : []; | ||
} | ||
|
||
get objectivesWithParents() { | ||
return this.objectives.filter((objective) => { | ||
return objective.courseObjectives.length > 0; | ||
return objective.hasMany('courseObjectives').ids().length > 0; | ||
}); | ||
} | ||
|
||
get objectivesWithMesh() { | ||
return this.objectives.filter((objective) => { | ||
return objective.meshDescriptors.length > 0; | ||
return objective.hasMany('meshDescriptors').ids().length > 0; | ||
}); | ||
} | ||
|
||
get objectivesWithTerms() { | ||
return this.objectives.filter((objective) => { | ||
return objective.terms.length > 0; | ||
return objective.hasMany('terms').ids().length > 0; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.