Skip to content
Snippets Groups Projects
Commit 70f39b5d authored by jensilo's avatar jensilo
Browse files

make all templates visible upon opening search modal

parent fe0476b9
No related branches found
No related tags found
1 merge request!4merge dev to main
......@@ -67,7 +67,8 @@ type TemplateFormData struct {
// SearchTemplateData contains templates to render as search results and a flag indicating if the query was too short.
type SearchTemplateData struct {
Templates []*template.Template
Templates []*template.Template
// Deprecated this is expected to be unnecessary with the current implementation of EIFFEL
QueryTooShort bool
}
......@@ -181,8 +182,21 @@ func renderElicitationPage(io web.IO, data TemplateFormData, success []string, e
}
func searchModal(appCtx *hctx.AppCtx, webCtx *web.Ctx) http.Handler {
templateRepository := util.UnwrapType[template.Repository](appCtx.Repository(template.RepositoryName))
return web.NewController(appCtx, webCtx, func(io web.IO) error {
return io.Render(nil, "eiffel.template.search.modal", "eiffel/_modal-template-search.go.html")
ctx := io.Context()
templates, err := templateRepository.FindByQueryForTypeAndUser(ctx, "", BasicTemplateType, user.MustCtxUser(ctx))
if err != nil && !errors.Is(err, persistence.ErrNotFound) {
return io.InlineError(web.ErrInternal, err)
}
return io.Render(
&SearchTemplateData{Templates: templates},
"eiffel.template.search.modal",
"eiffel/_modal-template-search.go.html",
"eiffel/_template-search-result.go.html",
)
})
}
......@@ -197,13 +211,7 @@ func searchTemplate(appCtx *hctx.AppCtx, webCtx *web.Ctx) http.Handler {
}
query := request.FormValue("search")
if len(query) < 3 {
return io.Render(
&SearchTemplateData{QueryTooShort: true},
"eiffel.template.search.result",
"eiffel/_template-search-result.go.html",
)
}
// query too short was removed as it is expected to be unnecessary
ctx := io.Context()
templates, err := templateRepository.FindByQueryForTypeAndUser(ctx, query, BasicTemplateType, user.MustCtxUser(ctx))
......
{{ define "eiffel.template.search.modal" }}
<div class="modal-dialog modal-lg">
<div class="modal-dialog modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="eiffelTemplateSearchLabel">{{ t "eiffel.elicitation.template.search.title" }}</h1>
......@@ -8,7 +8,7 @@
<div class="modal-body">
<div class="mb-3">
<input id="eiffelTemplateSearchInput"
name="search" type="search" class="form-control"
name="search" type="search" class="form-control border-dark-subtle"
hx-post="/eiffel/elicitation/templates/search"
hx-trigger="input changed delay:300ms, search"
hx-target="#eiffelTemplateSearchResults"
......@@ -26,9 +26,13 @@
</tr>
</thead>
<tbody id="eiffelTemplateSearchResults">
<tr>
<td class="text-center" colspan="4">{{ t "eiffel.elicitation.template.search.start" }}</td>
</tr>
{{ if not .Data.Templates }}
<tr>
<td class="text-center" colspan="4">{{ t "eiffel.elicitation.template.search.start" }}</td>
</tr>
{{ else }}
{{ template "eiffel.template.search.result" . }}
{{ end }}
</tbody>
</table>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment