Skip to content

Commit

Permalink
Merge pull request #7877 from michaelchadwick/normalize-format-date-i…
Browse files Browse the repository at this point in the history
…n-cur-inv

normalize date format displays in Curriculum Inventory Reports
  • Loading branch information
dartajax authored Jun 13, 2024
2 parents 2ed985c + b66685d commit bb49a71
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
colspan="2"
data-test-start-date
>
{{format-date @report.startDate}}
{{format-date @report.startDate day="2-digit" month="2-digit" year="numeric"}}
</td>
<td
class="text-center hide-from-small-screen"
colspan="2"
data-test-end-date
>
{{format-date @report.endDate}}
{{format-date @report.endDate day="2-digit" month="2-digit" year="numeric"}}
</td>
<td
class="text-center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<span>
{{#if @canUpdate}}
<EditableField
@value={{format-date @report.startDate}}
@value={{format-date @report.startDate day="2-digit" month="2-digit" year="numeric"}}
@save={{perform this.changeStartDate}}
@close={{this.revertStartDateChanges}}
>
Expand All @@ -60,7 +60,7 @@
<ValidationError @errors={{get-errors-for this.startDate}} />
</EditableField>
{{else}}
{{format-date @report.startDate}}
{{format-date @report.startDate day="2-digit" month="2-digit" year="numeric"}}
{{/if}}
</span>
</div>
Expand All @@ -71,7 +71,7 @@
<span>
{{#if @canUpdate}}
<EditableField
@value={{format-date @report.endDate}}
@value={{format-date @report.endDate day="2-digit" month="2-digit" year="numeric"}}
@save={{perform this.changeEndDate}}
@close={{this.revertEndDateChanges}}
>
Expand All @@ -83,7 +83,7 @@
<ValidationError @errors={{get-errors-for this.endDate}} />
</EditableField>
{{else}}
{{format-date @report.endDate}}
{{format-date @report.endDate day="2-digit" month="2-digit" year="numeric"}}
{{/if}}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
</td>
<td class="text-center hide-from-small-screen" colspan="2" data-test-start-date>
{{#if @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.notApplicableAbbr"}}
{{/if}}
</td>
<td class="text-center hide-from-small-screen" colspan="2" data-test-end-date>
{{#if @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.notApplicableAbbr"}}
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
{{#if this.course}}
<span class="details" data-test-course-details>
{{t "general.level"}}: {{this.course.level}},
{{t "general.startDate"}}: {{format-date this.course.startDate}},
{{t "general.endDate"}}: {{format-date this.course.endDate}}
{{t "general.startDate"}}: {{format-date this.course.startDate day="2-digit" month="2-digit" year="numeric"}},
{{t "general.endDate"}}: {{format-date this.course.endDate day="2-digit" month="2-digit" year="numeric"}}
{{#if this.course.clerkshipType}}
- {{t "general.clerkship"}} ({{this.course.clerkshipType.title}})
{{/if}}
Expand Down Expand Up @@ -176,15 +176,15 @@
{{on "click" (set this.isEditingDatesAndDuration true)}}
>
{{#if @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.clickToEdit"}}
{{/if}}
</button>
{{else}}
<span>
{{#if @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate}}
{{format-date @sequenceBlock.startDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.notApplicableAbbr"}}
{{/if}}
Expand All @@ -201,15 +201,15 @@
{{on "click" (set this.isEditingDatesAndDuration true)}}
>
{{#if @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.clickToEdit"}}
{{/if}}
</button>
{{else}}
<span>
{{#if @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate}}
{{format-date @sequenceBlock.endDate day="2-digit" month="2-digit" year="numeric"}}
{{else}}
{{t "general.notApplicableAbbr"}}
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,22 @@ module('Integration | Component | curriculum-inventory/report-list-item', functi
assert.strictEqual(component.name, 'CI Report');
assert.strictEqual(component.program, 'program 0');
assert.strictEqual(component.year, '2017');
assert.strictEqual(component.startDate, this.intl.formatDate(this.report.startDate));
assert.strictEqual(component.endDate, this.intl.formatDate(this.report.endDate));
assert.strictEqual(
component.startDate,
this.intl.formatDate(this.report.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(
component.endDate,
this.intl.formatDate(this.report.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(component.status, 'Draft');
assert.ok(component.isDeletable);
assert.notOk(component.confirmRemoval.isVisible);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ module('Integration | Component | curriculum-inventory/report-list', function (h
assert.strictEqual(component.reports[0].year, '2016', 'Academic year shows.');
assert.strictEqual(
component.reports[0].startDate,
this.intl.formatDate(reportModel2.startDate),
this.intl.formatDate(reportModel2.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Start date shows.',
);
assert.strictEqual(
component.reports[0].endDate,
this.intl.formatDate(reportModel2.endDate),
this.intl.formatDate(reportModel2.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'End date shows.',
);
assert.strictEqual(component.reports[0].status, 'Finalized', 'Status shows.');
Expand All @@ -111,12 +119,20 @@ module('Integration | Component | curriculum-inventory/report-list', function (h
assert.strictEqual(component.reports[1].year, '2017', 'Academic year shows.');
assert.strictEqual(
component.reports[1].startDate,
this.intl.formatDate(reportModel1.startDate),
this.intl.formatDate(reportModel1.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Start date shows.',
);
assert.strictEqual(
component.reports[1].endDate,
this.intl.formatDate(reportModel1.endDate),
this.intl.formatDate(reportModel1.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'End date shows.',
);
assert.strictEqual(component.reports[1].status, 'Draft', 'Status shows.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ module('Integration | Component | curriculum-inventory/report-overview', functio
assert.strictEqual(component.startDate.label, 'Start:', 'Start date label is correct.');
assert.strictEqual(
component.startDate.text,
this.intl.formatDate(reportModel.startDate),
this.intl.formatDate(reportModel.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Start date is visible.',
);
assert.strictEqual(component.endDate.label, 'End:', 'End date label is correct.');
assert.strictEqual(
component.endDate.text,
this.intl.formatDate(reportModel.endDate),
this.intl.formatDate(reportModel.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'End date is visible.',
);
assert.strictEqual(
Expand Down Expand Up @@ -102,12 +110,20 @@ module('Integration | Component | curriculum-inventory/report-overview', functio
);
assert.strictEqual(
component.startDate.readOnlyText,
this.intl.formatDate(reportModel.startDate),
this.intl.formatDate(reportModel.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Start date is visible.',
);
assert.strictEqual(
component.endDate.readOnlyText,
this.intl.formatDate(reportModel.endDate),
this.intl.formatDate(reportModel.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'End date is visible.',
);
assert.strictEqual(
Expand Down Expand Up @@ -204,7 +220,11 @@ module('Integration | Component | curriculum-inventory/report-overview', functio
await component.startDate.save();
assert.strictEqual(
component.startDate.text,
this.intl.formatDate(newVal),
this.intl.formatDate(newVal, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Edit link shown new start date post-update.',
);
assert.strictEqual(
Expand Down Expand Up @@ -249,7 +269,11 @@ module('Integration | Component | curriculum-inventory/report-overview', functio
await component.endDate.save();
assert.strictEqual(
component.endDate.text,
this.intl.formatDate(newVal),
this.intl.formatDate(newVal, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
'Edit link shown new end date post-update.',
);
assert.strictEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list-item'
assert.strictEqual(component.orderInSequence, '3');
assert.strictEqual(
component.startDate,
this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 3, day: 17 }).toJSDate()),
this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 3, day: 17 }).toJSDate(), {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(
component.endDate,
this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 5, day: 22 }).toJSDate()),
this.intl.formatDate(DateTime.fromObject({ year: 2021, month: 5, day: 22 }).toJSDate(), {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(component.course, 'course 0');
assert.ok(component.isDeletable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list', fun
assert.strictEqual(component.list.items[1].orderInSequence, 'n/a');
assert.strictEqual(
component.list.items[1].startDate,
this.intl.formatDate(this.sequenceBlock1.startDate),
this.intl.formatDate(this.sequenceBlock1.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(
component.list.items[1].endDate,
this.intl.formatDate(this.sequenceBlock1.endDate),
this.intl.formatDate(this.sequenceBlock1.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(component.list.items[1].course, this.course.title);
assert.ok(component.list.items[1].isDeletable);
Expand Down Expand Up @@ -191,11 +199,19 @@ module('Integration | Component | curriculum-inventory/sequence-block-list', fun
assert.strictEqual(component.list.items[1].orderInSequence, 'n/a');
assert.strictEqual(
component.list.items[1].startDate,
this.intl.formatDate(this.sequenceBlock1.startDate),
this.intl.formatDate(this.sequenceBlock1.startDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(
component.list.items[1].endDate,
this.intl.formatDate(this.sequenceBlock1.endDate),
this.intl.formatDate(this.sequenceBlock1.endDate, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
}),
);
assert.strictEqual(component.list.items[1].course, this.course.title);
assert.ok(component.list.items[1].isDeletable);
Expand Down
Loading

0 comments on commit bb49a71

Please sign in to comment.