agilibox 1.9.19 → 1.10.2

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: 6ec9c151ffb8cfeac78339974ae35f77124730d8e5a0f4103489c65c03738cff
4
- data.tar.gz: cf1862277f5a5fefff00dc06b356902d05ecb1b6e8b9b1bad12e973f4cbfe8fb
3
+ metadata.gz: c957ea49c90e282829586fcc2e643e29f0cafdf6de7addd6867e7c7ccb84b208
4
+ data.tar.gz: 7a03a0ccea759d460a7c67deb95f44e9e06f09ae89ddf9e8038e23f8112749a7
5
5
  SHA512:
6
- metadata.gz: df5df7fe6e3016d1740a684f8dbdcb44a85c37d299f02cabb2b056137a3745f6ef968f0f5f018d7f540286e9a51ef0a78f518aeaf824063dea2897e81c858db2
7
- data.tar.gz: 10a96821c98427c56b24d16e90b904038e7d2a4b60a38c495946ae3ff3d0c81adab668280103e68925e57124d072cc78a085d13c32f58351c97055aae1035098
6
+ metadata.gz: b458a4602f68758275b70049a33def1d27658af96e4d6941251702b0d2957b5968c3cd2cf7bb682338f4c3a931233e054636629e9539053ef5700ad9102c847b
7
+ data.tar.gz: f64d11c96a644d6f2871820a25f1ba000904dbecf50037fa07b69cfe37c1f87aab16041a9188f0fb78c9ff9d988597408ba8f3dac9d78682c755c3a5d1badc36
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v1.10.2
6
+ - Filters improvements
7
+
8
+ ## v1.10.1
9
+ - Fix date filters
10
+
11
+ ## v1.10.0
12
+ - Add date support to XLSX serializer
13
+ - Remove AXLSX serializer
14
+
15
+ ## v1.9.20
16
+ - Add bootstrap 5 search form
17
+
5
18
  ## v1.9.19
6
19
  - Add bootstrap 4/5 pagination support
7
20
 
@@ -1,4 +1,6 @@
1
1
  class Agilibox::SmallData::Filter
2
+ include ActiveModel::Model
3
+
2
4
  STRATEGIES = {}
3
5
 
4
6
  attr_reader :jar
@@ -60,8 +62,12 @@ class Agilibox::SmallData::Filter
60
62
  write read.merge(new_filters)
61
63
  end
62
64
 
65
+ def actives_count
66
+ read.count { |k, v| strategies.key?(k.to_s) && v.present? }
67
+ end
68
+
63
69
  def any?
64
- read.select { |k, v| strategies.key?(k.to_s) && v.present? }.any?
70
+ actives_count.positive?
65
71
  end
66
72
 
67
73
  def empty?
@@ -1,6 +1,6 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateBegin < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
- value = Time.zone.parse(value).beginning_of_day
3
+ value = Date.parse(value)
4
4
  column = column_for(query)
5
5
  query.where("#{column} >= ?", value)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateEnd < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
- value = Time.zone.parse(value).end_of_day
3
+ value = Date.parse(value)
4
4
  column = column_for(query)
5
5
  query.where("#{column} <= ?", value)
6
6
  end
@@ -39,8 +39,8 @@ class Agilibox::Serializers::Base
39
39
  I18n.t(value.to_s)
40
40
  end
41
41
 
42
- def format_datetime(value)
43
- Agilibox::AllHelpers.date(value)
42
+ def format_date_or_time(value)
43
+ value
44
44
  end
45
45
 
46
46
  def format_default(value)
@@ -48,10 +48,10 @@ class Agilibox::Serializers::Base
48
48
  end
49
49
 
50
50
  def formatter_for(value)
51
- return :integer if value.is_a?(Integer)
52
- return :decimal if value.is_a?(Numeric)
53
- return :boolean if value.is_a?(TrueClass) || value.is_a?(FalseClass)
54
- return :datetime if value.is_a?(Date) || value.is_a?(Time)
51
+ return :integer if value.is_a?(Integer)
52
+ return :decimal if value.is_a?(Numeric)
53
+ return :boolean if value.is_a?(TrueClass) || value.is_a?(FalseClass)
54
+ return :date_or_time if value.is_a?(Date) || value.is_a?(Time)
55
55
  return :default
56
56
  end
57
57
 
@@ -1,7 +1,13 @@
1
1
  class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
2
2
  def render_inline
3
3
  headers, *data = formatted_data
4
- SpreadsheetArchitect.to_xlsx(headers: headers, data: data, freeze_headers: true)
4
+
5
+ SpreadsheetArchitect.to_xlsx(
6
+ headers: headers,
7
+ data: data,
8
+ freeze_headers: true,
9
+ range_styles: range_styles(data[0]),
10
+ )
5
11
  end
6
12
 
7
13
  def render_file(file_path)
@@ -9,4 +15,24 @@ class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
9
15
  f.write(render_inline)
10
16
  end
11
17
  end
18
+
19
+ private
20
+
21
+ def range_styles(row)
22
+ return [] if row.nil?
23
+
24
+ date_range_styles(row) + time_range_styles(row)
25
+ end
26
+
27
+ def date_range_styles(row)
28
+ row.each_index.select { row[_1].is_a?(Date) }.map do
29
+ {range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy"}}
30
+ end
31
+ end
32
+
33
+ def time_range_styles(row)
34
+ row.each_index.select { row[_1].is_a?(Time) }.map do
35
+ {range: {rows: :all, columns: _1}, styles: {format_code: "dd/mm/yyyy hh:mm:ss"}}
36
+ end
37
+ end
12
38
  end
@@ -0,0 +1,7 @@
1
+ form.search.bs5.mb-3 method="get" action=action
2
+ = form_hidden_submit
3
+
4
+ .input-group.search
5
+ input.form-control.form-control-sm type="text" name="q" placeholder=ta(:search) value=params[:q]
6
+ button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" = icon(:times)
7
+ button.btn.btn-sm.bg-light.border.search-submit type="submit" = icon(:search)
@@ -1,5 +1,6 @@
1
1
  Capybara.register_driver :agilibox_no_driver do |_app|
2
- raise "You need to add Agilibox::CucumberConfig.require_cuprite! or "\
2
+ raise \
3
+ "You need to add Agilibox::CucumberConfig.require_cuprite! or " \
3
4
  "Agilibox::CucumberConfig.require_chrome_headless! " \
4
5
  "to your features/support/env.rb"
5
6
  end
@@ -9,6 +9,7 @@ class Agilibox::ErrorsMiddleware
9
9
  "ActionController::BadRequest",
10
10
  "ActionController::UnknownFormat",
11
11
  "ActionController::UnknownHttpMethod",
12
+ "ActionDispatch::Cookies::CookieOverflow",
12
13
  "ActionView::MissingTemplate",
13
14
  "Mime::Type::InvalidMimeType",
14
15
  ]
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.9.19"
2
+ VERSION = "1.10.2"
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.9.19
4
+ version: 1.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-26 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -125,7 +125,6 @@ files:
125
125
  - app/filters/agilibox/small_data/filter_strategy_by_key_value.rb
126
126
  - app/filters/agilibox/small_data/filter_strategy_by_key_values.rb
127
127
  - app/filters/agilibox/small_data/filter_strategy_by_tags.rb
128
- - app/filters/agilibox/small_data/filter_strategy_by_time_period.rb
129
128
  - app/forms/agilibox/mini_form_object.rb
130
129
  - app/helpers/agilibox/all_helpers.rb
131
130
  - app/helpers/agilibox/bootstrap_helper.rb
@@ -163,7 +162,6 @@ files:
163
162
  - app/models/concerns/agilibox/search.rb
164
163
  - app/models/concerns/agilibox/timestamp_helpers.rb
165
164
  - app/serializers/agilibox/serializers.rb
166
- - app/serializers/agilibox/serializers/axlsx.rb
167
165
  - app/serializers/agilibox/serializers/base.rb
168
166
  - app/serializers/agilibox/serializers/xlsx.rb
169
167
  - app/services/agilibox/service.rb
@@ -179,6 +177,7 @@ files:
179
177
  - app/views/agilibox/search/_form.html.slim
180
178
  - app/views/agilibox/search/_form_bs3.html.slim
181
179
  - app/views/agilibox/search/_form_bs4.html.slim
180
+ - app/views/agilibox/search/_form_bs5.html.slim
182
181
  - app/views/kaminari/bootstrap4/_first_page.html.slim
183
182
  - app/views/kaminari/bootstrap4/_gap.html.slim
184
183
  - app/views/kaminari/bootstrap4/_last_page.html.slim
@@ -1,6 +0,0 @@
1
- class Agilibox::SmallData::FilterStrategyByTimePeriod
2
- def initialize(*)
3
- raise "FilterStrategyByTimePeriod is deprecated, please use " \
4
- "FilterStrategyByDatePeriod or FilterStrategyByDatetimePeriod"
5
- end
6
- end
@@ -1,21 +0,0 @@
1
- class Agilibox::Serializers::AXLSX < Agilibox::Serializers::Base
2
- def render_inline
3
- xlsx.to_stream.read.force_encoding("BINARY")
4
- end
5
-
6
- def render_file(file_path)
7
- xlsx.serialize(file_path)
8
- end
9
-
10
- def xlsx
11
- @xlsx ||= Axlsx::Package.new do |p|
12
- p.workbook.add_worksheet do |sheet|
13
- formatted_data.each do |line|
14
- sheet.add_row(line)
15
- end
16
- end
17
-
18
- p.use_shared_strings = true
19
- end
20
- end
21
- end