checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 6f2f44dd973a477f962ee2e76805ca19f698a011d9000cedcd83aae30673dbaa
4
- data.tar.gz: 90ba13ccc6e08721384bb9abd608fe716166f695b7f09841abc5afa60eb1c2ab
3
+ metadata.gz: 21f228e7863e5274343cddda10e487d18fe613c5dc6bc520e2db03f0475cf7fa
4
+ data.tar.gz: b981d9c578d42bca6253c38bbb31690c3f0b417d1f43cbd23ed3a5ffac2e2bbd
5
5
SHA512:
6
- metadata.gz: 5f81afa67332d05cf6ff56d78ac408d3fbeb8bbd01bcdbee99b8d2cc7547b8318192b4ea00ecb954f39e58e8ff90f484add167d7e1f09b4120862d0008192d25
7
- data.tar.gz: e6db62b2dfcd78066dec9982171b2c0a66fb02898a77e08edafd2d86b4d26e66d3bedd929457f4a7c048a0dcf416b3e282c70c0d4897ec5132abf537401aee1d
6
+ metadata.gz: cf9b9f217b374801aa1cff551b27dbe0454c82acd8608437918f9b3b301541bcddc40b8bc4d5d4353ba1d833a82ea3eca561c0a3111919836aafcc49e0144aef
7
+ data.tar.gz: 3559c5cc114505be9fac3391222f29bdde5fbe2c4f75fe385b80fc6c8713332dff084a60e73a0a45596c9d8b67e4fbf8ab532a6d341ac5a6a22f029dba9a717d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
3
3
## Next version
4
4
5
+ ## 1.6.0
6
+ - Remove `GetHTTP`
7
+ - I18n fixes
8
+ - Add `Agilibox::TapMethods`
9
+ - Filters CSS : add flex-wrap
10
+ - Add `bs_card` helper
11
+ - Add `:br` separator to `info` helper
12
+ - TextHelper refactors
13
+ - Update dummy app to Rails 5.2
14
+ - Replace AXLSX by SpreadsheetArchitect
15
+
5
16
## 1.5.13
6
17
- Fix `info` helper with nested blank value
7
18
data/app/assets/stylesheets/agilibox/filters.sass CHANGED
@@ -6,6 +6,7 @@
6
6
padding: 8px
7
7
box-shadow: none
8
8
display: flex
9
+ flex-wrap: wrap
9
10
flex-direction: initial
10
11
background: #F0F0F0
11
12
data/app/helpers/agilibox/bootstrap_helper.rb CHANGED
@@ -1,4 +1,19 @@
1
1
module Agilibox::BootstrapHelper
2
+ class << self
3
+ attr_writer :card_classes
4
+
5
+ # rubocop:disable Rails/HelperInstanceVariable
6
+ def card_classes
7
+ @card_classes ||= {
8
+ :card => "card",
9
+ :header => "card-header",
10
+ :body => "card-body",
11
+ :footer => "card-footer",
12
+ }
13
+ end
14
+ # rubocop:enable Rails/HelperInstanceVariable
15
+ end
16
+
2
17
def bs_progress_bar(percentage)
3
18
content_tag(:div, class: "progress") do
4
19
content_tag(:div, class: "progress-bar", style: "width:#{percentage}%") do
@@ -6,4 +21,47 @@ module Agilibox::BootstrapHelper
6
21
end
7
22
end
8
23
end
24
+
25
+ def bs_card( # rubocop:disable Metrics/ParameterLists
26
+ header: nil,
27
+ body: true,
28
+ footer: nil,
29
+ card_tag: :div,
30
+ header_tag: :div,
31
+ body_tag: :div,
32
+ footer_tag: :div,
33
+ card_class: nil,
34
+ header_class: nil,
35
+ body_class: nil,
36
+ footer_class: nil,
37
+ &block
38
+ )
39
+ global_classes = Agilibox::BootstrapHelper.card_classes
40
+ card_classes = ([global_classes[:card]] + card_class.to_s.split(" ")).compact.sort
41
+ header_classes = ([global_classes[:header]] + header_class.to_s.split(" ")).compact.sort
42
+ body_classes = ([global_classes[:body]] + body_class.to_s.split(" ")).compact.sort
43
+ footer_classes = ([global_classes[:footer]] + footer_class.to_s.split(" ")).compact.sort
44
+
45
+ if header
46
+ header_html = content_tag(header_tag, class: header_classes) { header }
47
+ else
48
+ header_html = "".html_safe
49
+ end
50
+
51
+ if body
52
+ body_html = content_tag(body_tag, class: body_classes) { capture(&block) }
53
+ else
54
+ body_html = capture(&block)
55
+ end
56
+
57
+ if footer
58
+ footer_html = content_tag(footer_tag, class: footer_classes) { footer }
59
+ else
60
+ footer_html = "".html_safe
61
+ end
62
+
63
+ content_tag(card_tag, class: card_classes) do
64
+ header_html + body_html + footer_html
65
+ end
66
+ end
9
67
end
data/app/helpers/agilibox/text_helper.rb CHANGED
@@ -5,7 +5,7 @@ module Agilibox::TextHelper
5
5
6
6
def nbsp(text = :no_argument)
7
7
if text == :no_argument
8
- " "
8
+ "\u00A0"
9
9
else
10
10
text.to_s.gsub(" ", nbsp)
11
11
end
@@ -21,13 +21,13 @@ module Agilibox::TextHelper
21
21
I18n.t("number.currency.format.format")
22
22
.gsub("%n", number(n))
23
23
.gsub("%u", u)
24
- .tr(" ", "\u00A0")
24
+ .tr(" ", nbsp)
25
25
end
26
26
27
27
def percentage(n)
28
28
return if n.nil?
29
29
30
- (number(n) + " %").tr(" ", "\u00A0")
30
+ number(n) + nbsp + "%"
31
31
end
32
32
33
33
def number(n)
@@ -44,7 +44,7 @@ module Agilibox::TextHelper
44
44
opts[:delimiter] = I18n.t("number.format.delimiter")
45
45
opts[:separator] = I18n.t("number.format.separator")
46
46
47
- number_with_precision(n, opts).tr(" ", "\u00A0")
47
+ number_with_precision(n, opts).tr(" ", nbsp)
48
48
end
49
49
50
50
def date(d, *args)
@@ -101,6 +101,7 @@ module Agilibox::TextHelper
101
101
label = options[:label] || object.t(attribute)
102
102
tag = options[:tag] || :div
103
103
separator = options[:separator] || " : "
104
+ separator = " :<br/>".html_safe if separator == :br
104
105
helper = options[:helper]
105
106
i18n_key = "#{object.class.to_s.tableize.singularize}/#{attribute}"
106
107
nested = I18n.t("activerecord.attributes.#{i18n_key}", default: "").is_a?(Hash)
data/app/libs/agilibox/get_http.rb DELETED
@@ -1,55 +0,0 @@
1
- class Agilibox::GetHTTP < Agilibox::Service
2
- class Error < StandardError
3
- end
4
-
5
- EXCEPTIONS_TO_RERAISE = [
6
- IOError,
7
- Net::HTTPBadResponse,
8
- Net::HTTPExceptions,
9
- Net::HTTPHeaderSyntaxError,
10
- OpenSSL::SSL::SSLError,
11
- SocketError,
12
- SystemCallError,
13
- Timeout::Error,
14
- Zlib::Error,
15
- ]
16
-
17
- TIMEOUT = 10
18
-
19
- initialize_with :url
20
-
21
- def uri
22
- uri = URI(url.to_s)
23
- raise Error, "invalid URI type : #{uri.class}" unless uri.is_a?(URI::HTTP)
24
- uri
25
- end
26
-
27
- def response
28
- @response ||= fetch_response
29
- end
30
-
31
- def call
32
- response.body
33
- end
34
-
35
- private
36
-
37
- def fetch_response
38
- http_response = Timeout.timeout(TIMEOUT) do
39
- Net::HTTP.get_response(uri)
40
- end
41
-
42
- if http_response.code.start_with?("3")
43
- @url = http_response["Location"]
44
- return fetch_response
45
- end
46
-
47
- unless http_response.code.start_with?("2")
48
- raise Error, "invalid response code : #{http_response.code}"
49
- end
50
-
51
- http_response
52
- rescue *EXCEPTIONS_TO_RERAISE => e
53
- raise Error, e.message
54
- end
55
- end
data/app/models/concerns/agilibox/tap_methods.rb ADDED
@@ -0,0 +1,23 @@
1
+ module Agilibox::TapMethods
2
+ extend ActiveSupport::Concern
3
+
4
+ def tap_save!(options = {})
5
+ save!(options)
6
+ self
7
+ end
8
+
9
+ def tap_update!(attributes)
10
+ update!(attributes)
11
+ self
12
+ end
13
+
14
+ def tap_validate(context = nil)
15
+ validate(context)
16
+ self
17
+ end
18
+
19
+ def tap_validate!(context = nil)
20
+ validate!(context)
21
+ self
22
+ end
23
+ end
data/app/serializers/agilibox/serializers/axlsx.rb ADDED
@@ -0,0 +1,21 @@
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
data/app/serializers/agilibox/serializers/base.rb CHANGED
@@ -6,6 +6,12 @@ class Agilibox::Serializers::Base
6
6
@options = options
7
7
end
8
8
9
+ def formatted_data
10
+ data.map do |line|
11
+ line.map { |value| self.class.format(value) }
12
+ end
13
+ end
14
+
9
15
def render_inline
10
16
raise NotImplementedError
11
17
end
data/app/serializers/agilibox/serializers/xlsx.rb CHANGED
@@ -1,22 +1,11 @@
1
1
class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
2
2
def render_inline
3
- xlsx.to_stream.read.force_encoding("BINARY")
3
+ SpreadsheetArchitect.to_xlsx(data: formatted_data)
4
4
end
5
5
6
6
def render_file(file_path)
7
- xlsx.serialize(file_path)
8
- end
7
+ File.open(file_path, "w+b") do |f|
8
+ f.write(render_inline)
9
-
10
- def xlsx
11
- @xlsx ||= Axlsx::Package.new do |p|
12
- p.workbook.add_worksheet do |sheet|
13
- data.each do |line|
14
- values = line.map { |value| self.class.format(value) }
15
- sheet.add_row(values)
16
- end
17
- end
18
-
19
- p.use_shared_strings = true
20
9
end
21
10
end
22
11
end
data/app/views/agilibox/_flash.html.slim CHANGED
@@ -5,4 +5,5 @@
5
5
6
6
.alert class="alert-#{type}"
7
7
= message
8
- button.close data-dismiss="alert" aria-label="Fermer" = "×"
8
+ button.close data-dismiss="alert" aria-label=ta(:close) title=ta(:close)
9
+ = "×"
data/lib/agilibox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module Agilibox
2
- VERSION = "1.5.13"
2
+ VERSION = "1.6.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.5.13
4
+ version: 1.6.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: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: rails-i18n
@@ -115,7 +115,6 @@ files:
115
115
- app/libs/agilibox/collection_update.rb
116
116
- app/libs/agilibox/fcm/notifier.rb
117
117
- app/libs/agilibox/fcm/request.rb
118
- - app/libs/agilibox/get_http.rb
119
118
- app/libs/agilibox/initialize_with.rb
120
119
- app/libs/agilibox/mini_model_serializer/serialize.rb
121
120
- app/libs/agilibox/mini_model_serializer/serializer.rb
@@ -133,8 +132,10 @@ files:
133
132
- app/models/concerns/agilibox/pluck_to_hash.rb
134
133
- app/models/concerns/agilibox/polymorphic_id.rb
135
134
- app/models/concerns/agilibox/search.rb
135
+ - app/models/concerns/agilibox/tap_methods.rb
136
136
- app/models/concerns/agilibox/timestamp_helpers.rb
137
137
- app/serializers/agilibox/serializers.rb
138
+ - app/serializers/agilibox/serializers/axlsx.rb
138
139
- app/serializers/agilibox/serializers/base.rb
139
140
- app/serializers/agilibox/serializers/xlsx.rb
140
141
- app/services/agilibox/service.rb