mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:42:53 +08:00
If a search for a translation is exactly the value, prioritize it
This commit is contained in:
parent
de88be2fbc
commit
b0b85725ad
|
@ -20,8 +20,15 @@ class Admin::SiteTextsController < Admin::AdminController
|
||||||
translations.each do |k, v|
|
translations.each do |k, v|
|
||||||
results << {id: k, value: v}
|
results << {id: k, value: v}
|
||||||
end
|
end
|
||||||
|
|
||||||
results.sort! do |x, y|
|
results.sort! do |x, y|
|
||||||
(x[:id].size + x[:value].size) <=> (y[:id].size + y[:value].size)
|
if x[:value].casecmp(params[:q]) == 0
|
||||||
|
-1
|
||||||
|
elsif y[:value].casecmp(params[:q]) == 0
|
||||||
|
1
|
||||||
|
else
|
||||||
|
(x[:id].size + x[:value].size) <=> (y[:id].size + y[:value].size)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user