agilibox 1.9.20 → 1.10.0

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: 8e10ef85cda205b913421360ffdd960056fcc37df3e8ffa92e130cb0c09f3310
4
- data.tar.gz: d3a4c1af561aa8bc1b4cfb80bf8e3b6202b3a98d73b80b18df0e7c91fdf88825
3
+ metadata.gz: b79eff8bab58fe3ca456bb0f4ed5eb18de97fd7a82dc247751a094a4fb91a961
4
+ data.tar.gz: b13ee9bd49da7ceccee0f20737706ab1a9a3d4762688902bc773be94950af6cd
5
5
  SHA512:
6
- metadata.gz: ef482cd542ee089625a500352c6808e8638990f6acd5d3f8bf3d46dd92e9df723838d3a1d9b714352b43a742969730b4d866028fcd3e97691e01a5cec3e95b94
7
- data.tar.gz: fade774279ccc5f30a67d0b158b7913c153daa8da702932eeba74e8450c4147cef300566a8ee42aeb14eeb068c0c4fe0bdf82e8133e633ffef71a1a5fe5dc54c
6
+ metadata.gz: 599316ad810f15843e060a9cc5034cc76b505cde1bda4066deccd8bad1470986ad5bf3fecaa1e4712ede494904a06851a5df1a8852beeb0a087e5677bf118bb8
7
+ data.tar.gz: 92a2e1834215bfd50c322163cb59dfa22ea025aa4e52ee345815b5cebadb4cc3f45f376d8205e934e8aba4c8cf7cfe71813e367d4dd06e53cbbe1cf6cf329c3f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v1.10.0
6
+ - Add date support to XLSX serializer
7
+ - Remove AXLSX serializer
8
+
5
9
  ## v1.9.20
6
10
  - Add bootstrap 5 search form
7
11
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.9.20"
2
+ VERSION = "1.10.0"
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.20
4
+ version: 1.10.0
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-31 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -163,7 +163,6 @@ files:
163
163
  - app/models/concerns/agilibox/search.rb
164
164
  - app/models/concerns/agilibox/timestamp_helpers.rb
165
165
  - app/serializers/agilibox/serializers.rb
166
- - app/serializers/agilibox/serializers/axlsx.rb
167
166
  - app/serializers/agilibox/serializers/base.rb
168
167
  - app/serializers/agilibox/serializers/xlsx.rb
169
168
  - app/services/agilibox/service.rb
@@ -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