Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Course->New render modifier #8178

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/frontend/.lint-todo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|23cd787c79c34a628da
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|e5120f87b74c5ae8e4c76b9089e0b4a4504c6e3c|1722902400000|1730682000000|1754006400000|app/components/user-profile-roles.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|1fb0566922ce4f066916e5e2931f650f69d7cfba|1722902400000|1730682000000|1754006400000|app/components/visualizer-program-year-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|38e65b45b56fdfd4160d3b0884114b6643e3a036|1722902400000|1730682000000|1754006400000|app/components/visualizer-program-year-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|4|4|4|23cd787c79c34a628dadb6e96dd4004d42eebb79|1722902400000|1730682000000|1754006400000|app/components/courses/new.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1722902400000|1730682000000|1754006400000|app/components/curriculum-inventory/new-report.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1722902400000|1730682000000|1754006400000|app/components/curriculum-inventory/new-sequence-block.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|77e3831e4ae1b00caee1f808711f2e26ab452a23|1722902400000|1730682000000|1754006400000|app/components/curriculum-inventory/new-sequence-block.hbs
Expand Down
42 changes: 22 additions & 20 deletions packages/frontend/app/components/courses/new.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#let (unique-id) as |templateId|}}
<div class="courses-new" {{did-insert (perform this.load)}} data-test-courses-new>
<div class="courses-new" data-test-courses-new>
{{#unless this.load.isRunning}}
<h4>
{{t "general.newCourse"}}
Expand Down Expand Up @@ -28,26 +28,28 @@
<label for="year-{{templateId}}">
{{t "general.academicYear"}}:
</label>
<select
id="year-{{templateId}}"
data-test-year
{{on "change" (pick "target.value" this.setYear)}}
>
<option disabled="" selected={{is-empty this.selectedYear}} value="">
{{t "general.selectAcademicYear"}}
</option>
{{#each this.years as |year|}}
<option selected={{eq year this.selectedYear}} value={{year}}>
{{#if this.academicYearCrossesCalendarYearBoundaries}}
{{year}}
-
{{add year 1}}
{{else}}
{{year}}
{{/if}}
{{#if this.academicYearCrossesCalendarYearBoundariesData.isResolved}}
<select
id="year-{{templateId}}"
data-test-year
{{on "change" (pick "target.value" this.setYear)}}
>
<option disabled="" selected={{is-empty this.selectedYear}} value="">
{{t "general.selectAcademicYear"}}
</option>
{{/each}}
</select>
{{#each this.years as |year|}}
<option selected={{eq year this.selectedYear}} value={{year}}>
{{#if this.academicYearCrossesCalendarYearBoundaries}}
{{year}}
-
{{add year 1}}
{{else}}
{{year}}
{{/if}}
</option>
{{/each}}
</select>
{{/if}}
</div>
<div class="buttons">
<button
Expand Down
32 changes: 20 additions & 12 deletions packages/frontend/app/components/courses/new.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { cached, tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { DateTime } from 'luxon';
import { validatable, Length, NotBlank } from 'ilios-common/decorators/validation';
import { dropTask, restartableTask } from 'ember-concurrency';
import { dropTask } from 'ember-concurrency';
import { TrackedAsyncData } from 'ember-async-data';

@validatable
export default class CoursesNewComponent extends Component {
Expand All @@ -14,13 +15,29 @@ export default class CoursesNewComponent extends Component {

@tracked @NotBlank() selectedYear;
@tracked @NotBlank() @Length(3, 200) title;
@tracked academicYearCrossesCalendarYearBoundaries;
@tracked years;

constructor() {
super(...arguments);
const thisYear = DateTime.now().year;
this.years = [thisYear - 2, thisYear - 1, thisYear, thisYear + 1, thisYear + 2];

if (this.args.currentYear && this.years.includes(parseInt(this.args.currentYear.id, 10))) {
this.setYear(this.args.currentYear.id);
}
}

@cached
get academicYearCrossesCalendarYearBoundariesData() {
return new TrackedAsyncData(
this.iliosConfig.itemFromConfig('academicYearCrossesCalendarYearBoundaries'),
);
}

get academicYearCrossesCalendarYearBoundaries() {
return this.academicYearCrossesCalendarYearBoundariesData.isResolved
? this.academicYearCrossesCalendarYearBoundariesData.value
: false;
}

@action
Expand All @@ -45,15 +62,6 @@ export default class CoursesNewComponent extends Component {
}
}

load = restartableTask(async () => {
this.academicYearCrossesCalendarYearBoundaries = await this.iliosConfig.itemFromConfig(
'academicYearCrossesCalendarYearBoundaries',
);
if (this.args.currentYear && this.years.includes(parseInt(this.args.currentYear.id, 10))) {
this.setYear(this.args.currentYear.id);
}
});

saveCourse = dropTask(async () => {
this.addErrorDisplayFor('title');
const isValid = await this.isValid();
Expand Down