egov_utils 0.3.3 → 0.3.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 +4 -4
- data/app/helpers/egov_utils/application_helper.rb +1 -0
- data/app/helpers/egov_utils/grid_helper.rb +4 -4
- data/lib/azahara_schema_currency.rb +10 -0
- data/lib/azahara_schema_currency/association_attribute_patch.rb +9 -0
- data/lib/azahara_schema_currency/attribute_formatter_patch.rb +24 -0
- data/lib/azahara_schema_currency/currency_attribute.rb +22 -0
- data/lib/azahara_schema_currency/currency_format.rb +5 -0
- data/lib/egov_utils/engine.rb +1 -0
- data/lib/egov_utils/version.rb +1 -1
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 674e8db7ce7f9de0944efee865134ecde920a578b259c23ce74370ba4ba35ada
|
4
|
+
data.tar.gz: cfd4672a9a481389924b9dc69f485bcedbcd824ca4ed5969d6825a2d09b3e5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd772c57e1c3e27f6f3281238e2e317c01fae05fc6027398a828b6a5281b0c99edb0a7269c4fd0cb8862b090275057ff9041aa4b58b7fd6980150bb524df024
|
7
|
+
data.tar.gz: 5ead03e0f48e6da8aa5293786f3019e4668b6b30f2a81e03a58647506a03717b79c75318d63e9c0d89baa33d8a27c07fc00b60c72f65d8a4a73ff18c275438e0
|
@@ -5,6 +5,7 @@ module EgovUtils
|
|
5
5
|
s = ''
|
6
6
|
s << "window.I18n.defaultLocale = '#{I18n.default_locale}';"
|
7
7
|
s << "window.I18n.locale = '#{I18n.locale}';"
|
8
|
+
s << "window.currency_symbols = #{Money::Currency.table.each_with_object({}){|(k,v),o|o[k]=v[:symbol]}.to_json};"
|
8
9
|
s
|
9
10
|
javascript_tag s
|
10
11
|
end
|
@@ -3,7 +3,7 @@ module EgovUtils
|
|
3
3
|
|
4
4
|
def type_for_grid(type)
|
5
5
|
case type
|
6
|
-
when 'integer', 'float', 'decimal'
|
6
|
+
when 'integer', 'float', 'decimal', 'currency'
|
7
7
|
'Number'
|
8
8
|
when 'string', 'text', 'list', 'love'
|
9
9
|
'String'
|
@@ -57,10 +57,10 @@ module EgovUtils
|
|
57
57
|
|
58
58
|
if attribute.type == 'list'
|
59
59
|
s << ", format: ( (value) -> I18n.t('#{attribute.attribute_name.i18n_scoped_list_prefix}'+'.'+value, {defaults: $.map( #{attribute.attribute_name.i18n_list_fallback_prefixes.to_json}, (pref, i)-> {scope: (pref + '.' + value)} )}) ) "
|
60
|
-
elsif attribute.type
|
60
|
+
elsif %w(date datetime).include?(attribute.type)
|
61
61
|
s << ", format: ( (value)-> I18n.l('date.formats.default', value) )"
|
62
|
-
elsif attribute.type == '
|
63
|
-
s << ",
|
62
|
+
elsif attribute.type == 'currency'
|
63
|
+
s << ", columnTemplate: ( (cell, item, index)-> $('<div></div>').appendTo(cell).html( I18n.toCurrency(item['#{attribute.name}'], { unit: window.currency_symbols[item['#{attribute.try(:currency_code_col)}']]}) ) )"
|
64
64
|
end
|
65
65
|
s << "}"
|
66
66
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'money'
|
2
|
+
|
3
|
+
require 'azahara_schema_currency/currency_format'
|
4
|
+
require 'azahara_schema_currency/currency_attribute'
|
5
|
+
|
6
|
+
require 'azahara_schema_currency/attribute_formatter_patch'
|
7
|
+
AzaharaSchema::AttributeFormatter.__send__('prepend', AzaharaSchemaCurrency::AttributeFormatterPatch)
|
8
|
+
|
9
|
+
require 'azahara_schema_currency/association_attribute_patch'
|
10
|
+
AzaharaSchema::AssociationAttribute.__send__('prepend', AzaharaSchemaCurrency::AssociationAttributePatch)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AzaharaSchemaCurrency
|
2
|
+
module AttributeFormatterPatch
|
3
|
+
|
4
|
+
def format_value_html(attribute, unformated_value, **options)
|
5
|
+
case attribute.type
|
6
|
+
when 'currency'
|
7
|
+
Money.new(unformated_value, options[:currency_code].to_s.upercase.presence).format
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def formatting_options(attribute, entity)
|
15
|
+
case attribute.type
|
16
|
+
when 'currency'
|
17
|
+
{currency_code: attribute.currency_code(entity).to_s}
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Author:: Ondřej Ezr (mailto:oezr@msp.justice.cz)
|
2
|
+
# Copyright:: Copyright (c) 2018 Ministry of Justice
|
3
|
+
# License:: Distributes under license Open Source Licence pro Veřejnou Správu a Neziskový Sektor v.1
|
4
|
+
|
5
|
+
module AzaharaSchemaCurrency
|
6
|
+
class CurrencyAttribute < AzaharaSchema::Attribute
|
7
|
+
|
8
|
+
def initialize(model, name, type='currency', **options)
|
9
|
+
super(model, name, type)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def currency_code_col
|
14
|
+
@options[:currency_code_method] || 'currency_code'
|
15
|
+
end
|
16
|
+
|
17
|
+
def currency_code(entity)
|
18
|
+
entity.try(currency_code_col)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/egov_utils/engine.rb
CHANGED
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '2.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: money
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '6.11'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '6.11'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: request_store_rails
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,14 +226,14 @@ dependencies:
|
|
212
226
|
requirements:
|
213
227
|
- - "~>"
|
214
228
|
- !ruby/object:Gem::Version
|
215
|
-
version: 4.0.0
|
229
|
+
version: 4.0.0
|
216
230
|
type: :runtime
|
217
231
|
prerelease: false
|
218
232
|
version_requirements: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
234
|
- - "~>"
|
221
235
|
- !ruby/object:Gem::Version
|
222
|
-
version: 4.0.0
|
236
|
+
version: 4.0.0
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: sass-rails
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -494,6 +508,11 @@ files:
|
|
494
508
|
- db/migrate/20180403133155_create_egov_utils_people_base.rb
|
495
509
|
- db/migrate/20180403141531_join_people_tables.rb
|
496
510
|
- db/migrate/20180403150556_create_egov_utils_legal_people.rb
|
511
|
+
- lib/azahara_schema_currency.rb
|
512
|
+
- lib/azahara_schema_currency/association_attribute_patch.rb
|
513
|
+
- lib/azahara_schema_currency/attribute_formatter_patch.rb
|
514
|
+
- lib/azahara_schema_currency/currency_attribute.rb
|
515
|
+
- lib/azahara_schema_currency/currency_format.rb
|
497
516
|
- lib/bootstrap_form/check_box_patch.rb
|
498
517
|
- lib/bootstrap_form/custom_file_field.rb
|
499
518
|
- lib/bootstrap_form/datetimepicker.rb
|