MOBILE-3320 database: Fix some fields not displayed

main
Dani Palou 2021-06-29 09:26:39 +02:00
parent 331fd9fef9
commit 0607bd7f58
2 changed files with 9 additions and 5 deletions

View File

@ -36,6 +36,10 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo
*/ */
protected init(): void { protected init(): void {
if (this.displayMode) { if (this.displayMode) {
this.displayDate = this.value?.content
? parseInt(this.value.content, 10) * 1000
: undefined;
return; return;
} }
@ -62,10 +66,6 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo
? new Date(parseInt(this.value.content, 10) * 1000) ? new Date(parseInt(this.value.content, 10) * 1000)
: new Date(); : new Date();
this.displayDate = this.value?.content
? parseInt(this.value.content, 10) * 1000
: undefined;
} }
this.addControl('f_' + this.field.id, CoreTimeUtils.toDatetimeFormat(date.getTime())); this.addControl('f_' + this.field.id, CoreTimeUtils.toDatetimeFormat(date.getTime()));

View File

@ -407,7 +407,11 @@ export class CoreDomUtilsProvider {
return size; return size;
} }
size = Number(size); if (typeof size == 'string') {
// It's important to use parseInt instead of Number because Number('') is 0 instead of NaN.
size = parseInt(size, 10);
}
if (!isNaN(size)) { if (!isNaN(size)) {
return size + 'px'; return size + 'px';
} }