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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/netzke/basepack/columns.rb +0 -2
- data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +25 -28
- data/lib/netzke/basepack/grid.rb +2 -2
- data/lib/netzke/basepack/grid/javascripts/extensions.js +11 -0
- data/lib/netzke/basepack/grid/javascripts/grid.js +17 -2
- data/lib/netzke/basepack/search_panel.rb +7 -5
- data/lib/netzke/basepack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16a254ce373566ab871dcc25a79c46a1a33e687b
|
4
|
+
data.tar.gz: d46f4ce76ad16ebf476ee48b3f6e60a72a0e30f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -39,7 +39,9 @@ module Netzke::Basepack::DataAdapters
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def attr_type(attr_name)
|
42
|
-
|
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
|
-
|
118
|
+
method, assoc = method_and_assoc(c[:name])
|
117
119
|
|
118
120
|
if assoc
|
119
|
-
return !assoc.klass.column_names.include?(
|
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
|
-
|
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?(
|
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[
|
139
|
-
relation.to_a.map{ |r| [r.id, r.send(
|
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(
|
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
|
-
#
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
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
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
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[
|
371
|
+
update_predecate_for_datetime(arel_table[method], op, value.to_date)
|
375
372
|
when :string, :text
|
376
|
-
update_predecate_for_string(arel_table[
|
373
|
+
update_predecate_for_string(arel_table[method], op, value)
|
377
374
|
when :boolean
|
378
|
-
update_predecate_for_boolean(arel_table[
|
375
|
+
update_predecate_for_boolean(arel_table[method], op, value)
|
379
376
|
when :date
|
380
|
-
update_predecate_for_rest(arel_table[
|
377
|
+
update_predecate_for_rest(arel_table[method], op, value.to_date)
|
381
378
|
else
|
382
|
-
update_predecate_for_rest(arel_table[
|
379
|
+
update_predecate_for_rest(arel_table[method], op, value)
|
383
380
|
end
|
384
381
|
end
|
385
382
|
|
data/lib/netzke/basepack/grid.rb
CHANGED
@@ -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:
|
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
|
-
|
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
|
-
:
|
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
|
-
:
|
17
|
+
text: [
|
18
18
|
["contains", I18n.t(i18n_path % 'contains')] # same as matches => %string%
|
19
19
|
],
|
20
|
-
:
|
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
|
-
:
|
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
|
-
:
|
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"
|
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.
|
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-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netzke-core
|