diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:11:07 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 21:16:54 +0200 |
| commit | 804c99fce66998ddcfd4970ff2c63141915bafd1 (patch) | |
| tree | cb489e4fad6ba586e14389a05c179b9aac0dc75d /app/views | |
| parent | 3e6ae9e523b410e9f100c8840ee9b6cc77043537 (diff) | |
| download | operum-804c99fce66998ddcfd4970ff2c63141915bafd1.tar.gz operum-804c99fce66998ddcfd4970ff2c63141915bafd1.zip | |
searches: Add rich text description
This allows for adding rich content to searches so it can be displayed
in shared searches, for example.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/searches/_form.html.erb | 6 | ||||
| -rw-r--r-- | app/views/shared_searches/show.html.erb | 71 |
2 files changed, 47 insertions, 30 deletions
diff --git a/app/views/searches/_form.html.erb b/app/views/searches/_form.html.erb index 15b5735..e3a326f 100644 --- a/app/views/searches/_form.html.erb +++ b/app/views/searches/_form.html.erb @@ -8,7 +8,13 @@ <%= form.text_field :name, required: true, autocomplete: 'off', autocapitalize: 'on' %> </div> + <div id="search-form-description" class="hidden"> + <%= form.label :description %> + <%= form.rich_textarea :description %> + </div> + <div> + <%= form.label :body, id: 'search-body-label', class: 'hidden' %> <%= form.text_field :body, "data-action": "keydown.enter->search#load", "data-search-target": "body", placeholder: 'Search body' %> <a id="save-search" href="#" data-action="search#save" class="hidden"><%= I18n.t('searches.save') %></a> </div> diff --git a/app/views/shared_searches/show.html.erb b/app/views/shared_searches/show.html.erb index d981cde..ed605bd 100644 --- a/app/views/shared_searches/show.html.erb +++ b/app/views/shared_searches/show.html.erb @@ -1,30 +1,41 @@ -<table id="public-search-table"> - <% @search.results.values.flatten.each do |res| %> - <tr> - <td> - <details> - <% if res.is_a? Thing %> - <summary><%= res.title %></summary> - <div class="details-flex"> - <div><span><b><%= I18n.t('activerecord.attributes.thing.authors') %></b>: <%= authors_or_editors(res) %></span></div> - <div><span><b><%= I18n.t('activerecord.attributes.thing.publisher') %></b>: <%= string_maybe(res.publisher) %></span></div> - <div><span><b><%= I18n.t('activerecord.attributes.thing.year') %></b>: <%= string_maybe(res.year) %></span></div> - <div><span><b><%= I18n.t('activerecord.attributes.thing.kind') %></b>: <%= I18n.t("things.kind.#{res.kind}") %></span></div> - <% if res.note.present? %> - <div><span><b><%= I18n.t('activerecord.attributes.thing.note') %></b>: <%= res.note %></span></div> - <% end %> - <% unless res.url.blank? %> - <div><span><a href="<%= res.url %>" target="_blank"><%= I18n.t('activerecord.attributes.thing.url') %></a></span></div> - <% end %> - </div> - <% else %> - <summary><b><%= I18n.t('comments.title') %></b> <%= I18n.t('general.in') %> «<i><%= res.thing.title %></i>»</summary> - <div class="details-flex"> - <%= res.content %> - </div> - <% end %> - </details> - </td> - </tr> - <% end %> -</table> +<% unless @search.description.blank? %> + <div> + <%= @search.description %> + <br /> + </div> +<% end %> + +<% if @results.empty? %> + <p><%= I18n.t('searches.none') %>.</p> +<% else %> + <table id="public-search-table"> + <% @results.each do |res| %> + <tr> + <td> + <details> + <% if res.is_a? Thing %> + <summary><%= res.title %></summary> + <div class="details-flex"> + <div><span><b><%= I18n.t('activerecord.attributes.thing.authors') %></b>: <%= authors_or_editors(res) %></span></div> + <div><span><b><%= I18n.t('activerecord.attributes.thing.publisher') %></b>: <%= string_maybe(res.publisher) %></span></div> + <div><span><b><%= I18n.t('activerecord.attributes.thing.year') %></b>: <%= string_maybe(res.year) %></span></div> + <div><span><b><%= I18n.t('activerecord.attributes.thing.kind') %></b>: <%= I18n.t("things.kind.#{res.kind}") %></span></div> + <% if res.note.present? %> + <div><span><b><%= I18n.t('activerecord.attributes.thing.note') %></b>: <%= res.note %></span></div> + <% end %> + <% unless res.url.blank? %> + <div><span><a href="<%= res.url %>" target="_blank"><%= I18n.t('activerecord.attributes.thing.url') %></a></span></div> + <% end %> + </div> + <% else %> + <summary><b><%= I18n.t('comments.title') %></b> <%= I18n.t('general.in') %> «<i><%= res.thing.title %></i>»</summary> + <div class="details-flex"> + <%= res.content %> + </div> + <% end %> + </details> + </td> + </tr> + <% end %> + </table> +<% end %> |
