avo-money_field 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/avo-money_field.gemspec +18 -0
- data/lib/avo/money_field/fields/money_field/edit_component.html.erb +22 -0
- data/lib/avo/money_field/fields/money_field/edit_component.rb +4 -0
- data/lib/avo/money_field/fields/money_field/index_component.html.erb +3 -0
- data/lib/avo/money_field/fields/money_field/index_component.rb +4 -0
- data/lib/avo/money_field/fields/money_field/show_component.html.erb +3 -0
- data/lib/avo/money_field/fields/money_field/show_component.rb +4 -0
- data/lib/avo/money_field/fields/money_field.rb +37 -0
- data/lib/avo/money_field/plugin.rb +17 -0
- data/lib/avo/money_field/railtie.rb +9 -0
- data/lib/avo/money_field/version.rb +5 -0
- data/lib/avo/money_field.rb +15 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf6df3e68f4d47bcfe34a7ab5edb31c0f96cbf3648229d76e7ea96a0d6e51a58
|
4
|
+
data.tar.gz: fa4b46449d39734e5c5244fb9ba73b8e5ae64b777065d775758206bc20413573
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b0bf1ee72b7496aee9be4eb5afcf6e3486911b38a836d4f29ab4397178dd8a133a9cd58857c0fd03b266a538c534595fac178d87d36425775d019930fc47b14
|
7
|
+
data.tar.gz: 3e7a47c3e9294d6d84a943ccedaef051c5dd2b5089ecccd84a2cf11bd92dffb7344086fd9614004bc08367d0880c7fa8ad9c6d6c7f1b5829234420a789de6b39
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push File.expand_path("lib", __dir__)
|
2
|
+
|
3
|
+
require "avo/money_field/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "avo-money_field"
|
7
|
+
spec.version = Avo::MoneyField::VERSION
|
8
|
+
spec.summary = "Money field for Avo."
|
9
|
+
spec.description = "Money field for Avo."
|
10
|
+
spec.authors = ["Adrian Marin"]
|
11
|
+
spec.email = "adrian@adrianthedev.com"
|
12
|
+
spec.files = ["lib/avo_money_field.rb"]
|
13
|
+
|
14
|
+
spec.files = Dir["{lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "avo-money_field.gemspec", "Gemfile", "Gemfile.lock"]
|
15
|
+
|
16
|
+
spec.homepage = "https://avohq.io"
|
17
|
+
spec.license = "MIT"
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= field_wrapper **field_wrapper_args, class: "flex field-wrapper-test" do %>
|
2
|
+
<div class="w-full flex flex-1 space-x-2 grow-0">
|
3
|
+
<%= form.text_field @field.id,
|
4
|
+
value: @field.value,
|
5
|
+
class: classes("w-full"),
|
6
|
+
data: @field.get_html(:data, view: view, element: :input),
|
7
|
+
disabled: disabled?,
|
8
|
+
placeholder: @field.placeholder,
|
9
|
+
style: @field.get_html(:style, view: view, element: :input),
|
10
|
+
multiple: multiple,
|
11
|
+
autocomplete: @field.autocomplete
|
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
|
+
%>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Avo
|
2
|
+
module MoneyField
|
3
|
+
module Fields
|
4
|
+
class MoneyField < Avo::Fields::BaseField
|
5
|
+
attr_reader :currencies
|
6
|
+
attr_reader :currency_suffix
|
7
|
+
|
8
|
+
def initialize(id, **args, &block)
|
9
|
+
super(id, **args, &block)
|
10
|
+
|
11
|
+
add_array_prop args, :currencies
|
12
|
+
currency_suffix = defined?(MoneyRails) ? ::MoneyRails::Configuration.currency_column[:postfix] : :_currency
|
13
|
+
add_string_prop args, :currency_suffix, currency_suffix
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_permitted_param
|
17
|
+
[id.to_sym, currency_column.to_sym]
|
18
|
+
end
|
19
|
+
|
20
|
+
def fill_field(record, key, value, params)
|
21
|
+
record.public_send(:"#{key}=", value)
|
22
|
+
record.public_send(:"#{key}#{@currency_suffix}=", params[:"#{key}#{@currency_suffix}"])
|
23
|
+
|
24
|
+
record
|
25
|
+
end
|
26
|
+
|
27
|
+
def currency
|
28
|
+
value.send(:currency)
|
29
|
+
end
|
30
|
+
|
31
|
+
def currency_column
|
32
|
+
"#{id}#{currency_suffix}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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
|
+
# Avo.plugin_manager.register_field :money, Avo::MoneyField::Fields::MoneyField
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "zeitwerk"
|
2
|
+
require "avo"
|
3
|
+
require "avo/money_field/version"
|
4
|
+
require "avo/money_field/railtie"
|
5
|
+
|
6
|
+
loader = Zeitwerk::Loader.for_gem_extension(Avo)
|
7
|
+
loader.setup
|
8
|
+
|
9
|
+
module Avo
|
10
|
+
module MoneyField
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# loader.eager_load
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: avo-money_field
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Marin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Money field for Avo.
|
14
|
+
email: adrian@adrianthedev.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- avo-money_field.gemspec
|
21
|
+
- lib/avo/money_field.rb
|
22
|
+
- lib/avo/money_field/fields/money_field.rb
|
23
|
+
- lib/avo/money_field/fields/money_field/edit_component.html.erb
|
24
|
+
- lib/avo/money_field/fields/money_field/edit_component.rb
|
25
|
+
- lib/avo/money_field/fields/money_field/index_component.html.erb
|
26
|
+
- lib/avo/money_field/fields/money_field/index_component.rb
|
27
|
+
- lib/avo/money_field/fields/money_field/show_component.html.erb
|
28
|
+
- lib/avo/money_field/fields/money_field/show_component.rb
|
29
|
+
- lib/avo/money_field/plugin.rb
|
30
|
+
- lib/avo/money_field/railtie.rb
|
31
|
+
- lib/avo/money_field/version.rb
|
32
|
+
homepage: https://avohq.io
|
33
|
+
licenses:
|
34
|
+
- MIT
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.4.10
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Money field for Avo.
|
55
|
+
test_files: []
|