README.md in admino-0.0.10 vs README.md in admino-0.0.11

- old
+ new

@@ -24,10 +24,14 @@ If a particular controller or view needs something different from the standard CRUD/REST treatment, you can just avoid using those gems in that specific context, and fall back to standard Rails code. No workarounds, no facepalms. It seems easy, right? It is. So what about Admino? Well, it complements the above-mentioned gems, giving you the the missing ~10%: a fast way to generate administrative index views. +## Demo + +To better illustrate how to create a 100%-custom, super-DRY administrative interface using Admino and the aforementioned gems, we prepared a [repo with a sample Rails project](https://github.com/cantierecreativo/admino-example) you can take a look. The app is browsable at [http://admino-example.herokuapp.com](http://admino-example.herokuapp.com), and features a Bootstrap 3 theme. + ## Installation Add this line to your application's Gemfile: gem 'admino' @@ -84,10 +88,11 @@ class TasksQuery < Admino::Query::Base # ... search_field :title_matches end ``` + The `#scope` method will check the presence of the `params[:query][:title_matches]` key. If it finds it, it will augment the query with a named scope called `:title_matches`, expected to be found within the `Task` model. The scope needs to accept an argument. ```ruby class Task < ActiveRecord::Base scope :title_matches, ->(text) { @@ -100,10 +105,19 @@ TaskQuery.new.scope.count # => 2 TaskQuery.new(query: { title_matches: 'ASAP' }).scope.count # => 1 ``` +You can provide a default value with the `default` option: + +```ruby +class TasksQuery < Admino::Query::Base + # ... + search_field :title_matches, default: 'TODO' +end +``` + #### `filter_by` ```ruby class TasksQuery < Admino::Query::Base # ... @@ -127,10 +141,21 @@ TaskQuery.new(query: { status: 'completed' }).scope.count # => 2 TaskQuery.new(query: { status: 'pending' }).scope.count # => 1 TaskQuery.new(query: { status: 'foobar' }).scope.count # => 3 ``` +You can include a "reset" scope with the `include_empty_scope` option, and provide a default scope with the `default` option: + +```ruby +class TasksQuery < Admino::Query::Base + # ... + filter_by :time, [:last_month, :last_week], + include_empty_scope: true, + default: :last_week +end +``` + #### `sorting` ```ruby class TasksQuery < Admino::Query::Base # ... @@ -483,10 +508,10 @@ def table_html_options { class: 'table-class' } end - def tbody_tr_html_options(resource_index) + def tbody_tr_html_options(resource, index) { class: 'tr-class' } end def zebra_css_classes %w(one two three)