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 Reporting render modifiers #8352

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions packages/frontend/.lint-todo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ add|ember-template-lint|no-at-ember-render-modifiers|5|2|5|2|23cd787c79c34a628da
add|ember-template-lint|no-at-ember-render-modifiers|6|2|6|2|e5120f87b74c5ae8e4c76b9089e0b4a4504c6e3c|1731542400000|1762646400000|1793750400000|app/components/user-profile-roles.hbs
add|ember-template-lint|no-at-ember-render-modifiers|3|2|3|2|1fb0566922ce4f066916e5e2931f650f69d7cfba|1731542400000|1762646400000|1793750400000|app/components/visualizer-program-year-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|4|2|4|2|38e65b45b56fdfd4160d3b0884114b6643e3a036|1731542400000|1762646400000|1793750400000|app/components/visualizer-program-year-objectives.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/academic-year.hbs
add|ember-template-lint|no-at-ember-render-modifiers|11|6|11|6|940005188b476a060b0e5d3f05baea24ba178878|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/academic-year.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/competency.hbs
add|ember-template-lint|no-at-ember-render-modifiers|11|6|11|6|940005188b476a060b0e5d3f05baea24ba178878|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/competency.hbs
add|ember-template-lint|no-at-ember-render-modifiers|10|6|10|6|d919d2af254f782c01fe2ba15416673e52e91124|1731542400000|1762646400000|1793750400000|app/components/reports/subject/new/instructor-group.hbs
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/app/components/reports/new-subject.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export default class ReportsNewSubjectComponent extends Component {

get newPrepositionalObjectComponent() {
switch (this.prepositionalObject) {
case 'academic year':
return ensureSafeComponent(NewAcademicYearComponent, this);
case 'competency':
return ensureSafeComponent(NewCompetencyComponent, this);
case 'course':
Expand All @@ -237,8 +239,6 @@ export default class ReportsNewSubjectComponent extends Component {
return ensureSafeComponent(NewSessionTypeComponent, this);
case 'term':
return ensureSafeComponent(NewTermComponent, this);
case 'academic year':
return ensureSafeComponent(NewAcademicYearComponent, this);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
<label for="new-term">
{{t "general.whichIs"}}
</label>
{{#if this.isLoaded}}
{{#if this.academicYearsData.isResolved}}
<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}}>
<option selected={{eq year.id this.bestSelectedAcademicYear}} value={{year.id}}>
{{#if this.academicYearCrossesCalendarYearBoundaries}}
{{year.id}}
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ export default class ReportsSubjectNewAcademicYearComponent extends Component {
@service store;
@service iliosConfig;

constructor() {
super(...arguments);
console.log('this.args', this.args);
// this.setInitialValue.perform();
}

@cached
get data() {
get academicYearsData() {
return new TrackedAsyncData(this.store.findAll('academic-year'));
}

get academicYears() {
return this.academicYearsData.isResolved ? this.academicYearsData.value : [];
}

get bestSelectedAcademicYear() {
if (this.academicYears.map(({ id }) => id).includes(this.args.currentId)) {
return this.args.currentId;
}

return this.academicYears.find(({ id }) => Number(id) === currentAcademicYear())?.id;
}

crossesBoundaryConfig = new TrackedAsyncData(
this.iliosConfig.itemFromConfig('academicYearCrossesCalendarYearBoundaries'),
);
Expand All @@ -23,23 +41,15 @@ export default class ReportsSubjectNewAcademicYearComponent extends Component {
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
setInitialValue = task(async () => {
await 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;
}
const currentYear = currentAcademicYear();
const currentYearId = this.academicYears.find(({ id }) => Number(id) === currentYear)?.id;
this.args.changeId(currentYearId ?? ids.at(-1));
}
const newId = currentYearId ?? ids.at(-1);
this.args.changeId(newId);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module('Integration | Component | reports/subject/new/academic-year', function (
});

test('it renders', async function (assert) {
assert.expect(14);
assert.expect(13);
this.set('currentId', null);
this.set('changeId', (id) => {
assert.strictEqual(id, '2060');
Expand All @@ -37,28 +37,27 @@ module('Integration | Component | reports/subject/new/academic-year', function (
@school={{null}}
/>`);

assert.strictEqual(component.options.length, 3);
assert.strictEqual(component.options[0].text, '2015');
assert.strictEqual(component.options[1].text, '2031');
assert.strictEqual(component.options[2].text, '2060');
assert.strictEqual(component.options.length, 3, 'dropdown has 3 options');
assert.strictEqual(component.options[0].text, '2015', 'first option is 2015');
assert.strictEqual(component.options[1].text, '2031', 'second option is 2031');
assert.strictEqual(component.options[2].text, '2060', 'third option is 2060');

assert.strictEqual(component.value, '2060');
assert.strictEqual(component.value, '2060', 'selected option is 2060');

assert.notOk(component.options[0].isSelected);
assert.notOk(component.options[1].isSelected);
assert.ok(component.options[2].isSelected);
assert.notOk(component.options[0].isSelected, 'option 0 is not selected');
assert.notOk(component.options[1].isSelected, 'option 1 is not selected');
assert.ok(component.options[2].isSelected, 'option 2 is selected');

this.set('changeId', (id) => {
assert.strictEqual(id, '2031');
this.set('currentId', id);
});

this.set('currentId', '2031');
assert.notOk(component.options[0].isSelected);
assert.notOk(component.options[0].isSelected);
assert.ok(component.options[1].isSelected);
assert.notOk(component.options[2].isSelected);
assert.strictEqual(component.value, '2031');
assert.notOk(component.options[0].isSelected, 'option 0 is not selected');
assert.ok(component.options[1].isSelected, 'option 1 is selected');
assert.notOk(component.options[2].isSelected, 'option 2 is not selected');
assert.strictEqual(component.value, '2031', 'selected option is 2031');
});

test('it works', async function (assert) {
Expand All @@ -73,14 +72,14 @@ module('Integration | Component | reports/subject/new/academic-year', function (
assert.strictEqual(id, '2031');
this.set('currentId', id);
});
assert.ok(component.options[0].isSelected);
assert.notOk(component.options[1].isSelected);
assert.notOk(component.options[2].isSelected);
assert.ok(component.options[0].isSelected, 'option 0 is selected');
assert.notOk(component.options[1].isSelected, 'option 1 is not selected');
assert.notOk(component.options[2].isSelected, 'option 2 is not selected');

await component.set('2031');
assert.notOk(component.options[0].isSelected);
assert.ok(component.options[1].isSelected);
assert.notOk(component.options[2].isSelected);
assert.strictEqual(component.value, '2031');
assert.notOk(component.options[0].isSelected, 'option 0 is not selected');
assert.ok(component.options[1].isSelected, 'option 1 is selected');
assert.notOk(component.options[2].isSelected, 'option 2 is not selected');
assert.strictEqual(component.value, '2031', 'selected option is 2031');
});
});
Loading