2023-05-31 23:19:20 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
module Templates
|
2023-06-20 22:38:38 +03:00
|
|
|
module_function
|
|
|
|
|
|
2023-07-26 09:58:50 +03:00
|
|
|
def build_field_areas_index(fields)
|
2023-06-20 22:38:38 +03:00
|
|
|
hash = {}
|
|
|
|
|
|
2023-07-26 09:58:50 +03:00
|
|
|
fields.each do |field|
|
2023-06-20 22:38:38 +03:00
|
|
|
(field['areas'] || []).each do |area|
|
|
|
|
|
hash[area['attachment_uuid']] ||= {}
|
|
|
|
|
acc = (hash[area['attachment_uuid']][area['page']] ||= [])
|
|
|
|
|
|
|
|
|
|
acc << [area, field]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
hash
|
|
|
|
|
end
|
2023-09-15 02:11:48 +03:00
|
|
|
|
|
|
|
|
def search(templates, keyword)
|
|
|
|
|
return templates if keyword.blank?
|
|
|
|
|
|
|
|
|
|
templates.where(Template.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
|
|
|
|
|
end
|
2024-09-12 17:31:37 +03:00
|
|
|
|
|
|
|
|
def filter_undefined_submitters(template)
|
|
|
|
|
template.submitters.to_a.select do |item|
|
|
|
|
|
item['invite_by_uuid'].blank? && item['linked_to_uuid'].blank? &&
|
|
|
|
|
item['is_requester'].blank? && item['email'].blank?
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-05-31 23:19:20 +03:00
|
|
|
end
|