From 7ebb0681d50eb934df33d88e04bbec7456c1fa31 Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Mon, 4 Sep 2023 11:29:05 +0200 Subject: [PATCH] no message --- samples/htmx/Classes/uData.Model.pas | 1 - samples/htmx/Classes/uServices.pas | 19 +++++++-------- .../htmx/Controllers/uMovie.Controller.pas | 15 ++++++++---- samples/htmx/HTMX_Sample.dpr | 3 ++- samples/htmx/HTMX_Sample.dproj | 23 +++---------------- .../htmx}/MVCFramework.HTMX.pas | 2 +- samples/htmx/bin/data/data.json | 2 +- 7 files changed, 25 insertions(+), 40 deletions(-) rename {sources => samples/htmx}/MVCFramework.HTMX.pas (99%) diff --git a/samples/htmx/Classes/uData.Model.pas b/samples/htmx/Classes/uData.Model.pas index aa698d0f..92c93411 100644 --- a/samples/htmx/Classes/uData.Model.pas +++ b/samples/htmx/Classes/uData.Model.pas @@ -7,7 +7,6 @@ uses type TBaseBO = class - private protected procedure Clone(Source: TBaseBO); virtual; abstract; public diff --git a/samples/htmx/Classes/uServices.pas b/samples/htmx/Classes/uServices.pas index 99bd3565..06c92cf3 100644 --- a/samples/htmx/Classes/uServices.pas +++ b/samples/htmx/Classes/uServices.pas @@ -1,19 +1,17 @@ unit uServices; - -// services module which provides binding between the data model and the persistence layer -// for sample app this will persist data into a json file -// in a proper application this would be making calls to a persistent layer like a database etc +// Services module which provides binding between the data model and the persistence layer +// for sample app this will persist data into a json file. +// In a proper application this would be making calls to a persistent layer like a database etc interface uses - Spring, Spring.Collections, Spring.Collections.Lists, - System.Generics.Collections, uData.Model, + System.Generics.Collections, + uData.Model, System.SysUtils, JsonDataObjects; type - TServiceBase = class abstract public end; @@ -37,7 +35,7 @@ type function UpdateMovie(const Movie: TMovie; InsertMode: Boolean): Boolean; function DeleteMovie(const MovieID: Integer): Boolean; function GetNextID: Integer; - function ListAll2: IList; + function ListAll2: TObjectList; end; implementation @@ -80,12 +78,11 @@ begin end; end; -function TMovieService.ListAll2: IList; -// using Spring 4 D +function TMovieService.ListAll2: TObjectList; var Movie: TMovie; begin - Result := TCollections.CreateObjectList; + Result := TObjectList.Create; Movie := TMovie.Create; Movie.MovieID := 1; Movie.MovieName := 'gone'; diff --git a/samples/htmx/Controllers/uMovie.Controller.pas b/samples/htmx/Controllers/uMovie.Controller.pas index 16c5dec9..692c13eb 100644 --- a/samples/htmx/Controllers/uMovie.Controller.pas +++ b/samples/htmx/Controllers/uMovie.Controller.pas @@ -71,9 +71,13 @@ type implementation -uses Spring, Spring.Collections, Spring.Collections.Lists, - MVCFramework.Utils, System.SysUtils, - MVCFramework.Serializer.JsonDataObjects, uServices, System.Generics.Collections, uData.Model, +uses + MVCFramework.Utils, + System.SysUtils, + MVCFramework.Serializer.JsonDataObjects, + uServices, + System.Generics.Collections, + uData.Model, MVCFramework.Serializer.Defaults, MVCFramework.HTMX; @@ -107,7 +111,8 @@ begin else begin // just a normal form render - PageData.S['Explanation'] := 'Loaded via a full page reload, watch for the flicker in the title bar and see the calls in the browser Dev Tools console (network tab)'; + PageData.S['Explanation'] := + 'Loaded via a full page reload, watch for the flicker in the title bar and see the calls in the browser Dev Tools console (network tab)'; RenderForm(['Header', 'Movie', 'Footer']); end; finally @@ -146,7 +151,7 @@ begin sleep(500); // now tell the web page to delay doing the content swap for another 1 second Context.Response.SetReswap(soInnerHTML, 1000); - Render( Format('... Button was clicked at %s', [FormatDateTime('hh:mm:ss', Now)])); + Render(Format('... Button was clicked at %s', [FormatDateTime('hh:mm:ss', Now)])); end; procedure TMovieController.GetEditPanel(MovieID: Integer); diff --git a/samples/htmx/HTMX_Sample.dpr b/samples/htmx/HTMX_Sample.dpr index f5f2c944..e8e4da3a 100644 --- a/samples/htmx/HTMX_Sample.dpr +++ b/samples/htmx/HTMX_Sample.dpr @@ -17,7 +17,8 @@ uses uBase.Controller in 'Controllers\uBase.Controller.pas', uMovie.Controller in 'Controllers\uMovie.Controller.pas', uData.Model in 'Classes\uData.Model.pas', - uServices in 'Classes\uServices.pas'; + uServices in 'Classes\uServices.pas', + MVCFramework.HTMX in 'MVCFramework.HTMX.pas'; {$R *.res} diff --git a/samples/htmx/HTMX_Sample.dproj b/samples/htmx/HTMX_Sample.dproj index ce70c0ce..7c6b9e38 100644 --- a/samples/htmx/HTMX_Sample.dproj +++ b/samples/htmx/HTMX_Sample.dproj @@ -18,16 +18,6 @@ Base true - - true - Base - true - - - true - Base - true - true Base @@ -81,12 +71,6 @@ DataSnapServer;fmx;emshosting;DbxCommonDriver;bindengine;FireDACCommonODBC;emsclient;FireDACCommonDriver;IndyProtocols;dbxcds;emsedge;inetdb;FireDACSqliteDriver;DbxClientDriver;FireDACASADriver;soapmidas;dbexpress;FireDACInfxDriver;inet;DataSnapCommon;dbrtl;FireDACOracleDriver;CustomIPTransport;FireDACMSSQLDriver;DataSnapIndy10ServerTransport;DataSnapConnectors;FireDACMongoDBDriver;IndySystem;FireDACTDataDriver;bindcomp;FireDACCommon;DataSnapServerMidas;FireDACODBCDriver;emsserverresource;IndyCore;RESTBackendComponents;rtl;FireDACMySQLDriver;FireDACADSDriver;RESTComponents;dsnapxml;DataSnapClient;DataSnapFireDAC;emsclientfiredac;FireDACPgDriver;FireDAC;xmlrtl;dsnap;CloudService;FireDACDb2Driver;DataSnapNativeClient;DatasnapConnectorsFreePascal;soaprtl;soapserver;FireDACIBDriver;$(DCC_UsePackage) - - DataSnapServer;fmx;DbxCommonDriver;bindengine;IndyIPCommon;FireDACCommonODBC;emsclient;FireDACCommonDriver;IndyProtocols;IndyIPClient;dbxcds;bindcompfmx;DBXFirebirdDriver;inetdb;ibmonitor;FireDACSqliteDriver;DbxClientDriver;FireDACASADriver;soapmidas;fmxFireDAC;dbexpress;DBXMySQLDriver;inet;DataSnapCommon;fmxase;dbrtl;FireDACDBXDriver;FireDACOracleDriver;fmxdae;CustomIPTransport;FireDACMSSQLDriver;DataSnapIndy10ServerTransport;DBXInterBaseDriver;FireDACMongoDBDriver;IndySystem;FireDACTDataDriver;ibxbindings;bindcomp;FireDACCommon;DataSnapServerMidas;FireDACODBCDriver;IndyCore;RESTBackendComponents;bindcompdbx;rtl;FireDACMySQLDriver;RESTComponents;DBXSqliteDriver;IndyIPServer;dsnapxml;DataSnapClient;DataSnapProviderClient;DataSnapFireDAC;emsclientfiredac;FireDACPgDriver;FireDAC;FireDACDSDriver;inetdbxpress;xmlrtl;tethering;ibxpress;dsnap;CloudService;DBXSybaseASADriver;DBXOracleDriver;DBXInformixDriver;fmxobj;DataSnapNativeClient;soaprtl;soapserver;FireDACIBDriver;$(DCC_UsePackage) - - - DataSnapServer;fmx;DbxCommonDriver;bindengine;IndyIPCommon;FireDACCommonODBC;emsclient;FireDACCommonDriver;IndyProtocols;IndyIPClient;dbxcds;bindcompfmx;DBXFirebirdDriver;inetdb;ibmonitor;FireDACSqliteDriver;DbxClientDriver;FireDACASADriver;soapmidas;fmxFireDAC;dbexpress;DBXMySQLDriver;inet;DataSnapCommon;fmxase;dbrtl;FireDACDBXDriver;FireDACOracleDriver;fmxdae;CustomIPTransport;FireDACMSSQLDriver;DataSnapIndy10ServerTransport;DBXInterBaseDriver;FireDACMongoDBDriver;IndySystem;FireDACTDataDriver;ibxbindings;bindcomp;FireDACCommon;DataSnapServerMidas;FireDACODBCDriver;IndyCore;RESTBackendComponents;bindcompdbx;rtl;FireDACMySQLDriver;RESTComponents;DBXSqliteDriver;IndyIPServer;dsnapxml;DataSnapClient;DataSnapProviderClient;DataSnapFireDAC;emsclientfiredac;FireDACPgDriver;FireDAC;FireDACDSDriver;inetdbxpress;xmlrtl;tethering;ibxpress;dsnap;CloudService;DBXSybaseASADriver;DBXOracleDriver;DBXInformixDriver;fmxobj;DataSnapNativeClient;soaprtl;soapserver;FireDACIBDriver;$(DCC_UsePackage) - vclwinx;DataSnapServer;fmx;emshosting;vclie;DbxCommonDriver;bindengine;IndyIPCommon;VCLRESTComponents;DBXMSSQLDriver;FireDACCommonODBC;emsclient;FireDACCommonDriver;appanalytics;IndyProtocols;vclx;IndyIPClient;dbxcds;vcledge;bindcompvclwinx;emsedge;bindcompfmx;DBXFirebirdDriver;inetdb;ibmonitor;FireDACSqliteDriver;DbxClientDriver;FireDACASADriver;soapmidas;vclactnband;fmxFireDAC;dbexpress;FireDACInfxDriver;DBXMySQLDriver;VclSmp;inet;DataSnapCommon;EurekaLogCore;vcltouch;fmxase;DBXOdbcDriver;dbrtl;FireDACDBXDriver;FireDACOracleDriver;fmxdae;FireDACMSAccDriver;CustomIPTransport;FireDACMSSQLDriver;DataSnapIndy10ServerTransport;DataSnapConnectors;vcldsnap;DBXInterBaseDriver;OmniThreadLibraryRuntime;FireDACMongoDBDriver;IndySystem;BossExperts;FireDACTDataDriver;vcldb;ibxbindings;ADOCluster_RT;vclFireDAC;bindcomp;FireDACCommon;DataSnapServerMidas;FireDACODBCDriver;emsserverresource;IndyCore;RESTBackendComponents;dmvcframeworkDT;bindcompdbx;rtl;FireDACMySQLDriver;FireDACADSDriver;RESTComponents;DBXSqliteDriver;vcl;IndyIPServer;dsnapxml;dsnapcon;DataSnapClient;DataSnapProviderClient;adortl;DBXSybaseASEDriver;DBXDb2Driver;vclimg;DataSnapFireDAC;emsclientfiredac;FireDACPgDriver;FireDAC;FireDACDSDriver;inetdbxpress;xmlrtl;tethering;ibxpress;bindcompvcl;dsnap;CloudService;DBXSybaseASADriver;DBXOracleDriver;FireDACDb2Driver;DBXInformixDriver;vclib;fmxobj;bindcompvclsmp;DataSnapNativeClient;DatasnapConnectorsFreePascal;soaprtl;soapserver;FireDACIBDriver;$(DCC_UsePackage) Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) @@ -120,8 +104,8 @@ none true true - 2 - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.2;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 3 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.3;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= false @@ -141,6 +125,7 @@ + Base @@ -926,8 +911,6 @@ False - False - False False True diff --git a/sources/MVCFramework.HTMX.pas b/samples/htmx/MVCFramework.HTMX.pas similarity index 99% rename from sources/MVCFramework.HTMX.pas rename to samples/htmx/MVCFramework.HTMX.pas index 6d2e0401..1fbbdc25 100644 --- a/sources/MVCFramework.HTMX.pas +++ b/samples/htmx/MVCFramework.HTMX.pas @@ -106,7 +106,7 @@ type ///Helper class to expose HTMX options as native functions on WebResponse objects - THTMXResponseHelper = class helper for TMVCWebResponse + THTMXResponseHelper = class helper for TMVCWebResponse public type TClientEventType = (etReceived, etSettled, etSwapped); TSwapOption = (soInnerHTML, soOuterHTML, soBeforeBegin, soAfterBegin, soBeforeEnd, soAfterEnd, soDelete, soNone); diff --git a/samples/htmx/bin/data/data.json b/samples/htmx/bin/data/data.json index 2b61a4bb..5cc1b6b0 100644 --- a/samples/htmx/bin/data/data.json +++ b/samples/htmx/bin/data/data.json @@ -1 +1 @@ -[{"MovieID":1,"MovieName":"Star Wars - A New Hope","Rating":10,"GenreID":5,"GenreName":"Sci-Fi","Current":false,"ReleaseDate":"1977-05-25"},{"MovieID":2,"MovieName":"Hunt for Red October","Rating":7,"GenreID":3,"GenreName":"Action","Current":false,"ReleaseDate":"1990-03-02"},{"MovieID":3,"MovieName":"Oppenheimer","Rating":7,"GenreID":6,"GenreName":"Drama","Current":true,"ReleaseDate":"2023-08-01"},{"MovieID":4,"MovieName":"The Trouble With Harry","Rating":10,"GenreID":2,"GenreName":"Comedy","Current":false,"ReleaseDate":"1955-09-30"},{"MovieID":5,"MovieName":"Ms Information","Rating":10,"GenreID":7,"GenreName":"Documentary","Current":true,"ReleaseDate":"2023-07-28"}] \ No newline at end of file +[{"MovieID":1,"MovieName":"Star Wars - A New Hope","Rating":10,"GenreID":5,"GenreName":"Sci-Fi","Current":false,"ReleaseDate":"1977-05-25"},{"MovieID":2,"MovieName":"Hunt for Red October","Rating":7,"GenreID":3,"GenreName":"Action","Current":false,"ReleaseDate":"1990-03-02"},{"MovieID":3,"MovieName":"Oppenheimer","Rating":7,"GenreID":6,"GenreName":"Drama","Current":true,"ReleaseDate":"2023-08-01"},{"MovieID":4,"MovieName":"The Trouble With Harry","Rating":10,"GenreID":2,"GenreName":"Comedy","Current":false,"ReleaseDate":"1955-09-30"},{"MovieID":5,"MovieName":"Ms Information","Rating":10,"GenreID":7,"GenreName":"Documentary","Current":true,"ReleaseDate":"2023-07-28"},{"MovieID":6,"MovieName":"dfgdfgdfg","Rating":4,"GenreID":1,"GenreName":"","Current":true,"ReleaseDate":"2023-09-04"}] \ No newline at end of file