add templates and submissions search
This commit is contained in:
@@ -5,6 +5,20 @@ module Submissions
|
||||
|
||||
module_function
|
||||
|
||||
def search(submissions, keyword)
|
||||
return submissions if keyword.blank?
|
||||
|
||||
term = "%#{keyword.downcase}%"
|
||||
|
||||
arel_table = Submitter.arel_table
|
||||
|
||||
arel = arel_table[:email].lower.matches(term)
|
||||
.or(arel_table[:phone].matches(term))
|
||||
.or(arel_table[:name].lower.matches(term))
|
||||
|
||||
submissions.joins(:submitters).where(arel).distinct
|
||||
end
|
||||
|
||||
def update_template_fields!(submission)
|
||||
submission.template_fields = submission.template.fields
|
||||
submission.template_schema = submission.template.schema
|
||||
|
||||
@@ -17,4 +17,10 @@ module Templates
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
def search(templates, keyword)
|
||||
return templates if keyword.blank?
|
||||
|
||||
templates.where(Template.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user