Class: TinyAdmin::Actions::Index
- Inherits:
-
BasicAction
- Object
- BasicAction
- TinyAdmin::Actions::Index
- Defined in:
- lib/tiny_admin/actions/index.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#fields_options ⇒ Object
readonly
Returns the value of attribute fields_options.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#pagination ⇒ Object
readonly
Returns the value of attribute pagination.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
Methods inherited from BasicAction
Methods included from Utils
#humanize, #params_to_s, #prepare_page, #to_class
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def context @context end |
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def current_page @current_page end |
#fields_options ⇒ Object (readonly)
Returns the value of attribute fields_options.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def @fields_options end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def links @links end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def @options end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def pages @pages end |
#pagination ⇒ Object (readonly)
Returns the value of attribute pagination.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def pagination @pagination end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def params @params end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def query_string @query_string end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'lib/tiny_admin/actions/index.rb', line 6 def repository @repository end |
Instance Method Details
#call(app:, context:, options:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tiny_admin/actions/index.rb', line 17 def call(app:, context:, options:) @context = context @options = || {} () fields = repository.fields(options: ) filters = prepare_filters(fields) records, count = repository.list(page: current_page, limit: pagination, filters: filters, sort: [:sort]) attributes = { actions: context.actions, fields: fields, filters: filters, links: [:links], prepare_record: ->(record) { repository.index_record_attrs(record, fields: ) }, records: records, slug: context.slug, title: repository.index_title, widgets: [:widgets] } prepare_page(Views::Actions::Index, slug: context.slug, attributes: attributes) do |page| setup_pagination(page, TinyAdmin.settings.components[:pagination], total_count: count) end end |