-
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 #7670 from jrjohnson/3594-course-year-report
Add Some Reporting by Academic Year
- Loading branch information
Showing
15 changed files
with
353 additions
and
27 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
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
29 changes: 29 additions & 0 deletions
29
packages/frontend/app/components/reports/subject/new/academic-year.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<p data-test-reports-subject-new-academic-year> | ||
<label for="new-term"> | ||
{{t "general.whichIs"}} | ||
</label> | ||
{{#if this.isLoaded}} | ||
<select | ||
id="new-academic-year" | ||
data-test-prepositional-objects | ||
{{on "change" (pick "target.value" @changeId)}} | ||
{{did-insert (perform this.setInitialValue)}} | ||
{{did-update (perform this.setInitialValue) @school}} | ||
> | ||
{{#each (sort-by "title" this.academicYears) as |year|}} | ||
<option | ||
selected={{eq year.id @currentId}} | ||
value={{year.id}} | ||
> | ||
{{#if this.academicYearCrossesCalendarYearBoundaries}} | ||
{{year.id}} - {{add year.id 1}} | ||
{{else}} | ||
{{year.id}} | ||
{{/if}} | ||
</option> | ||
{{/each}} | ||
</select> | ||
{{else}} | ||
<LoadingSpinner /> | ||
{{/if}} | ||
</p> |
46 changes: 46 additions & 0 deletions
46
packages/frontend/app/components/reports/subject/new/academic-year.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Component from '@glimmer/component'; | ||
import { TrackedAsyncData } from 'ember-async-data'; | ||
import { cached } from '@glimmer/tracking'; | ||
import { service } from '@ember/service'; | ||
import { task, timeout } from 'ember-concurrency'; | ||
|
||
export default class ReportsSubjectNewAcademicYearComponent extends Component { | ||
@service store; | ||
@service iliosConfig; | ||
|
||
@cached | ||
get data() { | ||
return new TrackedAsyncData(this.store.findAll('academic-year')); | ||
} | ||
|
||
crossesBoundaryConfig = new TrackedAsyncData( | ||
this.iliosConfig.itemFromConfig('academicYearCrossesCalendarYearBoundaries'), | ||
); | ||
|
||
@cached | ||
get academicYearCrossesCalendarYearBoundaries() { | ||
return this.crossesBoundaryConfig.isResolved ? this.crossesBoundaryConfig.value : false; | ||
} | ||
|
||
get academicYears() { | ||
return this.data.value; | ||
} | ||
|
||
get isLoaded() { | ||
return this.data.isResolved; | ||
} | ||
|
||
@task | ||
*setInitialValue() { | ||
yield timeout(1); //wait a moment so we can render before setting | ||
const ids = this.academicYears.map(({ id }) => id); | ||
if (ids.includes(this.args.currentId)) { | ||
return; | ||
} | ||
if (!this.academicYears.length) { | ||
this.args.changeId(null); | ||
} else { | ||
this.args.changeId(this.academicYears[0].id); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.