netzke-basepack 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30d74b083e48e2a51888f96da8a9bfc2cae04fd6
4
- data.tar.gz: 8e2ee2d275266f0edb379c1a5842c2f8e560cdcc
3
+ metadata.gz: 16a254ce373566ab871dcc25a79c46a1a33e687b
4
+ data.tar.gz: d46f4ce76ad16ebf476ee48b3f6e60a72a0e30f0
5
5
  SHA512:
6
- metadata.gz: 23a15c8fad9fd568fb8eba8bbc548e596eed27755f4cd43b01552995a3e24025af4de898ae6e12f31499b5ac805979d3ccab474d2a2a431777553fb629b60647
7
- data.tar.gz: 290f1bc27eac9746be1d89eb276e56585861323928a75ecfad8231ecbfa9d40ef628bfed20c55c9566e9df4dafbe75277f164fd9fc6586c8b79cb0b5aecd9c0a
6
+ metadata.gz: 367b371b71bbbc162f4885d4cb51d81c0e60017485e7cbdc6b5f2c4ed463c8dc115324d1af83c4dcde8de006b1522b509b917714844950cc065aa64bd1fc394d
7
+ data.tar.gz: 91587317913ba081de7a6320520cc3b830e7a530d69cbdedd08fcd5fe727760d253abbebc02c06556fdd34832a3b173ba86f51800628715e32b18bd708f32aca
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.11.1 - 2015-04-20
2
+ * Fix filtering by association when associtaion method is integer
3
+ * Fix decimal and float columns in extended search form
4
+ * Fix showing 0-value in association shown by integer
5
+ * Fix limited precision in numeric column filter
6
+
1
7
  # 0.11.0 - 2015-02-05
2
8
  * Rails 4.2
3
9
  * A few fixes from AlexKovynev
@@ -142,8 +142,6 @@ module Netzke
142
142
  {name: c.name, text: c.text, attr_type: c.attr_type}.tap do |a|
143
143
  if c[:assoc]
144
144
  a[:text].sub!(" ", " ")
145
- a[:assoc] = true
146
- a[:attr_type] = :string
147
145
  end
148
146
  end
149
147
  end
@@ -39,7 +39,9 @@ module Netzke::Basepack::DataAdapters
39
39
  end
40
40
 
41
41
  def attr_type(attr_name)
42
- association_attr?(attr_name) ? :integer : (@model_class.columns_hash[attr_name.to_s].try(:type) || :string)
42
+ method, assoc = method_and_assoc(attr_name)
43
+ klass = assoc.nil? ? @model_class : assoc.klass
44
+ klass.columns_hash[method].try(:type) || :string
43
45
  end
44
46
 
45
47
  # Implementation for {AbstractAdapter#get_records}
@@ -113,17 +115,17 @@ module Netzke::Basepack::DataAdapters
113
115
 
114
116
  def virtual_attribute?(c)
115
117
  assoc_name, asso = c[:name].split('__')
116
- assoc, assoc_method = assoc_and_assoc_method_for_attr(c[:name])
118
+ method, assoc = method_and_assoc(c[:name])
117
119
 
118
120
  if assoc
119
- return !assoc.klass.column_names.include?(assoc_method)
121
+ return !assoc.klass.column_names.include?(method)
120
122
  else
121
123
  return !@model_class.column_names.include?(c[:name])
122
124
  end
123
125
  end
124
126
 
125
127
  def combo_data(attr, query = "")
126
- assoc, assoc_method = assoc_and_assoc_method_for_attr(attr[:name])
128
+ method, assoc = method_and_assoc(attr[:name])
127
129
 
128
130
  if assoc
129
131
  # Options for an asssociation attribute
@@ -131,16 +133,16 @@ module Netzke::Basepack::DataAdapters
131
133
  relation = assoc.klass.all
132
134
  relation = relation.extend_with(attr[:scope]) if attr[:scope]
133
135
 
134
- if assoc.klass.column_names.include?(assoc_method)
136
+ if assoc.klass.column_names.include?(method)
135
137
  # apply query
136
138
  assoc_arel_table = assoc.klass.arel_table
137
139
 
138
- relation = relation.where(assoc_arel_table[assoc_method].matches("%#{query}%")) if query.present?
139
- relation.to_a.map{ |r| [r.id, r.send(assoc_method)] }
140
+ relation = relation.where(assoc_arel_table[method].matches("%#{query}%")) if query.present?
141
+ relation.to_a.map{ |r| [r.id, r.send(method)] }
140
142
  else
141
143
  query.downcase!
142
144
  # an expensive search!
143
- relation.to_a.map{ |r| [r.id, r.send(assoc_method)] }.select{ |id,value| value.to_s.downcase.include?(query) }
145
+ relation.to_a.map{ |r| [r.id, r.send(method)] }.select{ |id,value| value.to_s.downcase.include?(query) }
144
146
  end
145
147
 
146
148
  else
@@ -296,11 +298,12 @@ module Netzke::Basepack::DataAdapters
296
298
  end
297
299
  end
298
300
 
299
- # Returns association and association method for a column
300
- def assoc_and_assoc_method_for_attr(column_name)
301
- assoc_name, assoc_method = column_name.split('__')
302
- assoc = @model_class.reflect_on_association(assoc_name.to_sym) if assoc_method
303
- [assoc, assoc_method]
301
+ # If association attribute is given, returns [method, association]
302
+ # Else returns [attr_name]
303
+ def method_and_assoc(attr_name)
304
+ assoc_name, method = attr_name.to_s.split('__')
305
+ assoc = @model_class.reflect_on_association(assoc_name.to_sym) if method
306
+ assoc.nil? ? [attr_name] : [method, assoc]
304
307
  end
305
308
 
306
309
  # An ActiveRecord::Relation instance encapsulating all the necessary conditions.
@@ -353,16 +356,10 @@ module Netzke::Basepack::DataAdapters
353
356
  predicates = conditions.map do |q|
354
357
  q = HashWithIndifferentAccess.new(q)
355
358
 
356
- assoc, method = q["attr"].split('__')
357
- if method
358
- assoc = @model_class.reflect_on_association(assoc.to_sym)
359
- assoc_arel = assoc.klass.arel_table
360
- attr = method
361
- arel_table = Arel::Table.new(assoc.klass.table_name.to_sym)
362
- else
363
- attr = assoc
364
- arel_table = @model_class.arel_table
365
- end
359
+ attr = q[:attr]
360
+ method, assoc = method_and_assoc(attr)
361
+
362
+ arel_table = assoc ? Arel::Table.new(assoc.klass.table_name.to_sym) : @model_class.arel_table
366
363
 
367
364
  value = q["value"]
368
365
  op = q["operator"]
@@ -371,15 +368,15 @@ module Netzke::Basepack::DataAdapters
371
368
 
372
369
  case attr_type
373
370
  when :datetime
374
- update_predecate_for_datetime(arel_table[attr], op, value.to_date)
371
+ update_predecate_for_datetime(arel_table[method], op, value.to_date)
375
372
  when :string, :text
376
- update_predecate_for_string(arel_table[attr], op, value)
373
+ update_predecate_for_string(arel_table[method], op, value)
377
374
  when :boolean
378
- update_predecate_for_boolean(arel_table[attr], op, value)
375
+ update_predecate_for_boolean(arel_table[method], op, value)
379
376
  when :date
380
- update_predecate_for_rest(arel_table[attr], op, value.to_date)
377
+ update_predecate_for_rest(arel_table[method], op, value.to_date)
381
378
  else
382
- update_predecate_for_rest(arel_table[attr], op, value)
379
+ update_predecate_for_rest(arel_table[method], op, value)
383
380
  end
384
381
  end
385
382
 
@@ -378,8 +378,6 @@ module Netzke
378
378
  # JavaScript includes
379
379
  ex = Netzke::Core.ext_path.join("examples")
380
380
 
381
- c.require :extensions
382
-
383
381
  # Includes for column filters
384
382
  if column_filters_available
385
383
  [
@@ -392,6 +390,8 @@ module Netzke
392
390
  c.require(ex.join"ux/grid/filter/#{f}Filter.js")
393
391
  end
394
392
  end
393
+
394
+ c.require :extensions
395
395
  end
396
396
 
397
397
  # Allows children classes to simply do:
@@ -138,3 +138,14 @@ Ext.override(Ext.ux.CheckColumn, {
138
138
  else return this.callOverridden(arguments);
139
139
  }
140
140
  });
141
+
142
+ // Fix 2-digit precision in the numeric column filter
143
+ Ext.define('Ext.ux.grid.menu.RangeMenu', {
144
+ override: 'Ext.ux.grid.menu.RangeMenu',
145
+ menuItemCfgs : {
146
+ emptyText: 'Enter Number...',
147
+ selectOnFocus: false,
148
+ width: 155,
149
+ decimalPrecision: 10
150
+ },
151
+ });
@@ -241,7 +241,7 @@
241
241
 
242
242
  // Setting the default filter type
243
243
  if (c.filterable != false && !c.filter) {
244
- c.filter = {type: c.assoc ? 'string' : this.netzkeFieldTypeForAttrType(c.attrType)};
244
+ c.filter = {type: this.netzkeFilterTypeForAttrType(c.attrType)};
245
245
  }
246
246
 
247
247
  // setting dataIndex
@@ -280,6 +280,20 @@
280
280
  return Ext.create('Netzke.classes.Basepack.Grid.ArrayReader');
281
281
  },
282
282
 
283
+ netzkeFilterTypeForAttrType: function(attrType){
284
+ var map = {
285
+ integer : 'int',
286
+ decimal : 'int',
287
+ float : 'int',
288
+ datetime : 'date',
289
+ date : 'date',
290
+ string : 'string',
291
+ text : 'string',
292
+ 'boolean' : 'boolean'
293
+ };
294
+ return map[attrType] || 'string';
295
+ },
296
+
283
297
  netzkeFieldTypeForAttrType: function(attrType){
284
298
  var map = {
285
299
  integer : 'int',
@@ -376,7 +390,8 @@
376
390
  if (recordFromStore) {
377
391
  renderedValue = recordFromStore.get('text');
378
392
  } else if (c.assoc && r.get('meta')) {
379
- renderedValue = r.get('meta').associationValues[c.name] || c.emptyText;
393
+ var assocValue = r.get('meta').associationValues[c.name];
394
+ renderedValue = (assocValue == undefined) ? c.emptyText : assocValue;
380
395
  } else {
381
396
  renderedValue = value;
382
397
  }
@@ -9,24 +9,24 @@ module Netzke
9
9
  i18n_path = "netzke.basepack.search_panel.%s"
10
10
 
11
11
  ATTRIBUTE_OPERATORS_MAP = {
12
- :integer => [
12
+ integer: [
13
13
  ["eq", I18n.t(i18n_path % 'equals')],
14
14
  ["gt", I18n.t(i18n_path % 'greater_than')],
15
15
  ["lt", I18n.t(i18n_path % 'less_than')]
16
16
  ],
17
- :text => [
17
+ text: [
18
18
  ["contains", I18n.t(i18n_path % 'contains')] # same as matches => %string%
19
19
  ],
20
- :string => [
20
+ string: [
21
21
  ["contains", I18n.t(i18n_path % 'contains')], # same as matches => %string%
22
22
  ["matches", I18n.t(i18n_path % 'matches')]
23
23
  ],
24
- :boolean => [
24
+ boolean: [
25
25
  ["is_any", I18n.t(i18n_path % 'is_true')],
26
26
  ["is_true", I18n.t(i18n_path % 'is_true')],
27
27
  ["is_false", I18n.t(i18n_path % 'is_false')]
28
28
  ],
29
- :date => [
29
+ date: [
30
30
  ["eq", I18n.t(i18n_path % 'date_equals')],
31
31
  ["gt", I18n.t(i18n_path % 'after')],
32
32
  ["lt", I18n.t(i18n_path % 'before')],
@@ -36,6 +36,8 @@ module Netzke
36
36
  }
37
37
 
38
38
  ATTRIBUTE_OPERATORS_MAP[:datetime] = ATTRIBUTE_OPERATORS_MAP[:date]
39
+ ATTRIBUTE_OPERATORS_MAP[:decimal] = ATTRIBUTE_OPERATORS_MAP[:integer]
40
+ ATTRIBUTE_OPERATORS_MAP[:float] = ATTRIBUTE_OPERATORS_MAP[:integer]
39
41
 
40
42
  js_configure do |c|
41
43
  c.extend = "Ext.form.FormPanel"
@@ -1,5 +1,5 @@
1
1
  module Netzke
2
2
  module Basepack
3
- VERSION = "0.11.0"
3
+ VERSION = "0.11.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-basepack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Gorin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: netzke-core