fix: 🐛 Fix null date time erroring out (#1623)

* fix: 🐛 Fix null date time erroring out

* style: 💄 Remove braces in if statement
This commit is contained in:
Zhihe Li authored and GitHub committed 2023-02-03 17:53:30 -05:00
1 parent 2d6e26de84
commit 82bee42959
3 files changed
+14 -1

No files matched your search

@@ -45,6 +45,8 @@ export default class extends Helper {
// =methods
compute([date]) {
if (!date) return;
const delta = date.valueOf() - this.clockTick.now;
const greatestMeaningfulUnit = unitMappings.reduce(
(currentValue, previousValue) => {
@@ -53,4 +53,12 @@ module('Integration | Helper | relative-datetime-live', function (hooks) {
await render(hbs`{{relative-datetime-live this.date}}`);
assert.dom(this.element).hasText('in 22 years');
});
test('it renders nothing when there is no date', async function (assert) {
assert.expect(1);
this.date = null;
await render(hbs`{{relative-datetime-live this.date}}`);
assert.dom(this.element).hasText('');
});
});
@@ -99,7 +99,10 @@
<form.input
@name='last seen'
@type='datetime'
@value={{concat relativeDate ', ' customFormat}}
@value={{if
@model.last_status_time
(concat relativeDate ', ' customFormat)
}}
@label={{t 'form.worker_last_seen.label'}}
@helperText={{t 'form.worker_last_seen.help'}}
@disabled={{true}}