agilibox 1.0.3 → 1.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: f7f739bd49f416e9f7d8a573c539df4789924c07
4
- data.tar.gz: 1b2117cc0abb18f89630d9e6cd3227867f4e0fe7
3
+ metadata.gz: 34fb21a5843843694e3e1a1f239ee8aed148f238
4
+ data.tar.gz: a805c337e3420c19fc10cf95e40087b68c9839bd
5
5
  SHA512:
6
- metadata.gz: 823620225894206e08757a10b9f1473ed3a6bdf13bcf1381430c3a5edd9b61e9a41ad927b6a8bc2c14146b98d652ee5f04a5dae030724095779e99e96eafe215
7
- data.tar.gz: 53b80b2fc9f2a9e6a0ac819de2b2f1bf04a06d749f865078d039fc0b08f71ddc8788f3efc6b6767fd00557cba51a54d4881c119022fe2184cf6db279ffc906a1
6
+ metadata.gz: e17dff217f2407f24f223f22294cd29b9304b545d3becf42737eb1a88f1c4a1a3ccf2643793b61d2bc8e9d0266ca3771c7e9ca9ae1226033bf79f30f696f37a2
7
+ data.tar.gz: bb84424a5d72162939ee056a0474b9489ee7d612a681b32b1854ca432e2b38002a6a4d74a88fe8699c66f86bfed13fe8a9063b66e5b9bda2dd8cddc20513c116
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.4
4
+
5
+ - Search now ignore accents
6
+ - Add Sorter class
7
+
3
8
  ## 1.0.3
4
9
 
5
10
  - Add `ta` (translate action) helper
@@ -14,7 +14,7 @@ module Agilibox::Search
14
14
 
15
15
  sql_query = words.map.with_index do |word, index|
16
16
  fields.map do |field|
17
- "(LOWER(CAST(#{field} AS TEXT)) LIKE :w#{index})"
17
+ "(UNACCENT(CAST(#{field} AS TEXT)) ILIKE :w#{index})"
18
18
  end.join(" OR ")
19
19
  end.map{ |e| "(#{e})" }.join(" AND ")
20
20
 
@@ -0,0 +1,26 @@
1
+ class Agilibox::Sorter
2
+ include Agilibox::SortingHelper
3
+
4
+ attr_reader :collection, :sort_param, :column, :direction
5
+
6
+ def initialize(collection, sort_param)
7
+ @collection = collection
8
+ @sort_param = sort_param
9
+ @column, @direction = sortable_column_order(sort_param.to_s)
10
+ end
11
+
12
+ def sort
13
+ raise NotImplementedError
14
+ end
15
+
16
+ def call
17
+ # Don't replace by `collection.reorder(sort)`
18
+ # #sort can change #collection and must be called before #collection
19
+ order = sort
20
+ collection.reorder(order)
21
+ end
22
+
23
+ def self.call(*args)
24
+ new(*args).call
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ class EnableUnaccent < ActiveRecord::Migration[5.0]
2
+ def change
3
+ enable_extension "unaccent"
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilibox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-06 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -79,10 +79,12 @@ files:
79
79
  - app/serializers/agilibox/serializers.rb
80
80
  - app/serializers/agilibox/serializers/base.rb
81
81
  - app/serializers/agilibox/serializers/xlsx.rb
82
+ - app/sorters/agilibox/sorter.rb
82
83
  - app/views/agilibox/search/_form.html.slim
83
84
  - config/locales/common.en.yml
84
85
  - config/locales/common.fr.yml
85
86
  - config/routes.rb
87
+ - db/migrate/20170502143330_enable_unaccent.rb
86
88
  - lib/agilibox.rb
87
89
  - lib/agilibox/active_record_comma_type_cast.rb
88
90
  - lib/agilibox/core_and_rails_ext.rb