Skip to content

Commit

Permalink
Updated WineCellar demo
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Jul 28, 2024
1 parent 2732dd9 commit e494111
Show file tree
Hide file tree
Showing 6 changed files with 1,181 additions and 608 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object TabbedForm: TTabbedForm
StyleLookup = 'detailstoolbutton'
TabOrder = 1
Text = 'DrawerBtn'
TextSettings.Trimming = None
end
end
object TabControl1: TTabControl
Expand All @@ -53,6 +54,7 @@ object TabbedForm: TTabbedForm
CustomIcon = <
item
end>
TextSettings.Trimming = None
IsSelected = True
Size.Width = 8.000000000000000000
Size.Height = 8.000000000000000000
Expand All @@ -65,13 +67,13 @@ object TabbedForm: TTabbedForm
object BtnWineList: TButton
Action = acWineList
Align = Bottom
Enabled = True
ImageIndex = -1
Position.Y = 473.000000000000000000
Size.Width = 384.000000000000000000
Size.Height = 46.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
TextSettings.Trimming = None
end
object WineListView: TListView
ItemAppearanceClassName = 'TListItemRightDetailAppearance'
Expand All @@ -90,6 +92,7 @@ object TabbedForm: TTabbedForm
CustomIcon = <
item
end>
TextSettings.Trimming = None
IsSelected = False
Size.Width = 8.000000000000000000
Size.Height = 8.000000000000000000
Expand Down Expand Up @@ -184,12 +187,12 @@ object TabbedForm: TTabbedForm
object Button1: TButton
Action = acSaveWine
Align = Client
Enabled = True
ImageIndex = -1
Size.Width = 384.000000000000000000
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
TextSettings.Trimming = None
end
end
object EdtID: TEdit
Expand Down Expand Up @@ -265,39 +268,32 @@ object TabbedForm: TTabbedForm
Name = 'id'
FieldType = ftUInteger
Generator = 'AlphaColors'
ReadOnly = False
end
item
Name = 'name'
Generator = 'BitmapNames'
ReadOnly = False
end
item
Name = 'year'
FieldType = ftUInteger
Generator = 'AlphaColors'
ReadOnly = False
end
item
Name = 'grapes'
Generator = 'ColorsNames'
ReadOnly = False
end
item
Name = 'country'
Generator = 'ColorsNames'
ReadOnly = False
end
item
Name = 'region'
Generator = 'ColorsNames'
ReadOnly = False
end
item
Name = 'description'
FieldType = ftTStrings
Generator = 'LoremIpsum'
ReadOnly = False
end>
ScopeMappings = <>
OnCreateAdapter = PrototypeBindSource1CreateAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ TTabbedForm = class(TForm)
procedure ListBoxItem2Click(Sender: TObject);
procedure acSaveWineExecute(Sender: TObject);
private
WineRESTService: IWineResource;
WinesAdapter: TListBindSourceAdapter<TWine>;
fWineRESTService: IWineResource;
fWinesAdapter: TListBindSourceAdapter<TWine>;
{ Private declarations }
protected
function GetWine: TWine;
Expand Down Expand Up @@ -100,9 +100,9 @@ procedure TTabbedForm.acSaveWineExecute(Sender: TObject);
ChangeTabActionWineList.ExecuteTarget(Sender);
end, nil, true);
if Wine.id > 0 then
WineRESTService.UpdateWineById(Wine.id, Wine, AsynchReq)
fWineRESTService.UpdateWineById(Wine.id, Wine, AsynchReq)
else
WineRESTService.SaveWine(Wine, AsynchReq);
fWineRESTService.SaveWine(Wine, AsynchReq);
end;

procedure TTabbedForm.acWineListExecute(Sender: TObject);
Expand All @@ -112,10 +112,10 @@ procedure TTabbedForm.acWineListExecute(Sender: TObject);
AsynchReq := TAsynchRequest.Create(
procedure(AValue: TValue)
begin
WinesAdapter.SetList(AValue.AsType<TWines>);
WinesAdapter.Active := true;
fWinesAdapter.SetList(AValue.AsType<TWines>);
fWinesAdapter.Active := true;
end, nil, true);
WineRESTService.GetWineList(AsynchReq);
fWineRESTService.GetWineList(AsynchReq);
end;

procedure TTabbedForm.FormCreate(Sender: TObject);
Expand All @@ -126,7 +126,7 @@ procedure TTabbedForm.FormCreate(Sender: TObject);
TabControl1.ActiveTab := WineListTabItem;
// REST Service
RESTAdapter := TRESTAdapter<IWineResource>.Create;
WineRESTService := RESTAdapter.Build('localhost', 3000);
fWineRESTService := RESTAdapter.Build('localhost', 3000);
PrototypeBindSource1.Active := true;
end;

Expand All @@ -142,7 +142,7 @@ function TTabbedForm.GetWine: TWine;
Result.grapes := EdtGrapes.Text;
Result.country := EdtCountry.Text;
Result.region := EdtRegion.Text;
FWines := TObjectList<TWine>(WinesAdapter.List);
FWines := TObjectList<TWine>(fWinesAdapter.List);
Result.description := FWines[PrototypeBindSource1.ItemIndex].description;
end;

Expand All @@ -159,11 +159,12 @@ procedure TTabbedForm.ListBoxItem2Click(Sender: TObject);
MultiView1.HideMaster;
end;

procedure TTabbedForm.PrototypeBindSource1CreateAdapter(Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
procedure TTabbedForm.PrototypeBindSource1CreateAdapter(
Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
WinesAdapter := TListBindSourceAdapter<TWine>.Create(PrototypeBindSource1);
ABindSourceAdapter := WinesAdapter;
fWinesAdapter := TListBindSourceAdapter<TWine>.Create(PrototypeBindSource1);
ABindSourceAdapter := fWinesAdapter;
end;

procedure TTabbedForm.WineListViewItemClick(const Sender: TObject;
Expand Down
Loading

0 comments on commit e494111

Please sign in to comment.