Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
moved serialization logic to the controller
Dieser Commit ist enthalten in:
Ursprung
20c8d8493e
Commit
69ce09bdf7
2 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
|
@ -1,8 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CustomWizard::RealtimeValidationsController < ::ApplicationController
|
||||
def validate
|
||||
params.require(:validation)
|
||||
params.require(::CustomWizard::RealtimeValidation.types[params[:validation].to_sym][:required_params])
|
||||
|
||||
render_json_dump(::CustomWizard::RealtimeValidation.send(params[:validation], params, current_user))
|
||||
result = ::CustomWizard::RealtimeValidation.send(params[:validation], params, current_user)
|
||||
render_serialized(result[:items], result[:serializer], result[:opts])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,6 @@ class CustomWizard::RealtimeValidation
|
|||
topics.select! { |t| categories.include?(t.category.id.to_s) } if categories.present?
|
||||
topics.select! { |t| t.created_at > DateTime.parse(date_after) } if date_after.present?
|
||||
topics.map! { |t| SimilarTopic.new(t) }
|
||||
::ActiveModel::ArraySerializer.new(topics, each_serializer: SimilarTopicSerializer, root: :similar_topics, rest_serializer: true, scope: ::Guardian.new(current_user))
|
||||
{ items: topics, serializer: SimilarTopicSerializer, opts: { root: :similar_topics } }
|
||||
end
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren