Fix table entity boolean and number type property values (#737)

This commit is contained in:
victor-meng 2021-04-29 17:23:21 -07:00 committed by GitHub
parent 5e0523c7d9
commit 9878bf0d5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View File

@ -328,7 +328,7 @@ export const EditTableEntityPanel: FunctionComponent<EditTableEntityPanelProps>
selectedKey={entity.type} selectedKey={entity.type}
entityPropertyPlaceHolder={detailedHelp} entityPropertyPlaceHolder={detailedHelp}
entityValuePlaceholder={entity.entityValuePlaceholder} entityValuePlaceholder={entity.entityValuePlaceholder}
entityValue={entity.value} entityValue={entity.value?.toString()}
isEntityTypeDate={entity.isEntityTypeDate} isEntityTypeDate={entity.isEntityTypeDate}
entityTimeValue={entity.entityTimeValue} entityTimeValue={entity.entityTimeValue}
isEntityValueDisable={entity.isEntityValueDisable} isEntityValueDisable={entity.isEntityValueDisable}

View File

@ -165,7 +165,7 @@ export function convertEntityToNewDocument(entity: Entities.ITableEntityForTable
$id: entity.RowKey._, $id: entity.RowKey._,
id: entity.RowKey._, id: entity.RowKey._,
}; };
for (var property in entity) { for (const property in entity) {
if ( if (
property !== Constants.EntityKeyNames.PartitionKey && property !== Constants.EntityKeyNames.PartitionKey &&
property !== Constants.EntityKeyNames.RowKey && property !== Constants.EntityKeyNames.RowKey &&
@ -176,18 +176,30 @@ export function convertEntityToNewDocument(entity: Entities.ITableEntityForTable
property !== keyProperties.attachments && property !== keyProperties.attachments &&
property !== keyProperties.Id2 property !== keyProperties.Id2
) { ) {
if (entity[property].$ === Constants.TableType.DateTime) { const propertyValue = entity[property]._;
// Convert javascript date back to ticks with 20 zeros padding let parsedValue;
document[property] = { switch (entity[property].$) {
$t: (<any>DataTypes)[entity[property].$], case Constants.TableType.DateTime:
$v: DateTimeUtilities.convertJSDateToTicksWithPadding(entity[property]._), parsedValue = DateTimeUtilities.convertJSDateToTicksWithPadding(propertyValue);
}; break;
} else { case Constants.TableType.Boolean:
document[property] = { parsedValue = propertyValue.toLowerCase() === "true";
$t: (<any>DataTypes)[entity[property].$], break;
$v: entity[property]._, case Constants.TableType.Int32:
}; case Constants.TableType.Int64:
parsedValue = parseInt(propertyValue, 10);
break;
case Constants.TableType.Double:
parsedValue = parseFloat(propertyValue);
break;
default:
parsedValue = propertyValue;
} }
document[property] = {
$t: (<any>DataTypes)[entity[property].$],
$v: parsedValue,
};
} }
} }
return document; return document;