MOBILE-2567 database: Fix change detection with number fields

main
Dani Palou 2018-09-05 11:18:32 +02:00
parent b67a2900eb
commit d15165ad98
1 changed files with 3 additions and 2 deletions

View File

@ -50,9 +50,10 @@ export class AddonModDataFieldNumberHandler extends AddonModDataFieldTextHandler
*/ */
hasFieldDataChanged(field: any, inputData: any, originalFieldData: any): Promise<boolean> | boolean { hasFieldDataChanged(field: any, inputData: any, originalFieldData: any): Promise<boolean> | boolean {
const fieldName = 'f_' + field.id, const fieldName = 'f_' + field.id,
input = typeof inputData[fieldName] != 'undefined' ? parseFloat(inputData[fieldName]) : ''; input = typeof inputData[fieldName] != 'undefined' && inputData[fieldName] !== null ?
parseFloat(inputData[fieldName]) : '';
originalFieldData = (originalFieldData && typeof originalFieldData.content != 'undefined') ? originalFieldData = (originalFieldData && typeof originalFieldData.content != 'undefined' && originalFieldData !== null) ?
parseFloat(originalFieldData.content) : ''; parseFloat(originalFieldData.content) : '';
return input != originalFieldData; return input != originalFieldData;