autosubmit, live search

This commit is contained in:
2026-01-22 23:52:53 +01:00
parent 34ab3d80ae
commit 28532fb109
12 changed files with 263 additions and 182 deletions
+11 -4
View File
@@ -1,5 +1,5 @@
class EntriesController < ApplicationController
before_action :set_entry, only: [:show]
before_action :set_entry, only: [ :show ]
def index
@supported_languages = SupportedLanguage.where(active: true).order(:sort_order, :name)
@@ -7,7 +7,7 @@ class EntriesController < ApplicationController
@category = params[:category].presence
@query = params[:q].to_s.strip
@starts_with = params[:starts_with].presence
@page = [params[:page].to_i, 1].max
@page = [ params[:page].to_i, 1 ].max
@per_page = 25
entries_scope = Entry.all
@@ -25,13 +25,13 @@ class EntriesController < ApplicationController
@verified_count = Entry.where(verified: true).count
@needs_review_count = @entry_count - @verified_count
@complete_entries_count = @supported_languages.reduce(Entry.all) do |scope, language|
scope.where.not(language.code => [nil, ""])
scope.where.not(language.code => [ nil, "" ])
end.count
@missing_entries_count = @entry_count - @complete_entries_count
@language_completion = @supported_languages.index_with do |language|
next 0 if @entry_count.zero?
(Entry.where.not(language.code => [nil, ""]).count * 100.0 / @entry_count).round
(Entry.where.not(language.code => [ nil, "" ]).count * 100.0 / @entry_count).round
end
if @language_code.present?
@@ -40,6 +40,13 @@ class EntriesController < ApplicationController
else
@display_languages = @supported_languages
end
if turbo_frame_request?
turbo_frame_id = request.headers["Turbo-Frame"]
if turbo_frame_id == "entries_results"
render partial: "entries/results_frame", layout: false
end
end
end
def show