agilibox 1.2.0 → 1.2.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
  SHA256:
3
- metadata.gz: c47b5f9188e74619272d53f2f46dccaba3fbbdb4f36ff862a2fc42964d9272ad
4
- data.tar.gz: db7e31ea1f12048dc3bee0a6483d74f54b041260372ceb9a43352dceaee3a189
3
+ metadata.gz: b42ef5b03fc57fe2ff9cb01ac9aaf7b784b574eafe4ee68859501e088ff39e88
4
+ data.tar.gz: 782675f5041b1e5b41690217b995fdcc0b1ef225ad81d25489ca0f1e9a0db5ee
5
5
  SHA512:
6
- metadata.gz: 73b32e94afc159700b611ae0fb1363bcab445f5b12ad6cc89145b8ae4192581fd0977f14e94bb533cb2454b97f6286fbcd572bfdb1d10a0b4400d00f9a7de87d
7
- data.tar.gz: 15636d5f9372df16d14ddfbbb076b564b25183cce1ffc80e55260e5df3e68e4d33e65d21fa471fdcf3669aa27a3f18960b94f2b029daaaafef2b2f3affe0a6ac
6
+ metadata.gz: 812c848c24e8e85dcf7da2b743fc7be4f2ea992fb5c77f2e352f5793e0a59b66127d07d4662f54563f879ad1061474e4e80bf6b6585ab8163f1f583cc44e699d
7
+ data.tar.gz: 83dfd77a0e25e0734e5294006a52def01817eb28c5fca6bddf36669454e0137cb29ff92321098890e5a95d3263dea9ac4829795a3c141ab03fecf53ad631296c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.1
4
+
5
+ - Fix flash partial
6
+ - Filter by date/datetime period now allows custom periods
7
+ - Sorter class improvements
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  - Add `Agilibox::MiniFormObject`
@@ -0,0 +1,56 @@
1
+ class Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
+ def initialize(*)
3
+ if self.class == Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
4
+ raise "please use FilterStrategyByDatePeriod or FilterStrategyByDatetimePeriod"
5
+ end
6
+
7
+ super
8
+ end
9
+
10
+ def apply(query, value) # rubocop:disable Metrics/MethodLength
11
+ value = value.to_s
12
+
13
+ if value == "today"
14
+ a = now
15
+ b = now
16
+ elsif value == "yesterday"
17
+ a = (now - 1.day)
18
+ b = (now - 1.day)
19
+ elsif value == "this_week"
20
+ a = now.beginning_of_week
21
+ b = now.end_of_week
22
+ elsif value == "this_month"
23
+ a = now.beginning_of_month
24
+ b = now.end_of_month
25
+ elsif value == "this_year"
26
+ a = now.beginning_of_year
27
+ b = now.end_of_year
28
+ elsif value == "last_week"
29
+ a = (now - 1.week).beginning_of_week
30
+ b = (now - 1.week).end_of_week
31
+ elsif value == "last_month"
32
+ a = (now - 1.month).beginning_of_month
33
+ b = (now - 1.month).end_of_month
34
+ elsif value == "last_year"
35
+ a = (now - 1.year).beginning_of_year
36
+ b = (now - 1.year).end_of_year
37
+ elsif (m = value.match(/last\.([0-9]+)\.(days?|weeks?|months?|years?)/))
38
+ a = now - m[1].to_i.public_send(m[2])
39
+ b = now
40
+ else
41
+ return query
42
+ end
43
+
44
+ if now.is_a?(Time)
45
+ a = a.beginning_of_day if a
46
+ b = b.end_of_day if b
47
+ end
48
+
49
+ column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
50
+
51
+ query = query.where("#{column} >= ?", a) if a
52
+ query = query.where("#{column} <= ?", b) if b
53
+
54
+ query
55
+ end
56
+ end
@@ -1,37 +1,5 @@
1
- class Agilibox::SmallData::FilterStrategyByDatePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
- def apply(query, value)
3
- value = value.to_s
4
-
5
- if value == "today"
6
- a = Date.current
7
- b = Date.current
8
- elsif value == "yesterday"
9
- a = (Date.current - 1.day)
10
- b = (Date.current - 1.day)
11
- elsif value == "this_week"
12
- a = Date.current.beginning_of_week
13
- b = Date.current.end_of_week
14
- elsif value == "this_month"
15
- a = Date.current.beginning_of_month
16
- b = Date.current.end_of_month
17
- elsif value == "this_year"
18
- a = Date.current.beginning_of_year
19
- b = Date.current.end_of_year
20
- elsif value == "last_week"
21
- a = (Date.current - 1.week).beginning_of_week
22
- b = (Date.current - 1.week).end_of_week
23
- elsif value == "last_month"
24
- a = (Date.current - 1.month).beginning_of_month
25
- b = (Date.current - 1.month).end_of_month
26
- elsif value == "last_year"
27
- a = (Date.current - 1.year).beginning_of_year
28
- b = (Date.current - 1.year).end_of_year
29
- else
30
- return query
31
- end
32
-
33
- column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
34
-
35
- query.where("#{column} >= ? AND #{column} <= ?", a, b)
1
+ class Agilibox::SmallData::FilterStrategyByDatePeriod < ::Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
2
+ def now
3
+ Date.current
36
4
  end
37
5
  end
@@ -1,37 +1,5 @@
1
- class Agilibox::SmallData::FilterStrategyByDatetimePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
- def apply(query, value)
3
- value = value.to_s
4
-
5
- if value == "today"
6
- a = Time.zone.now.beginning_of_day
7
- b = Time.zone.now.end_of_day
8
- elsif value == "yesterday"
9
- a = (Time.zone.now - 1.day).beginning_of_day
10
- b = (Time.zone.now - 1.day).end_of_day
11
- elsif value == "this_week"
12
- a = Time.zone.now.beginning_of_week
13
- b = Time.zone.now.end_of_week
14
- elsif value == "this_month"
15
- a = Time.zone.now.beginning_of_month
16
- b = Time.zone.now.end_of_month
17
- elsif value == "this_year"
18
- a = Time.zone.now.beginning_of_year
19
- b = Time.zone.now.end_of_year
20
- elsif value == "last_week"
21
- a = (Time.zone.now - 1.week).beginning_of_week
22
- b = (Time.zone.now - 1.week).end_of_week
23
- elsif value == "last_month"
24
- a = (Time.zone.now - 1.month).beginning_of_month
25
- b = (Time.zone.now - 1.month).end_of_month
26
- elsif value == "last_year"
27
- a = (Time.zone.now - 1.year).beginning_of_year
28
- b = (Time.zone.now - 1.year).end_of_year
29
- else
30
- return query
31
- end
32
-
33
- column = key.is_a?(Symbol) ? "#{query.model.table_name}.#{key}" : key.to_s
34
-
35
- query.where("#{column} >= ? AND #{column} <= ?", a, b)
1
+ class Agilibox::SmallData::FilterStrategyByDatetimePeriod < ::Agilibox::SmallData::FilterStrategyByDateOrDatetimePeriod
2
+ def now
3
+ Time.zone.now
36
4
  end
37
5
  end
@@ -3,7 +3,7 @@ class Agilibox::Sorter
3
3
 
4
4
  attr_reader :collection, :sort_param, :column, :direction
5
5
 
6
- def initialize(collection, sort_param)
6
+ def initialize(collection, sort_param = nil)
7
7
  @collection = collection
8
8
  @sort_param = sort_param
9
9
  @column, @direction = sortable_column_order(sort_param.to_s)
@@ -1,4 +1,4 @@
1
- #flash.container
1
+ #flash
2
2
  - flash.map do |type, message|
3
3
  - type = "success" if type == "notice"
4
4
  - type = "danger" if type == "alert"
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -87,6 +87,7 @@ files:
87
87
  - app/filters/agilibox/small_data/filter_strategy_by_date.rb
88
88
  - app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb
89
89
  - app/filters/agilibox/small_data/filter_strategy_by_date_end.rb
90
+ - app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb
90
91
  - app/filters/agilibox/small_data/filter_strategy_by_date_period.rb
91
92
  - app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb
92
93
  - app/filters/agilibox/small_data/filter_strategy_by_key_value.rb