mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Updated samples to TemplatePro 0.5
This commit is contained in:
parent
b289b2f8eb
commit
0c80ec022d
@ -1,11 +1,11 @@
|
||||
{{if(!ishtmx)}}
|
||||
{{include("partials/header.html")}}
|
||||
{{if !ishtmx}}
|
||||
{{include "partials/header.html"}}
|
||||
{{endif}}
|
||||
<form class="form form-horizontal" id="myForm" name="myForm" hx-post="/people" hx-target="#main">
|
||||
<input type="hidden" value="{{:person.guid}}" name="guid">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{if(!person)}}
|
||||
{{if !person}}
|
||||
<h3>New Person</h3>
|
||||
{{else}}
|
||||
<h3>Edit Person</h3>
|
||||
@ -40,9 +40,9 @@
|
||||
<div class="form-group">
|
||||
<label for="items" class="col-sm-10 control-label">Devices</label>
|
||||
<select id="items" name="items" multiple class="form-control">
|
||||
{{loop(deviceslist) as device}}
|
||||
<option value="{{:device.devicename}}" {{if(device.selected)}}selected{{endif}}>{{:device.devicename|capitalize}}</option>
|
||||
{{endloop}}
|
||||
{{for device in deviceslist}}
|
||||
<option value="{{:device.devicename}}" {{if device.selected}}selected{{endif}}>{{:device.devicename|capitalize}}</option>
|
||||
{{endfor}}
|
||||
</select>
|
||||
<span style="font-size: 80%">(Ctrl+Click to select multiple devices)</span>
|
||||
</div>
|
||||
@ -59,7 +59,7 @@
|
||||
<button type="submit" class="btn btn-primary btn-block w-100">Save</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
{{if(person)}}
|
||||
{{if person}}
|
||||
<button
|
||||
type="button"
|
||||
hx-confirm="Are you sure you wish to delete user?"
|
||||
@ -74,6 +74,6 @@
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{{if(!ishtmx)}}
|
||||
{{include("partials/footer.html")}}
|
||||
{{if !ishtmx}}
|
||||
{{include "partials/footer.html"}}
|
||||
{{endif}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
guid;first_name;last_name;age
|
||||
{{loop(people) as person}}
|
||||
{{for person in people}}
|
||||
{{:person.guid}};"{{:person.firstname}}";"{{:person.lastname}}";{{:person.age}}
|
||||
{{endloop}}
|
||||
{{endfor}}
|
@ -1,13 +1,13 @@
|
||||
{{if(!ishtmx)}}
|
||||
{{include("partials/header.html")}}
|
||||
{{if !ishtmx}}
|
||||
{{include "partials/header.html"}}
|
||||
{{endif}}
|
||||
{{include("people_list_search.html")}}
|
||||
{{include "people_list_search.html"}}
|
||||
<div class="row" id="people_list" hx-target="#main">
|
||||
<div class="col">
|
||||
{{include("people_table.html")}}
|
||||
{{include "people_table.html"}}
|
||||
</div>
|
||||
</div>
|
||||
{{include("people_list_bottom.html")}}
|
||||
{{if(!ishtmx)}}
|
||||
{{include("partials/footer.html")}}
|
||||
{{include "people_list_bottom.html"}}
|
||||
{{if !ishtmx}}
|
||||
{{include "partials/footer.html"}}
|
||||
{{endif}}
|
||||
|
@ -8,4 +8,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{include("partials/modal_placeholder.html")}}
|
||||
{{include "partials/modal_placeholder.html"}}
|
@ -9,20 +9,20 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if(!people)}}
|
||||
{{if !people}}
|
||||
<tr>
|
||||
<td class="text-center" colspan="5"><<No People Found>></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
{{loop(people) as person}}
|
||||
{{for person in people}}
|
||||
<tr>
|
||||
<td>{{:person.@@index}}</td>
|
||||
<td>{{:person.FirstName|capitalize}}</td>
|
||||
<td>{{:person.LastName|capitalize}}</td>
|
||||
<td>{{:person.Age}}</td>
|
||||
<td class="text-end">{{include("delete_person_link.html")}} | {{include("view_person_link.html")}}</td>
|
||||
<td class="text-end">{{include "delete_person_link.html"}} | {{include "view_person_link.html"}}</td>
|
||||
</tr>
|
||||
{{endloop}}
|
||||
{{endfor}}
|
||||
{{endif}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -62,6 +62,6 @@
|
||||
<main class="container-fluid">
|
||||
<div class="parent">
|
||||
<!-- Side Navigation -->
|
||||
{{include("partials/sidenav.html")}}
|
||||
{{include "partials/sidenav.html"}}
|
||||
<!-- Main Content Area -->
|
||||
<div class="main" id="main">
|
@ -1,3 +1,3 @@
|
||||
{{if(ispage)}}{{include("../_header.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_header.html"}}{{endif}}
|
||||
<h1 class="text-2xl font-bold mb-4">Customers</h1>
|
||||
{{if(ispage)}}{{include("../_footer.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_footer.html"}}{{endif}}
|
@ -1,3 +1,4 @@
|
||||
{{if(ispage)}}{{include("../_header.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_header.html"}}{{endif}}
|
||||
<h1 class="text-2xl font-bold mb-4">HTMX WebSite</h1>
|
||||
{{if(ispage)}}{{include("../_footer.html")}}{{endif}}
|
||||
<p>Powered by DMVCFramework, TemplatePro and HTMX</p>
|
||||
{{if ispage}}{{include "../_footer.html"}}{{endif}}
|
@ -1,3 +1,3 @@
|
||||
{{if(ispage)}}{{include("../_header.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_header.html"}}{{endif}}
|
||||
<h1 class="text-2xl font-bold mb-4">Posts</h1>
|
||||
{{if(ispage)}}{{include("../_footer.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_footer.html"}}{{endif}}
|
@ -1,3 +1,3 @@
|
||||
{{if(ispage)}}{{include("../_header.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_header.html"}}{{endif}}
|
||||
<h1 class="text-2xl font-bold mb-4">Users</h1>
|
||||
{{if(ispage)}}{{include("../_footer.html")}}{{endif}}
|
||||
{{if ispage}}{{include "../_footer.html"}}{{endif}}
|
@ -2,7 +2,6 @@
|
||||
const highlightMenuItem = (evt) => {
|
||||
let menuItems = document.querySelectorAll('#' + evt.srcElement.parentElement.id + ' > a');
|
||||
menuItems.forEach((item) => {
|
||||
console.log(item);
|
||||
item.classList.remove("selected");
|
||||
});
|
||||
evt.srcElement.classList.add("selected");
|
||||
|
@ -13,7 +13,6 @@ uses
|
||||
MVCFramework.Logger,
|
||||
MVCFramework.DotEnv,
|
||||
MVCFramework.Commons,
|
||||
MVCFramework.View.Renderers.Mustache,
|
||||
mormot.core.mustache,
|
||||
MVCFramework.Signal,
|
||||
ControllerU in 'ControllerU.pas',
|
||||
|
@ -60,6 +60,8 @@ begin
|
||||
// UseConsoleLogger defines if logs must be emitted to also the console (if available).
|
||||
UseConsoleLogger := True;
|
||||
|
||||
MVCUseTemplatesCache := False;
|
||||
|
||||
LogI('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
||||
|
||||
CreateSqlitePrivateConnDef(True);
|
||||
|
@ -155,7 +155,6 @@
|
||||
<DCCReference Include="Controllers.BooksU.pas"/>
|
||||
<DCCReference Include="WebModuleU.pas">
|
||||
<Form>MyWebModule</Form>
|
||||
<FormType>dfm</FormType>
|
||||
<DesignClass>TWebModule</DesignClass>
|
||||
</DCCReference>
|
||||
<DCCReference Include="FDConnectionConfigU.pas"/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@ -18,7 +18,7 @@
|
||||
<p class="subtitle is-6">⭐ DMVCFramework + HTMX :: Instant Search Demo ⭐</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="results">{{include("search_results.html")}}</div>
|
||||
<div id="results">{{include "search_results.html"}}</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
@ -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>
|
||||
{{if(!books)}}
|
||||
{{if !books}}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<span>No books found</span>
|
||||
</td>
|
||||
</tr>
|
||||
{{endif}}
|
||||
{{loop(books) as book}}
|
||||
{{for book in books}}
|
||||
<tr>
|
||||
<td>{{:book.id|lpad:8:"0"}}</td>
|
||||
<td>{{:book.id|lpad,8,"0"}}</td>
|
||||
<td>{{:book.book_name}}</td>
|
||||
<td>{{:book.author_name}}</td>
|
||||
<td>{{:book.genre|uppercase}}</td>
|
||||
</tr>
|
||||
{{endloop}}
|
||||
{{endfor}}
|
||||
</tbody>
|
||||
</table>
|
@ -52,8 +52,37 @@ uses
|
||||
{$WARNINGS OFF}
|
||||
|
||||
function GetDataSetOrObjectListCount(const aValue: TValue; const aParameters: TArray<string>): TValue;
|
||||
var
|
||||
lWrappedList: IMVCList;
|
||||
begin
|
||||
// todo
|
||||
if not aValue.IsObject then
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
if aValue.AsObject is TDataSet then
|
||||
begin
|
||||
Result := TDataSet(aValue.AsObject).RecordCount;
|
||||
end
|
||||
else if aValue.AsObject is TJsonArray then
|
||||
begin
|
||||
Result := TJsonArray(aValue.AsObject).Count;
|
||||
end
|
||||
else if aValue.AsObject is TJsonObject then
|
||||
begin
|
||||
Result := TJsonObject(aValue.AsObject).Count;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if TDuckTypedList.CanBeWrappedAsList(aValue.AsObject, lWrappedList) then
|
||||
begin
|
||||
Result := lWrappedList.Count;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DumpAsJSONString(const aValue: TValue; const aParameters: TArray<string>): TValue;
|
||||
@ -82,7 +111,7 @@ procedure TMVCTemplateProViewEngine.Execute(const ViewName: string; const Builde
|
||||
var
|
||||
lTP: TTProCompiler;
|
||||
lViewFileName: string;
|
||||
lViewTemplate: UTF8String;
|
||||
lViewTemplate: String;
|
||||
lCompiledTemplate: ITProCompiledTemplate;
|
||||
lPair: TPair<String, TValue>;
|
||||
lActualFileTimeStamp: TDateTime;
|
||||
|
@ -1218,12 +1218,6 @@ begin
|
||||
end;
|
||||
|
||||
function HTMLSpecialCharsEncode(s: string): string;
|
||||
procedure repl(var s: string; r: string; posi: Integer);
|
||||
begin
|
||||
Delete(s, posi, 1);
|
||||
Insert(r, s, posi);
|
||||
end;
|
||||
|
||||
var
|
||||
I: Integer;
|
||||
r: string;
|
||||
@ -1432,7 +1426,8 @@ begin
|
||||
end;
|
||||
if r <> '' then
|
||||
begin
|
||||
repl(s, '&' + r + ';', I);
|
||||
s := s.Replace(s[I], '&' + r + ';');
|
||||
Inc(I, Length(r) + 1);
|
||||
end;
|
||||
Inc(I)
|
||||
end;
|
||||
@ -2127,12 +2122,44 @@ end;
|
||||
function TTProCompiledTemplate.IsTruthy(const Value: TValue): Boolean;
|
||||
var
|
||||
lStrValue: String;
|
||||
lWrappedList: ITProWrappedList;
|
||||
begin
|
||||
if Value.IsEmpty then
|
||||
begin
|
||||
Exit(False);
|
||||
end;
|
||||
lStrValue := Value.ToString;
|
||||
if Value.IsObjectInstance then
|
||||
begin
|
||||
if Value.AsObject = nil then
|
||||
begin
|
||||
lStrValue := '';
|
||||
end
|
||||
else if Value.AsObject is TDataSet then
|
||||
begin
|
||||
lStrValue := TDataSet(Value.AsObject).RecordCount.ToString;
|
||||
end
|
||||
else if Value.AsObject is TJsonArray then
|
||||
begin
|
||||
lStrValue := TJsonArray(Value.AsObject).Count.ToString;
|
||||
end
|
||||
else if Value.AsObject is TJsonObject then
|
||||
begin
|
||||
lStrValue := TJsonObject(Value.AsObject).Count.ToString;
|
||||
end
|
||||
else
|
||||
begin
|
||||
lWrappedList := TTProDuckTypedList.Wrap(Value.AsObject);
|
||||
if lWrappedList = nil then
|
||||
begin
|
||||
lStrValue := '';
|
||||
end
|
||||
else
|
||||
begin
|
||||
lStrValue := lWrappedList.Count.ToString;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := not (SameText(lStrValue,'false') or SameText(lStrValue,'0') or SameText(lStrValue,''));
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user