effective_datatables 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6861407f8fce38a641e334d011a8904bfb507ca1
4
- data.tar.gz: 755a765c5da61e125bf682056afa098911704a11
3
+ metadata.gz: 104ed4736f57500cb86aaa07631d96aa36b4df8d
4
+ data.tar.gz: 800891f688c2e363b19336e19896ba0fa5900ecb
5
5
  SHA512:
6
- metadata.gz: a5636647282d639a8cf5d2099cadb741dec3270fefaf9ab9a63feea37e11d6cf934edc23682cafeac806a062285192a269d4e14528f79171ed77a29bc119f16d
7
- data.tar.gz: b031ed0aab1f0788d3005560ac2b1d75737972674636a273b4446a4cd731dd57abbe40f19c1596f45341744fba83e4ab0abb44bdcb817c65f645cadbd5fafc4a
6
+ metadata.gz: 1b70a5c78893a581b4db8bc277196c37e19b5fe1d4ea2eb5025868aee2512e071b8cfb9ce1ef0f3ec4f8e2ffb1ba363eae7c6d24db6fd7291838c653b2076fb9
7
+ data.tar.gz: 066e62e1d2a348dfe780f59b2405284c7707a00985ed3db03166b542e8ddce4fe82110ea3feddc911241489f47411026c490271627c6cff7985b696e1a0484c7
@@ -100,6 +100,11 @@ module Effective
100
100
  collection.where("#{column} = :term", term: term.to_i)
101
101
  when :year
102
102
  collection.where("EXTRACT(YEAR FROM #{column}) = :term", term: term.to_i)
103
+ when :price
104
+ price_in_cents = (term.gsub(/[^0-9|\.]/, '').to_f * 100.0).to_i
105
+ collection.where("#{column} = :term", term: price_in_cents)
106
+ when :currency
107
+ collection.where("#{column} = :term", term: term.gsub(/[^0-9|\.]/, '').to_f)
103
108
  else
104
109
  collection.where("#{column} = :term", term: term)
105
110
  end
@@ -2,7 +2,7 @@ module Effective
2
2
  class Datatable
3
3
  attr_accessor :total_records, :display_records, :view, :attributes
4
4
 
5
- delegate :render, :link_to, :mail_to, :to => :@view
5
+ delegate :render, :link_to, :mail_to, :number_to_currency, :to => :@view
6
6
 
7
7
  include Effective::EffectiveDatatable::Dsl
8
8
  extend Effective::EffectiveDatatable::Dsl::ClassMethods
@@ -46,8 +46,9 @@ module Effective
46
46
  filter: false,
47
47
  partial_local: :resource,
48
48
  partial_locals: { show_action: show, edit_action: edit, destroy_action: destroy }
49
- }
50
- opts[:partial] = '/effective/datatables/actions_column' unless (block_given? || proc.present?)
49
+ }.merge(options)
50
+
51
+ opts[:partial] ||= '/effective/datatables/actions_column' unless (block_given? || proc.present?)
51
52
 
52
53
  table_column(name, opts, proc, &block)
53
54
  end
@@ -105,6 +105,13 @@ module Effective
105
105
  (obj.send(name).strftime(EffectiveDatatables.datetime_format) rescue nil)
106
106
  elsif opts[:type] == :date
107
107
  (obj.send(name).strftime(EffectiveDatatables.date_format) rescue nil)
108
+ elsif opts[:type] == :price
109
+ # This is price_to_currency from effective_form_inputs retyped...
110
+ price = ((obj.send(name) || 0) rescue 0)
111
+ raise 'column type: price expects an Integer representing the number of cents' unless price.kind_of?(Integer)
112
+ number_to_currency(price / 100.0)
113
+ elsif opts[:type] == :currency
114
+ number_to_currency(((obj.send(name) || 0) rescue 0))
108
115
  else
109
116
  obj.send(name) rescue (obj[opts[:array_index]] rescue nil)
110
117
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '2.0.3'.freeze
2
+ VERSION = '2.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails