avo 2.5.2.pre.6 → 2.6.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +8 -1
- data/app/assets/builds/action_cable.js +2 -0
- data/app/assets/builds/action_cable.js.map +7 -0
- data/app/assets/builds/avo.css +725 -203
- data/app/assets/builds/avo.js +211 -122
- data/app/assets/builds/avo.js.map +3 -3
- data/app/assets/stylesheets/avo.css +2 -0
- data/app/assets/stylesheets/css/tags.css +16 -0
- data/app/components/avo/actions_component.html.erb +1 -1
- data/app/components/avo/button_component.rb +8 -14
- data/app/components/avo/card_component.rb +12 -0
- data/app/components/avo/fields/belongs_to_field/autocomplete_component.html.erb +2 -0
- data/app/components/avo/fields/concerns/item_labels.rb +40 -0
- data/app/components/avo/fields/tags_field/edit_component.html.erb +27 -0
- data/app/components/avo/fields/tags_field/edit_component.rb +4 -0
- data/app/components/avo/fields/tags_field/index_component.html.erb +10 -0
- data/app/components/avo/fields/tags_field/index_component.rb +9 -0
- data/app/components/avo/fields/tags_field/show_component.html.erb +7 -0
- data/app/components/avo/fields/tags_field/show_component.rb +7 -0
- data/app/components/avo/fields/tags_field/tag_component.html.erb +9 -0
- data/app/components/avo/fields/tags_field/tag_component.rb +11 -0
- data/app/components/avo/index/resource_table_component.html.erb +1 -1
- data/app/components/avo/paginator_component.html.erb +2 -2
- data/app/components/avo/sidebar_component.html.erb +1 -1
- data/app/components/avo/sidebar_profile_component.html.erb +1 -1
- data/app/controllers/avo/base_controller.rb +0 -19
- data/app/controllers/avo/search_controller.rb +11 -4
- data/app/javascript/js/application.js +1 -1
- data/app/javascript/js/controllers/base_controller.js +22 -0
- data/app/javascript/js/controllers/fields/tags_field_controller.js +86 -0
- data/app/javascript/js/controllers/fields/tags_field_helpers.js +47 -0
- data/app/javascript/js/controllers/search_controller.js +7 -1
- data/app/javascript/js/controllers.js +2 -0
- data/app/views/avo/dashboards/_chartkick_card.html.erb +1 -1
- data/app/views/avo/dashboards/_metric_card.html.erb +1 -1
- data/app/views/avo/partials/_global_search.html.erb +1 -1
- data/app/views/avo/partials/_navbar.html.erb +3 -3
- data/app/views/avo/partials/_resource_search.html.erb +1 -1
- data/db/factories.rb +2 -0
- data/lib/avo/base_resource.rb +6 -0
- data/lib/avo/concerns/handles_field_args.rb +36 -0
- data/lib/avo/fields/base_field.rb +2 -1
- data/lib/avo/fields/tags_field.rb +82 -0
- data/lib/avo/hosts/association_scope_host.rb +1 -0
- data/lib/avo/hosts/base_host.rb +2 -0
- data/lib/avo/hosts/record_host.rb +7 -0
- data/lib/avo/licensing/pro_license.rb +2 -1
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/cards/chartkick_card.tt +1 -1
- data/lib/generators/avo/templates/cards/chartkick_card_sample.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card.tt +1 -1
- data/lib/generators/avo/templates/cards/metric_card_sample.tt +1 -1
- data/lib/generators/avo/templates/locales/avo.en.yml +4 -0
- data/lib/tasks/avo_tasks.rake +7 -3
- data/public/avo-assets/avo.css +694 -78
- data/public/avo-assets/avo.js +211 -122
- data/public/avo-assets/avo.js.map +3 -3
- metadata +20 -2
@@ -0,0 +1,36 @@
|
|
1
|
+
module Avo
|
2
|
+
module Concerns
|
3
|
+
module HandlesFieldArgs
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
# Add an instance variable from args
|
9
|
+
# That may be a string, boolean, or array
|
10
|
+
# Each args should also have a default value
|
11
|
+
def add_prop_from_args(args = {}, name: nil, type: :string, default: nil)
|
12
|
+
value = default
|
13
|
+
|
14
|
+
if type == :boolean
|
15
|
+
value = args[name.to_sym] == true
|
16
|
+
else
|
17
|
+
value = args[name.to_sym] unless args.dig(name.to_sym).nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
instance_variable_set(:"@#{name}", value)
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_boolean_prop(args, name, default = false)
|
24
|
+
add_prop_from_args args, name: name, default: default, type: :boolean
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_array_prop(args, name, default = [])
|
28
|
+
add_prop_from_args args, name: name, default: default, type: :array
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_string_prop(args, name, default = [])
|
32
|
+
add_prop_from_args args, name: name, default: default, type: :string
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -4,8 +4,9 @@ module Avo
|
|
4
4
|
extend ActiveSupport::DescendantsTracker
|
5
5
|
extend Avo::Fields::FieldExtensions::HasFieldName
|
6
6
|
|
7
|
-
include ActionView::Helpers::UrlHelper
|
8
7
|
include Avo::Fields::FieldExtensions::VisibleInDifferentViews
|
8
|
+
include Avo::Concerns::HandlesFieldArgs
|
9
|
+
include ActionView::Helpers::UrlHelper
|
9
10
|
|
10
11
|
delegate :view_context, to: "Avo::App"
|
11
12
|
delegate :main_app, to: :view_context
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Avo
|
2
|
+
module Fields
|
3
|
+
class TagsField < BaseField
|
4
|
+
attr_reader :acts_as_taggable_on
|
5
|
+
attr_reader :close_on_select
|
6
|
+
attr_reader :delimiters
|
7
|
+
attr_reader :enforce_suggestions
|
8
|
+
|
9
|
+
def initialize(id, **args, &block)
|
10
|
+
super(id, **args, &block)
|
11
|
+
|
12
|
+
add_boolean_prop args, :close_on_select
|
13
|
+
add_boolean_prop args, :enforce_suggestions
|
14
|
+
add_string_prop args, :acts_as_taggable_on
|
15
|
+
add_array_prop args, :disallowed
|
16
|
+
add_array_prop args, :delimiters, [","]
|
17
|
+
add_array_prop args, :suggestions
|
18
|
+
end
|
19
|
+
|
20
|
+
def field_value
|
21
|
+
return json_value if acts_as_taggable_on.present?
|
22
|
+
|
23
|
+
value || []
|
24
|
+
end
|
25
|
+
|
26
|
+
def json_value
|
27
|
+
value.map do |item|
|
28
|
+
{
|
29
|
+
value: item.name
|
30
|
+
}
|
31
|
+
end.as_json
|
32
|
+
end
|
33
|
+
|
34
|
+
def fill_field(model, key, value, params)
|
35
|
+
if acts_as_taggable_on.present?
|
36
|
+
model.send(act_as_taggable_attribute(key), parsed_value(value))
|
37
|
+
else
|
38
|
+
model.send("#{key}=", parsed_value(value))
|
39
|
+
end
|
40
|
+
|
41
|
+
model
|
42
|
+
end
|
43
|
+
|
44
|
+
def suggestions
|
45
|
+
return @suggestions if @suggestions.is_a? Array
|
46
|
+
|
47
|
+
if @suggestions.respond_to? :call
|
48
|
+
return Avo::Hosts::RecordHost.new(block: @suggestions, record: model).handle
|
49
|
+
end
|
50
|
+
|
51
|
+
[]
|
52
|
+
end
|
53
|
+
|
54
|
+
def disallowed
|
55
|
+
return @disallowed if @disallowed.is_a? Array
|
56
|
+
|
57
|
+
if @disallowed.respond_to? :call
|
58
|
+
return Avo::Hosts::RecordHost.new(block: @disallowed, record: model).handle
|
59
|
+
end
|
60
|
+
|
61
|
+
[]
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def act_as_taggable_attribute(key)
|
67
|
+
"#{key.singularize}_list="
|
68
|
+
end
|
69
|
+
|
70
|
+
def parsed_value(value)
|
71
|
+
JSON.parse(value).pluck("value")
|
72
|
+
rescue
|
73
|
+
[]
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def parse_suggestions_from_args(args)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/avo/hosts/base_host.rb
CHANGED
data/lib/avo/version.rb
CHANGED
@@ -9,7 +9,7 @@ class <%= class_name.camelize %> < Avo::Dashboards::ChartkickCard
|
|
9
9
|
# self.chart_options = { library: { plugins: { legend: { display: true } } } }
|
10
10
|
# self.flush = true
|
11
11
|
|
12
|
-
query
|
12
|
+
def query
|
13
13
|
points = 16
|
14
14
|
i = Time.new.year.to_i - points
|
15
15
|
base_data = Array.new(points).map do
|
data/lib/tasks/avo_tasks.rake
CHANGED
@@ -5,11 +5,14 @@
|
|
5
5
|
|
6
6
|
desc 'Installs Avo assets and bundles them for when you want to use the GitHub repo in your app'
|
7
7
|
task 'avo:build-assets' do
|
8
|
+
spec = get_gem_spec 'avo'
|
9
|
+
# Uncomment to enable only when the source is github.com
|
10
|
+
# enabled = spec.source.to_s.include?('https://github.com/avo-hq/avo')
|
8
11
|
enabled = true
|
9
12
|
|
10
13
|
if enabled
|
11
14
|
puts "Starting avo:build-assets"
|
12
|
-
path =
|
15
|
+
path = spec.full_gem_path
|
13
16
|
|
14
17
|
Dir.chdir(path) do
|
15
18
|
system 'yarn'
|
@@ -24,11 +27,12 @@ end
|
|
24
27
|
|
25
28
|
# From
|
26
29
|
# https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
|
27
|
-
def
|
30
|
+
def get_gem_spec(name)
|
28
31
|
spec = Bundler.load.specs.find{|s| s.name == name }
|
29
32
|
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
|
30
33
|
if spec.name == 'bundler'
|
31
34
|
return File.expand_path('../../../', __FILE__)
|
32
35
|
end
|
33
|
-
|
36
|
+
|
37
|
+
spec
|
34
38
|
end
|