diff --git a/samples/htmx_mustache/WebSiteControllerU.pas b/samples/htmx_mustache/WebSiteControllerU.pas index c965c7c6..a0ad89fe 100644 --- a/samples/htmx_mustache/WebSiteControllerU.pas +++ b/samples/htmx_mustache/WebSiteControllerU.pas @@ -38,6 +38,12 @@ type [MVCProduces(TMVCMediaType.TEXT_HTML)] procedure NewPerson; + [MVCPath('/modal/fordelete/($guid)')] + [MVCHTTPMethods([httpGET])] + [MVCProduces(TMVCMediaType.TEXT_HTML)] + function ShowModalForDelete(guid: string): String; + + [MVCPath('/edit/($guid)')] [MVCHTTPMethods([httpGET])] [MVCProduces(TMVCMediaType.TEXT_HTML)] @@ -48,6 +54,11 @@ type [MVCProduces(TMVCMediaType.TEXT_HTML)] procedure Index; + [MVCPath('/modal')] + [MVCHTTPMethods([httpGET])] + [MVCProduces(TMVCMediaType.TEXT_HTML)] + function ShowModal: String; + [MVCPath('/mustacheshowcase')] [MVCHTTPMethods([httpGET])] [MVCProduces(TMVCMediaType.TEXT_HTML)] @@ -66,6 +77,7 @@ var begin LDAL := TServicesFactory.GetPeopleDAL; LDAL.DeleteByGUID(GUID); + Context.Response.SetPageRefresh(true); RenderStatusMessage(HTTP_STATUS.OK); end; @@ -242,4 +254,27 @@ begin Context.Response.SetRedirect('/people'); end; +function TWebSiteController.ShowModal: String; +begin + var lJSON := StrToJSONObject('{"message":"Do you really want to delete row?", "title":"Bootstrap Modal Dialog"}'); + try + Result := GetRenderedView(['modal'], lJSON); + finally + lJSON.Free; + end; +end; + +function TWebSiteController.ShowModalForDelete(guid: string): String; +begin + var lJSON := TJsonObject.Create; + try + lJSON.S['title'] := 'Bootstrap Modal Dialog'; + lJSON.S['message'] := 'Do you really want to delete row?'; + lJSON.S['guid'] := guid; + Result := GetRenderedView(['modal'], lJSON); + finally + lJSON.Free; + end; +end; + end. diff --git a/samples/htmx_mustache/bin/templates/delete_person_link.mustache b/samples/htmx_mustache/bin/templates/delete_person_link.mustache index a2e346e1..e4abe96b 100644 --- a/samples/htmx_mustache/bin/templates/delete_person_link.mustache +++ b/samples/htmx_mustache/bin/templates/delete_person_link.mustache @@ -1 +1,9 @@ -Delete \ No newline at end of file + + + \ No newline at end of file diff --git a/samples/htmx_mustache/bin/templates/editperson.mustache b/samples/htmx_mustache/bin/templates/editperson.mustache index 6853bf6e..083d40a8 100644 --- a/samples/htmx_mustache/bin/templates/editperson.mustache +++ b/samples/htmx_mustache/bin/templates/editperson.mustache @@ -24,7 +24,7 @@