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:
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
|
// =methods
|
||||||
|
|
||||||
compute([date]) {
|
compute([date]) {
|
||||||
|
if (!date) return;
|
||||||
|
|
||||||
const delta = date.valueOf() - this.clockTick.now;
|
const delta = date.valueOf() - this.clockTick.now;
|
||||||
const greatestMeaningfulUnit = unitMappings.reduce(
|
const greatestMeaningfulUnit = unitMappings.reduce(
|
||||||
(currentValue, previousValue) => {
|
(currentValue, previousValue) => {
|
||||||
|
|||||||
@@ -53,4 +53,12 @@ module('Integration | Helper | relative-datetime-live', function (hooks) {
|
|||||||
await render(hbs`{{relative-datetime-live this.date}}`);
|
await render(hbs`{{relative-datetime-live this.date}}`);
|
||||||
assert.dom(this.element).hasText('in 22 years');
|
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
|
<form.input
|
||||||
@name='last seen'
|
@name='last seen'
|
||||||
@type='datetime'
|
@type='datetime'
|
||||||
@value={{concat relativeDate ', ' customFormat}}
|
@value={{if
|
||||||
|
@model.last_status_time
|
||||||
|
(concat relativeDate ', ' customFormat)
|
||||||
|
}}
|
||||||
@label={{t 'form.worker_last_seen.label'}}
|
@label={{t 'form.worker_last_seen.label'}}
|
||||||
@helperText={{t 'form.worker_last_seen.help'}}
|
@helperText={{t 'form.worker_last_seen.help'}}
|
||||||
@disabled={{true}}
|
@disabled={{true}}
|
||||||
|
|||||||
Reference in new issue
Block a user