Module: AdminHelper

Defined in:
lib/generators/infold/templates/install/app/helpers/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#admin_field_invalid?(form, field) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/generators/infold/templates/install/app/helpers/admin_helper.rb', line 2

def admin_field_invalid?(form, field)
  form.object&.errors&.include?(field)
end

#admin_remote_modal_idObject



19
20
21
# File 'lib/generators/infold/templates/install/app/helpers/admin_helper.rb', line 19

def admin_remote_modal_id
  admin_turbo_frame_request_id
end

#admin_search_result_count(records) ⇒ Object



6
7
8
9
# File 'lib/generators/infold/templates/install/app/helpers/admin_helper.rb', line 6

def admin_search_result_count(records)
  return nil if records.blank?
  "#{records.offset_value + 1} - #{records.offset_value + records.length} of #{records.total_count} in total"
end

#admin_turbo_frame_request_idObject



15
16
17
# File 'lib/generators/infold/templates/install/app/helpers/admin_helper.rb', line 15

def admin_turbo_frame_request_id
  request.headers["Turbo-Frame"]
end

#admin_turbo_stream_flashObject



11
12
13
# File 'lib/generators/infold/templates/install/app/helpers/admin_helper.rb', line 11

def admin_turbo_stream_flash
  turbo_stream.append "flashes", partial: "admin/common/flash"
end