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

replaces ember render modifiers in curr inv new report component. #8260

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 @@ -27,7 +27,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c0
add|ember-template-lint|no-at-ember-render-modifiers|11|6|11|6|940005188b476a060b0e5d3f05baea24ba178878|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/session-type.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/term.hbs
add|ember-template-lint|no-at-ember-render-modifiers|11|6|11|6|940005188b476a060b0e5d3f05baea24ba178878|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/term.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1733184000000|1735776000000|1738368000000|app/components/curriculum-inventory/new-report.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1733184000000|1735776000000|1738368000000|app/components/curriculum-inventory/new-sequence-block.hbs
add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|77e3831e4ae1b00caee1f808711f2e26ab452a23|1733184000000|1735776000000|1738368000000|app/components/curriculum-inventory/new-sequence-block.hbs
add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|23cd787c79c34a628dadb6e96dd4004d42eebb79|1733184000000|1735776000000|1738368000000|app/components/curriculum-inventory/report-overview.hbs
Expand Down
148 changes: 71 additions & 77 deletions packages/frontend/app/components/curriculum-inventory/new-report.hbs
Original file line number Diff line number Diff line change
@@ -1,82 +1,76 @@
{{! template-lint-disable attribute-indentation }}
<div
class="curriculum-inventory-new-report"
data-test-curriculum-inventory-new-report
{{did-insert (perform this.load)}}
>
<div class="curriculum-inventory-new-report" data-test-curriculum-inventory-new-report>
{{#let (unique-id) as |templateId|}}
{{#unless this.load.isRunning}}
<h4>
{{t "general.newCurriculumInventoryReport"}}
</h4>
<div class="form">
<div class="item" data-test-name>
<label for="name-{{templateId}}">
{{t "general.name"}}:
</label>
<input
id="name-{{templateId}}"
type="text"
value={{this.name}}
disabled={{this.save.isRunning}}
placeholder={{t "general.reportNamePlaceholder"}}
{{on "focusout" (fn this.addErrorDisplayFor "name")}}
{{on "keyup" (perform this.keyboard)}}
{{on "input" (pick "target.value" (set this "name"))}}
{{on "keyup" (fn this.addErrorDisplayFor "name")}}
/>
<ValidationError @validatable={{this}} @property="name" />
</div>
<div class="item" data-test-description>
<label for="description-{{templateId}}">
{{t "general.description"}}:
</label>
<textarea
id="description-{{templateId}}"
disabled={{this.save.isRunning}}
placeholder={{t "general.reportDescriptionPlaceholder"}}
{{on "input" (pick "target.value" (set this "description"))}}
>{{this.description}}</textarea>
<ValidationError @validatable={{this}} @property="description" />
</div>
<div class="item" data-test-program-title>
<label>
{{t "general.program"}}:
</label>
<span>
{{@currentProgram.title}}
</span>
</div>
<div class="item" data-test-academic-year>
<label for="academicYear-{{templateId}}">
{{t "general.academicYear"}}:
</label>
<select
id="academicYear-{{templateId}}"
disabled={{this.save.isRunning}}
{{on "change" (pick "target.value" this.setSelectedYear)}}
>
{{#each this.years as |year|}}
<option
value={{year.id}}
selected={{eq year.id this.selectedYear.id}}
>{{year.title}}</option>
{{/each}}
</select>
</div>
<div class="buttons">
<button type="button" class="done text" {{on "click" (perform this.save)}} data-test-save>
{{#if this.save.isRunning}}
<LoadingSpinner />
{{else}}
{{t "general.done"}}
{{/if}}
</button>
<button type="button" class="cancel text" {{on "click" @cancel}} data-test-cancel>
{{t "general.cancel"}}
</button>
</div>
<h4>
{{t "general.newCurriculumInventoryReport"}}
</h4>
<div class="form">
<div class="item" data-test-name>
<label for="name-{{templateId}}">
{{t "general.name"}}:
</label>
<input
id="name-{{templateId}}"
type="text"
value={{this.name}}
disabled={{this.save.isRunning}}
placeholder={{t "general.reportNamePlaceholder"}}
{{on "focusout" (fn this.addErrorDisplayFor "name")}}
{{on "keyup" (perform this.keyboard)}}
{{on "input" (pick "target.value" (set this "name"))}}
{{on "keyup" (fn this.addErrorDisplayFor "name")}}
/>
<ValidationError @validatable={{this}} @property="name" />
</div>
{{/unless}}
<div class="item" data-test-description>
<label for="description-{{templateId}}">
{{t "general.description"}}:
</label>
<textarea
id="description-{{templateId}}"
disabled={{this.save.isRunning}}
placeholder={{t "general.reportDescriptionPlaceholder"}}
{{on "input" (pick "target.value" (set this "description"))}}
>{{this.description}}</textarea>
<ValidationError @validatable={{this}} @property="description" />
</div>
<div class="item" data-test-program-title>
<label>
{{t "general.program"}}:
</label>
<span>
{{@currentProgram.title}}
</span>
</div>
<div class="item" data-test-academic-year>
<label for="academicYear-{{templateId}}">
{{t "general.academicYear"}}:
</label>
<select
id="academicYear-{{templateId}}"
disabled={{this.save.isRunning}}
{{on "change" (pick "target.value" this.setSelectedYear)}}
>
{{#each this.years as |year|}}
<option
value={{year.id}}
selected={{eq year.id this.selectedYear}}
>{{year.title}}</option>
{{/each}}
</select>
</div>
<div class="buttons">
<button type="button" class="done text" {{on "click" (perform this.save)}} data-test-save>
{{#if this.save.isRunning}}
<LoadingSpinner />
{{else}}
{{t "general.done"}}
{{/if}}
</button>
<button type="button" class="cancel text" {{on "click" @cancel}} data-test-cancel>
{{t "general.cancel"}}
</button>
</div>
</div>
{{/let}}
</div>
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
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 { dropTask } from 'ember-concurrency';
import { TrackedAsyncData } from 'ember-async-data';
import { validatable, Length, NotBlank } from 'ilios-common/decorators/validation';
import { findById } from 'ilios-common/utils/array-helpers';
import { dropTask, restartableTask } from 'ember-concurrency';

@validatable
export default class CurriculumInventoryNewReportComponent extends Component {
@service store;
@service iliosConfig;
@service intl;

currentYear = new Date().getFullYear();
@tracked @NotBlank() @Length(1, 60) name;
@tracked @NotBlank() @Length(1, 21844) description;
@tracked selectedYear;
@tracked years = [];
@tracked academicYearCrossesCalendarYearBoundaries;

constructor() {
super(...arguments);
this.description = this.intl.t('general.curriculumInventoryReport');
this.selectedYear = this.currentYear;
}

load = restartableTask(async () => {
const years = [];
const currentYear = new Date().getFullYear();
this.academicYearCrossesCalendarYearBoundaries = await this.iliosConfig.itemFromConfig(
'academicYearCrossesCalendarYearBoundaries',
@cached
get academicYearCrossesCalendarYearBoundariesData() {
return new TrackedAsyncData(
this.iliosConfig.itemFromConfig('academicYearCrossesCalendarYearBoundaries'),
);
for (let id = currentYear - 5, n = currentYear + 5; id <= n; id++) {
let title = id.toString();
if (this.academicYearCrossesCalendarYearBoundaries) {
title = title + ' - ' + (id + 1);
}
const year = { id, title };
years.push(year);
}

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

get years() {
const rhett = [];
for (let year = this.currentYear - 5, n = this.currentYear + 5; year <= n; year++) {
rhett.push({
id: year,
title: this.academicYearCrossesCalendarYearBoundaries ? `${year} - ${year + 1}` : `${year}`,
});
}
this.years = years;
this.selectedYear = findById(years, currentYear);
});
return rhett;
}

save = dropTask(async () => {
this.addErrorDisplaysFor(['name', 'description']);
const isValid = await this.isValid();
if (!isValid) {
return false;
}
const year = this.selectedYear.id;
const year = this.selectedYear;
const startDate = this.academicYearCrossesCalendarYearBoundaries
? new Date(year, 6, 1)
: new Date(year, 0, 1);
Expand All @@ -67,8 +73,7 @@ export default class CurriculumInventoryNewReportComponent extends Component {

@action
setSelectedYear(year) {
const id = Number(year);
this.selectedYear = findById(this.years, id);
this.selectedYear = Number(year);
}

keyboard = dropTask(async (ev) => {
Expand Down
Loading