avo-money_field 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 655569e5199b518fb5dbb825bf6bdafe675d65dbb643ac1d07962322722dfc8b
4
- data.tar.gz: 8307eea78c63ed8670484c011f991cf24a9da067b3b8f475445aa5555e3d8a71
3
+ metadata.gz: 910589f65e9e88bee4e6991fd9bc078b593928d7963d592b69cb17d6eb461ce1
4
+ data.tar.gz: c3b44a78430e6adf62ba37590940f224ef60a8c8257906d3e3448adaf6c2baa4
5
5
  SHA512:
6
- metadata.gz: 2f995ce7c837c947da912b73d0cda93763a205dff2eede3bbcd15a84188731565056243d0a867b70949b1ce2a0423b8e3ab91775995f16ada8ea6e9b0f52ac09
7
- data.tar.gz: 1ddf279b769880b7db683d0a1fe3a382afec82e70232cf111d5d8bac83f321a8b344fd8002d0bed557c9bd7989a15b2027058af203183059d75314caf209ea0b
6
+ metadata.gz: 304b31602df40581a50a47f148a6489405299b4a50217e2452544ff652e05659ecf96d174d0e34e755a87a0e23d6058a7968ec4e77c8dce1c015a21457d9ed50
7
+ data.tar.gz: 61710f37650fc6e87b7c4a6c798a138dfa153129ab33fd1dfb86789023bb7d7b826ed097cf64ddf4aaa616be41ce40b8c3ab7681c41683c1e888d8d423d3bf99
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Avo Money Field
2
2
 
3
- A simple money field for https://github.com/avo-hq/avo.
3
+ A simple money field for [avo-hq/avo](https://github.com/avo-hq/avo), a Rails Admin Panel and Internal Tool Builder.
4
4
 
5
5
  Docs available at [https://docs.avohq.io/3.0/fields/money.html](https://docs.avohq.io/3.0/fields/money.html)
6
6
 
@@ -10,13 +10,15 @@
10
10
  multiple: multiple,
11
11
  autocomplete: @field.autocomplete
12
12
  %>
13
- <%= @form.select @field.currency_column,
14
- options_for_select(@field.currencies, selected: @field.currency),
15
- {},
16
- class: classes("w-24"),
17
- disabled: disabled?,
18
- value: @field.currency,
19
- autocomplete: @field.autocomplete
20
- %>
13
+ <% if @field.enable_currency %>
14
+ <%= @form.select @field.currency_column,
15
+ options_for_select(@field.currencies, selected: @field.currency),
16
+ {},
17
+ class: classes("w-24"),
18
+ disabled: disabled?,
19
+ value: @field.currency,
20
+ autocomplete: @field.autocomplete
21
+ %>
22
+ <% end %>
21
23
  </div>
22
24
  <% end %>
@@ -4,6 +4,7 @@ module Avo
4
4
  class MoneyField < Avo::Fields::BaseField
5
5
  attr_reader :currencies
6
6
  attr_reader :currency_suffix
7
+ attr_reader :enable_currency
7
8
 
8
9
  def initialize(id, **args, &block)
9
10
  super(id, **args, &block)
@@ -11,6 +12,7 @@ module Avo
11
12
  add_array_prop args, :currencies
12
13
  currency_suffix = defined?(MoneyRails) ? ::MoneyRails::Configuration.currency_column[:postfix] : :_currency
13
14
  add_string_prop args, :currency_suffix, currency_suffix
15
+ add_boolean_prop args, :enable_currency, true
14
16
  end
15
17
 
16
18
  def to_permitted_param
@@ -19,13 +21,13 @@ module Avo
19
21
 
20
22
  def fill_field(record, key, value, params)
21
23
  record.public_send(:"#{key}=", value)
22
- record.public_send(:"#{key}#{@currency_suffix}=", params[:"#{key}#{@currency_suffix}"])
24
+ record.public_send(:"#{key}#{@currency_suffix}=", params[:"#{key}#{@currency_suffix}"]) if enable_currency
23
25
 
24
26
  record
25
27
  end
26
28
 
27
29
  def currency
28
- value.send(:currency)
30
+ value && value.send(:currency)
29
31
  end
30
32
 
31
33
  def currency_column
@@ -1,8 +1,12 @@
1
+ require_relative "fields/money_field"
2
+
1
3
  module Avo
2
4
  module MoneyField
3
5
  class Railtie < Rails::Railtie
4
6
  initializer "avo-money_field.init" do
5
- Avo.plugin_manager.register Avo::MoneyField::Plugin
7
+ ActiveSupport.on_load(:avo_boot) do
8
+ Avo.plugin_manager.register_field :money, Avo::MoneyField::Fields::MoneyField
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -1,5 +1,5 @@
1
1
  module Avo
2
2
  module MoneyField
3
- VERSION = "0.0.4" unless const_defined?(:VERSION)
3
+ VERSION = "0.0.6" unless const_defined?(:VERSION)
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo-money_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: money-rails
@@ -40,14 +39,12 @@ files:
40
39
  - lib/avo/money_field/fields/money_field/index_component.rb
41
40
  - lib/avo/money_field/fields/money_field/show_component.html.erb
42
41
  - lib/avo/money_field/fields/money_field/show_component.rb
43
- - lib/avo/money_field/plugin.rb
44
42
  - lib/avo/money_field/railtie.rb
45
43
  - lib/avo/money_field/version.rb
46
44
  homepage: https://avohq.io
47
45
  licenses:
48
46
  - MIT
49
47
  metadata: {}
50
- post_install_message:
51
48
  rdoc_options: []
52
49
  require_paths:
53
50
  - lib
@@ -62,8 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
59
  - !ruby/object:Gem::Version
63
60
  version: '0'
64
61
  requirements: []
65
- rubygems_version: 3.4.10
66
- signing_key:
62
+ rubygems_version: 3.6.9
67
63
  specification_version: 4
68
64
  summary: Money field for Avo.
69
65
  test_files: []
@@ -1,16 +0,0 @@
1
- require_relative "fields/money_field"
2
-
3
- module Avo
4
- module MoneyField
5
- class Plugin < Avo::Plugin
6
- class << self
7
- def boot
8
- Avo.plugin_manager.register_field :money, Avo::MoneyField::Fields::MoneyField
9
- end
10
-
11
- def init
12
- end
13
- end
14
- end
15
- end
16
- end