Skip to content

Commit

Permalink
Merge branch 'Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arteha committed Dec 27, 2019
2 parents 743c46c + b0bec76 commit d860a1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin-bro-typeorm",
"version": "0.1.6-alpha.4",
"version": "0.1.6-alpha.5",
"description": "TypeORM adapter for AdminBro",
"keywords": [
"typeorm",
Expand Down
8 changes: 4 additions & 4 deletions src/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ export class Property extends BaseProperty

type = type || "string";

if(type == "string" && Reflect.getMetadata(TEXTAREA_SYMBOL, this.resource.model, this.name()))
if(
["string", "richtext"].includes(type) &&
Reflect.getMetadata(TEXTAREA_SYMBOL, this.resource.model, this.name())
)
return "textarea";
// TODO: Uncomment this in future.
/*if(Reflect.getMetadata(TEXTAREA_SYMBOL, this.resource.model, this.name()))
return "textarea";*/

return type;
}
Expand Down
15 changes: 7 additions & 8 deletions src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,16 @@ export class Resource extends BaseResource
for (const p in params)
{
const property = this.property(p);
if(property)
if(property && params[p])
{
if(property.type() === "mixed")
if(["mixed", "boolean"].includes(property.type()))
params[p] = JSON.parse(params[p]);
if(property.type() === "number" && params[p] && params[p].toString().length)
params[p] = +params[p];
if(property.type() === "reference" && params[p] && params[p].toString().length)
{
// references can be stored as an IDs in typeorm:
else if(["number", "float"].includes(property.type()))
params[p] = Number(params[p]);
else if(["date", "datetime"].includes(property.type()))
params[p] = new Date(params[p]);
else if(property.type() == "reference")
params[property.column.propertyName] = +params[p];
}
}
}
return params;
Expand Down

0 comments on commit d860a1e

Please sign in to comment.