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-05-31 23:19:20 +03:00
|
|
|
end
|