Skip to content

Commit

Permalink
BugFix #1
Browse files Browse the repository at this point in the history
Falha no GetFieldsByType em condição única #1
  • Loading branch information
bittencourtthulio committed Apr 10, 2021
1 parent b066f17 commit ba3884f
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 21 deletions.
71 changes: 71 additions & 0 deletions src/Bind4D.Attributes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface
fvNotNull = class(TCustomAttribute)
private
FMsg: String;
FKey : String;
procedure SetMsg(const Value: String);
public
constructor Create(aMsg : String);
Expand All @@ -22,6 +23,7 @@ fvNotNull = class(TCustomAttribute)
FormDefault = class(TCustomAttribute)
private
FTitle: String;
FKey : String;
procedure SetTitle(const Value: String);
public
constructor Create ( aTitle : String = '' );
Expand All @@ -34,6 +36,7 @@ FormRest = class(TCustomAttribute)
FEndPoint: String;
FOrder: String;
FSort: String;
FKey : String;
procedure SetEndPoint(const Value: String);
procedure SetPK(const Value: String);
procedure SetOrderBy(const Value: String);
Expand All @@ -52,6 +55,7 @@ S3Storage = class(TCustomAttribute)
private
FFileExtension: String;
FContentType: String;
FKey : String;
procedure SetContentType(const Value: String);
procedure SetFileExtension(const Value: String);
public
Expand All @@ -63,6 +67,7 @@ S3Storage = class(TCustomAttribute)
Translation = class(TCustomAttribute)
private
FQuery: String;
FKey : String;
procedure SetQuery(const Value: String);
public
constructor Create(aQuery : String);
Expand All @@ -73,13 +78,18 @@ Translation = class(TCustomAttribute)
{$region 'Components Attributes'}

AdjustResponsive = class(TCustomAttribute)
private
FKey : String;
public
constructor Create;
end;

ImageAttribute = class(TCustomAttribute)
private
FDefaultResourceImage: String;
FWidth: Integer;
FHeigth: Integer;
FKey : String;
procedure SetDefaultResourceImage(const Value: String);
procedure SetHeigth(const Value: Integer);
procedure SetWidth(const Value: Integer);
Expand All @@ -97,6 +107,7 @@ ComponentBindStyle = class(TCustomAttribute)
FFontColor: TColor;
FFontName: String;
FEspecialType: TEspecialType;
FKey : String;
procedure SetColor(const Value: TColor);
procedure SetFontColor(const Value: TColor);
procedure SetFontSize(const Value: Integer);
Expand All @@ -114,6 +125,7 @@ ComponentBindStyle = class(TCustomAttribute)
ComponentBindFormat = class(TCustomAttribute)
private
FEspecialType: TEspecialType;
FKey : String;
procedure SetEspecialType(const Value: TEspecialType);
public
constructor Create(aEspecialType : TEspecialType = teNull);
Expand All @@ -125,22 +137,39 @@ ComponentBindFormat = class(TCustomAttribute)
FieldJsonBind = class(TCustomAttribute)
private
FJsonName: string;
FKey : String;
procedure SetJsonName(const Value: string);
public
constructor Create(aJsonName: string);
property JsonName : string read FJsonName write SetJsonName;
end;

FbIgnorePut = class(TCustomAttribute)
private
FKey : String;
public
constructor Create;
end;

FbIgnorePost = class(TCustomAttribute)
private
FKey : String;
public
constructor Create;
end;

FbIgnoreDelete = class(TCustomAttribute)
private
FKey : String;
public
constructor Create;
end;

FbIgnoreGet = class(TCustomAttribute)
private
FKey : String;
public
constructor Create;
end;
{$endregion}

Expand All @@ -155,6 +184,7 @@ FieldDataSetBind = class(TCustomAttribute)
FAlignment: TAlignment;
FEditMask: String;
FFLimitWidth: Integer;
FKey : String;
procedure SetFieldName(const Value: String);
procedure SetDisplayName(const Value: String);
procedure SetWidth(const Value: Integer);
Expand All @@ -179,11 +209,14 @@ FieldDataSetBind = class(TCustomAttribute)

implementation

uses
System.SysUtils;
{ fvNotNull }

constructor fvNotNull.Create(aMsg: String);
begin
FMsg := aMsg;
FKey := TGuid.NewGuid.ToString;
end;

procedure fvNotNull.SetMsg(const Value: String);
Expand All @@ -196,6 +229,7 @@ procedure fvNotNull.SetMsg(const Value: String);
constructor FormDefault.Create(aTitle: String);
begin
FTitle := aTitle;
FKey := TGuid.NewGuid.ToString;
end;

procedure FormDefault.SetTitle(const Value: String);
Expand All @@ -211,6 +245,7 @@ constructor FormRest.Create(aEndPoint, aPK, aSort, aOrder: String);
FPK := aPK;
FOrder := aOrder;
FSort := aSort;
FKey := TGuid.NewGuid.ToString;
end;

procedure FormRest.SetEndPoint(const Value: String);
Expand Down Expand Up @@ -238,6 +273,7 @@ procedure FormRest.SetSort(const Value: String);
constructor Translation.Create(aQuery : String);
begin
FQuery := aQuery;
FKey := TGuid.NewGuid.ToString;
end;

procedure Translation.SetQuery(const Value: String);
Expand All @@ -251,6 +287,7 @@ constructor S3Storage.Create(aFileExtension : String; aContentType : String);
begin
FFileExtension := aFileExtension;
FContentType := aContentType;
FKey := TGuid.NewGuid.ToString;
end;

procedure S3Storage.SetContentType(const Value: String);
Expand All @@ -268,6 +305,7 @@ procedure S3Storage.SetFileExtension(const Value: String);
constructor ComponentBindFormat.Create(aEspecialType: TEspecialType);
begin
FEspecialType := aEspecialType;
FKey := TGuid.NewGuid.ToString;
end;

procedure ComponentBindFormat.SetEspecialType(const Value: TEspecialType);
Expand All @@ -285,6 +323,7 @@ constructor ComponentBindStyle.Create(aColor: TColor; aFontSize: Integer;
FFontColor := aFontColor;
FFontName := aFontName;
FEspecialType := aEspecialType;
FKey := TGuid.NewGuid.ToString;
end;

procedure ComponentBindStyle.SetColor(const Value: TColor);
Expand Down Expand Up @@ -319,6 +358,7 @@ constructor ImageAttribute.Create( aDefaultResourceImage : String; aWidth : Inte
FDefaultResourceImage := aDefaultResourceImage;
FWidth := aWidth;
FHeigth := aHeigth;
FKey := TGuid.NewGuid.ToString;
end;

procedure ImageAttribute.SetDefaultResourceImage(const Value: String);
Expand All @@ -341,6 +381,7 @@ procedure ImageAttribute.SetWidth(const Value: Integer);
constructor FieldJsonBind.Create(aJsonName: string);
begin
FJsonName := aJsonName;
FKey := TGuid.NewGuid.ToString;
end;

procedure FieldJsonBind.SetJsonName(const Value: string);
Expand All @@ -362,6 +403,7 @@ constructor FieldDataSetBind.Create(aFieldName: String; aFdType: TFieldType;
FEditMask := aEditMask;
FFdType := aFdType;
FLimitWidth := aLimitWidth;
FKey := TGuid.NewGuid.ToString;
end;

procedure FieldDataSetBind.SetAlignment(const Value: TAlignment);
Expand Down Expand Up @@ -404,4 +446,33 @@ procedure FieldDataSetBind.SetWidth(const Value: Integer);
FWidth := Value;
end;

{ AdjustResponsive }

constructor FbIgnorePut.Create;
begin
FKey := TGuid.NewGuid.ToString;
end;

constructor AdjustResponsive.Create;
begin
FKey := TGuid.NewGuid.ToString;
end;

constructor FbIgnorePost.Create;
begin
FKey := TGuid.NewGuid.ToString;
end;

{ FbIgnoreGet }

constructor FbIgnoreGet.Create;
begin
FKey := TGuid.NewGuid.ToString;
end;

constructor FbIgnoreDelete.Create;
begin
FKey := TGuid.NewGuid.ToString;
end;

end.
1 change: 1 addition & 0 deletions src/Bind4D.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface
function SetStyleComponents : iBind4D;
function SetCaptionComponents : iBind4D;
function SetImageComponents : iBind4D;
function ClearCacheComponents : iBind4D;
function Translator : iTranslator4D;
function AWSService : iAWS4D;
end;
Expand Down
16 changes: 16 additions & 0 deletions src/Bind4D.Types.Delete.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TBind4DTypesDelete = class(TInterfacedObject, iBind4DTypesInterface)
constructor Create;
destructor Destroy; override;
class function New : iBind4DTypesInterface;
function TryGetJsonName(aComponent : TComponent; out aJsonName : String ) : Boolean;
function GetJsonName (aComponent : TComponent) : String;
procedure TryAddJsonPair( aComponent : TComponent; var aJsonObject : TJsonObject);
end;
Expand Down Expand Up @@ -61,4 +62,19 @@ procedure TBind4DTypesDelete.TryAddJsonPair(aComponent: TComponent;
aJsonObject.AddPair(aAttrJson.JsonName, TBind4DComponentUtils.GetValueString(aComponent));
end;

function TBind4DTypesDelete.TryGetJsonName(aComponent: TComponent;
out aJsonName: String): Boolean;
var
aAttrIg : FbIgnoreDelete;
aAttrFJBind : FieldJsonBind;
begin
Result := False;
if not RttiUtils.TryGet<FbIgnoreDelete>(aComponent, aAttrIg) then
if RttiUtils.TryGet<FieldJsonBind>(aComponent, aAttrFJBind) then
begin
Result := True;
aJsonName := aAttrFJBind.JsonName;
end;
end;

end.
16 changes: 16 additions & 0 deletions src/Bind4D.Types.Get.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TBind4DTypesGet = class(TInterfacedObject, iBind4DTypesInterface)
destructor Destroy; override;
class function New : iBind4DTypesInterface;
function GetJsonName (aComponent : TComponent) : String;
function TryGetJsonName(aComponent : TComponent; out aJsonName : String ) : Boolean;
procedure TryAddJsonPair( aComponent : TComponent; var aJsonObject : TJsonObject);
end;

Expand Down Expand Up @@ -59,4 +60,19 @@ procedure TBind4DTypesGet.TryAddJsonPair(aComponent: TComponent;
aJsonObject.AddPair(aAttrFJBind.JsonName, TBind4DComponentUtils.GetValueString(aComponent));
end;

function TBind4DTypesGet.TryGetJsonName(aComponent: TComponent;
out aJsonName: String): Boolean;
var
aAttrIgGet : FbIgnoreGet;
aAttrFJBind : FieldJsonBind;
begin
Result := False;
if not RttiUtils.TryGet<FbIgnoreGet>(aComponent, aAttrIgGet) then
if RttiUtils.TryGet<FieldJsonBind>(aComponent, aAttrFJBind) then
begin
Result := True;
aJsonName := aAttrFJBind.JsonName;
end;
end;

end.
1 change: 1 addition & 0 deletions src/Bind4D.Types.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface
iBind4DTypesInterface = interface
['{EA313825-7246-4171-8E8C-FCA8C5B54880}']
function GetJsonName (aComponent : TComponent) : String;
function TryGetJsonName(aComponent : TComponent; out aJsonName : String ) : Boolean;
procedure TryAddJsonPair( aComponent : TComponent; var aJsonObject : TJsonObject);
end;

Expand Down
16 changes: 16 additions & 0 deletions src/Bind4D.Types.Post.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TBind4DTypesPost = class(TInterfacedObject, iBind4DTypesInterface)
destructor Destroy; override;
class function New : iBind4DTypesInterface;
function GetJsonName (aComponent : TComponent) : String;
function TryGetJsonName(aComponent : TComponent; out aJsonName : String ) : Boolean;
procedure TryAddJsonPair( aComponent : TComponent; var aJsonObject : TJsonObject);
end;

Expand Down Expand Up @@ -61,4 +62,19 @@ procedure TBind4DTypesPost.TryAddJsonPair(aComponent: TComponent;
aJsonObject.AddPair(aAttrJson.JsonName, TBind4DComponentUtils.GetValueString(aComponent));
end;

function TBind4DTypesPost.TryGetJsonName(aComponent: TComponent;
out aJsonName: String): Boolean;
var
aAttrIg : FbIgnorePost;
aAttrFJBind : FieldJsonBind;
begin
Result := False;
if not RttiUtils.TryGet<FbIgnorePost>(aComponent, aAttrIg) then
if RttiUtils.TryGet<FieldJsonBind>(aComponent, aAttrFJBind) then
begin
Result := True;
aJsonName := aAttrFJBind.JsonName;
end;
end;

end.
16 changes: 16 additions & 0 deletions src/Bind4D.Types.Put.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TBind4DTypesPut = class(TInterfacedObject, iBind4DTypesInterface)
constructor Create;
destructor Destroy; override;
class function New : iBind4DTypesInterface;
function TryGetJsonName(aComponent : TComponent; out aJsonName : String ) : Boolean;
function GetJsonName (aComponent : TComponent) : String;
procedure TryAddJsonPair( aComponent : TComponent; var aJsonObject : TJsonObject);
end;
Expand Down Expand Up @@ -61,4 +62,19 @@ procedure TBind4DTypesPut.TryAddJsonPair(aComponent: TComponent;
aJsonObject.AddPair(aAttrJson.JsonName, TBind4DComponentUtils.GetValueString(aComponent));
end;

function TBind4DTypesPut.TryGetJsonName(aComponent: TComponent;
out aJsonName: String): Boolean;
var
aAttrIg : FbIgnorePut;
aAttrFJBind : FieldJsonBind;
begin
Result := False;
if not RttiUtils.TryGet<FbIgnorePut>(aComponent, aAttrIg) then
if RttiUtils.TryGet<FieldJsonBind>(aComponent, aAttrFJBind) then
begin
Result := True;
aJsonName := aAttrFJBind.JsonName;
end;
end;

end.
Loading

0 comments on commit ba3884f

Please sign in to comment.