This commit is contained in:
BoHung Chiu 2023-01-30 11:18:19 +08:00
parent 9d3f15a695
commit c490f060ff
2 changed files with 4 additions and 4 deletions

View File

@ -145,7 +145,7 @@ class PersonalPluginField
end
def self.get_modal_names
name_routes = Rails.application.routes.named_routes.map{|k,v| k}.select{|s| s.to_s[0..4] == "admin"}.map{|s| s.to_s.split('admin_').last}
modal_names = name_routes.map{|n| n.classify}.select{|n| (n.constantize rescue nil)}
modal_names = name_routes.map{|n| n.camelize}.select{|n| (n.constantize rescue nil)}
modal_names = modal_names.map{|n| n.constantize}.select{|n| n.class == Class }.uniq
@@modal_names = modal_names.map{|n| n.to_s.underscore}
end

View File

@ -120,7 +120,7 @@ class PersonalPluginTemplatesController < ApplicationController
elsif select_field.split(".").count > 1
relate_name = select_field.split(".").first
field_name = select_field.split(".").last.gsub(/^\$+/, '')
relate = relate_name.classify.constantize
relate = relate_name.camelize.constantize
relate_ids = relate.where(field_name=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
plugin_templates = plugin_templates.where("#{relate_name.singularize}_id"=>{'$in'=>relate_ids})
elsif (PluginTemplate.fields[select_field].options[:type] == Date rescue false)
@ -148,14 +148,14 @@ class PersonalPluginTemplatesController < ApplicationController
tmp_plugin_templates = plugin_templates.select{|p| p.send(select_field).to_s.include?(keywords)}
plugin_templates = plugin_templates.where(:id.in=>tmp_plugin_templates.map{|p| p.id})
elsif file_fields.include?(select_field)
file_field = select_field.classify.constantize
file_field = select_field.camelize.constantize
ids1 = file_field.where(:file=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
ids2 = file_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
ids = ids1 + ids2
tmp_plugin_templates = plugin_templates.select{|p| (p.send("#{select_field}_ids") & ids).count != 0}
plugin_templates = plugin_templates.where(:id.in=>tmp_plugin_templates.map{|p| p.id})
elsif link_fields.include?(select_field)
link_field = select_field.classify.constantize
link_field = select_field.camelize.constantize
ids1 = link_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
ids2 = link_field.where(:url=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
ids = ids1 + ids2