lib/netzke/basepack/paging_form.rb in netzke-basepack-0.12.9 vs lib/netzke/basepack/paging_form.rb in netzke-basepack-1.0.0.0.pre

- old
+ new

@@ -1,11 +1,11 @@ module Netzke module Basepack # A Form with paging toolbar. Allows browsing and editing records one-by-one. # # == Configuration - # Besides +Netzke::Basepack::Form+ config options, accepts: + # Besides +Netzke::Form::Base+ config options, accepts: # * +scope+ - specifies how the data should be filtered. # When it's a symbol, it's used as a scope name. # When it's a string, it's a SQL statement (passed directly to +ActiveRecord::Relation#where+). # When it's a hash, it's a conditions hash (passed directly to +ActiveRecord::Relation#where+). # When it's an array, it's expanded into an SQL statement with arguments (passed directly to +ActiveRecord::Relation#where+), e.g.: @@ -17,29 +17,25 @@ # :scope => { |rel| rel.where(:id.gt => 100).order(:created_at) } # # == ToDo # * Update the number of records after form submit class PagingForm < Form - js_configure do |c| - c.mixin - end - # override def record - @record ||= data_adapter.first + @record ||= model_adapter.first end - def js_configure(c) + def configure_client(c) super # Pass total records amount and the first record to the JS constructor c.total_records = total_records end - endpoint :get_data do |params, this| - @record = data_adapter.get_records(params).first + endpoint :get_data do |params| + @record = model_adapter.get_records(params).first record_hash = @record && js_record_data - this.merge!(:records => record_hash && [record_hash] || [], :total => total_records(params)) + client.merge!(:records => record_hash && [record_hash] || [], :total => total_records(params)) end action :search do |a| a.icon = :find a.select = true @@ -57,10 +53,10 @@ end protected def total_records(params = {}) - @total_records ||= data_adapter.count_records(params, []) + @total_records ||= model_adapter.count_records(params, []) end end end end