Updated instantsearch_htmx demo and some small fix to templatepro

This commit is contained in:
Daniele Teti 2024-08-16 19:08:36 +02:00
parent 028a88828e
commit 9e989378ec
5 changed files with 24 additions and 33 deletions

View File

@ -731,9 +731,9 @@ begin
Result := Result and (Self.ff_int4 = lOtherObj.ff_int4);
Result := Result and (Self.ff_int8 = lOtherObj.ff_int8);
Result := Result and (Self.ff_bool = lOtherObj.ff_bool);
Result := Result and (Self.ff_date = lOtherObj.ff_date);
Result := Result and (Self.ff_time = lOtherObj.ff_time);
Result := Result and (Self.ff_datetime = lOtherObj.ff_datetime);
Result := Result and Self.ff_date.Equals(lOtherObj.ff_date);
Result := Result and Self.ff_time.Equals(lOtherObj.ff_time);
Result := Result and Self.ff_datetime.Equals(lOtherObj.ff_datetime);
Result := Result and (Self.ff_float4 = lOtherObj.ff_float4);
Result := Result and (Self.ff_float8 = lOtherObj.ff_float8);
Result := Result and (Self.ff_string = lOtherObj.ff_string);

View File

@ -7,7 +7,7 @@ uses
System.Classes,
Web.HTTPApp,
MVCFramework, FireDAC.Stan.ExprFuncs, FireDAC.Phys.SQLiteWrapper.Stat,
MVCFramework.View.Renderers.Mustache,
MVCFramework.View.Renderers.TemplatePro,
FireDAC.Phys.SQLiteDef, FireDAC.Stan.Intf, FireDAC.Phys, FireDAC.Phys.SQLite;
type
@ -77,7 +77,7 @@ begin
fMVC.AddMiddleware(TMVCActiveRecordMiddleware.Create(CON_DEF_NAME));
// Middleware - END
fMVC.SetViewEngine(TMVCMustacheViewEngine);
fMVC.SetViewEngine(TMVCTemplateProViewEngine);
end;

View File

@ -5,29 +5,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Books Search</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css" />
<script src="https://cdn.jsdelivr.net/npm/htmx.org/dist/htmx.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/htmx.org/dist/htmx.min.js"></script>
</head>
<body>
<section class="section">
<div class="columns">
<div class="column is-one-third is-offset-one-third">
<input
type="text"
class="input"
placeholder="Search"
name="query"
hx-get="/search"
hx-trigger="keyup changed delay:500ms"
hx-target="#results"
hx-push-url="true"
/>
<input type="text" class="input" placeholder="Search" name="query" hx-get="/search"
hx-trigger="keyup changed delay:500ms" hx-target="#results" hx-push-url="true" />
</div>
<div class="column is-one-third">
<p class="subtitle is-6">⭐ DMVCFramework + HTMX :: Instant Search Demo ⭐</p>
<p class="subtitle is-6">⭐ DMVCFramework + HTMX :: Instant Search Demo ⭐</p>
</div>
</div>
<div id="results">{{>search_results}}</div>
<div id="results">{{include("search_results.html")}}</div>
</section>
</body>
</html>

View File

@ -1,4 +1,4 @@
<p>{{books_count}} book/s found</p>
<p>{{:books_count}} book/s found</p>
<table class="table is-fullwidth is-striped is-hoverable">
<thead>
<tr>
@ -9,20 +9,20 @@
</tr>
</thead>
<tbody>
{{#books}}
<tr>
<td>{{id}}</td>
<td>{{book_name}}</td>
<td>{{author_name}}</td>
<td>{{genre}}</td>
</tr>
{{/books}}
{{^books}}
{{if(!books)}}
<tr>
<td colspan="4">
<span>No books found</span>
</td>
</tr>
{{/books}}
{{endif}}
{{loop(books) as book}}
<tr>
<td>{{:book.id|lpad:8:"0"}}</td>
<td>{{:book.book_name}}</td>
<td>{{:book.author_name}}</td>
<td>{{:book.genre|uppercase}}</td>
</tr>
{{endloop}}
</tbody>
</table>

View File

@ -1716,10 +1716,10 @@ begin
lField := TDataSet(lVariable.VarValue.AsObject).FieldByName(lVarMembers);
case lField.DataType of
ftInteger: Result := lField.AsInteger;
ftLargeint: Result := lField.AsLargeInt;
ftString, ftWideString: Result := lField.AsWideString;
ftLargeint, ftAutoInc: Result := lField.AsLargeInt;
ftString, ftWideString, ftMemo, ftWideMemo: Result := lField.AsWideString;
else
Error('Invalid data type for field ' + lVarMembers);
Error('Invalid data type for field "' + lVarMembers + '": ' + TRttiEnumerationType.GetName<TFieldType>(lField.DataType));
end;
end;
end