avo 2.32.5 → 2.32.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc2e0d4d0438f400a3ceb9929a504b9b9f42e760155a6321c9cbca07e575f52b
4
- data.tar.gz: d023300fd0ca0d5484c05545da79f495fd1e2f47e2c8576353a4d87eec23dc9c
3
+ metadata.gz: 6cd2f99c299bdf5412dbf9650696b335b9157c226c3f24fb0d80b04b6d9a5eae
4
+ data.tar.gz: 3586667c9311be37ed01fc950afca11455e08a3e02fa14965797c7c25119dbb3
5
5
  SHA512:
6
- metadata.gz: 8335667ee5a3c608c6533d758fccc92508a20ca927c75acd890761ffe1ee2d3a1ebbb72c7ddb56e94162a0d72bd36eaf606ebfdf85217c33a971f9e26358c8c2
7
- data.tar.gz: b2dbeb103ac187a839526bf614afdda7bf6fdfd73a242e2323308b8332df738575fe5469f87a85d7cab95be29ea75e47fc7118cfd54bfbcece6cd545978b63c2
6
+ metadata.gz: 76635e0735361495b584e9cff07913733c10016403c6d572098f9c6d793cb8403741d2eb789dd1105941cbff3232b98ab2882314ccb3c5172532fe5f3bf8e3cb
7
+ data.tar.gz: a0a1799b442787df8e39537f64ad8380a1a82d30baa4c58fe4f14eee294100ba814187ecfbbed8c2471bf04b0287ae0bbe10c2151a8573e2c1c40a282fb8a7b0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.32.5)
4
+ avo (2.32.6)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -1,4 +1,4 @@
1
- @import './../../../node_modules/simplemde/dist/simplemde.min.css';
1
+ @import './../../../node_modules/easymde/dist/easymde.min.css';
2
2
  @import './../../../node_modules/tippy.js/dist/tippy.css';
3
3
  @import './../../../node_modules/tippy.js/themes/light.css';
4
4
  @import './../../../node_modules/flatpickr/dist/flatpickr.css';
@@ -4,11 +4,12 @@ class Avo::ActionsComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
5
  attr_reader :label
6
6
 
7
- def initialize(actions: [], resource: nil, view: nil, exclude: [], style: :outline, color: :primary, label: nil)
7
+ def initialize(actions: [], resource: nil, view: nil, exclude: [], include: [], style: :outline, color: :primary, label: nil)
8
8
  @actions = actions || []
9
9
  @resource = resource
10
10
  @view = view
11
11
  @exclude = exclude
12
+ @include = include
12
13
  @color = color
13
14
  @style = style
14
15
  @label = label || I18n.t("avo.actions")
@@ -19,7 +20,13 @@ class Avo::ActionsComponent < ViewComponent::Base
19
20
  end
20
21
 
21
22
  def actions
22
- @actions.reject { |action| action.class.in?(@exclude) }
23
+ if @exclude.present?
24
+ @actions.reject { |action| action.class.in?(@exclude) }
25
+ elsif @include.present?
26
+ @actions.select { |action| action.class.in?(@include) }
27
+ else
28
+ @actions
29
+ end
23
30
  end
24
31
 
25
32
  # When running an action for one record we should do it on a special path.
@@ -1,10 +1,10 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
- <div data-controller="simple-mde">
2
+ <div data-controller="easy-mde">
3
3
  <%= @form.text_area @field.id,
4
- class: classes("w-full js-has-simple-mde-editor"),
4
+ class: classes("w-full js-has-easy-mde-editor"),
5
5
  data: {
6
6
  view: view,
7
- 'simple-mde-target': 'element',
7
+ 'easy-mde-target': 'element',
8
8
  'component-options': @field.options.to_json,
9
9
  },
10
10
  disabled: disabled?,
@@ -1,10 +1,10 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
- <div data-controller="simple-mde">
2
+ <div data-controller="easy-mde">
3
3
  <%= text_area_tag @field.id, @field.value,
4
- class: helpers.input_classes('w-full js-has-simple-mde-editor'),
4
+ class: helpers.input_classes('w-full js-has-easy-mde-editor'),
5
5
  placeholder: @field.placeholder,
6
6
  disabled: disabled?,
7
- 'data-simple-mde-target': 'element',
7
+ 'data-easy-mde-target': 'element',
8
8
  'data-component-options': @field.options.to_json,
9
9
  'data-view': :show %>
10
10
  </div>
@@ -40,19 +40,19 @@
40
40
  <% end %>
41
41
  <% end %>
42
42
  <% elsif can_see_the_actions_button? && control.actions_list? %>
43
- <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, style: control.style, color: control.color, label: control.label %>
43
+ <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, include: control.include, style: control.style, color: control.color, label: control.label %>
44
44
  <% elsif control.edit_button? %>
45
45
  <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
46
- <% end %>
47
- <%= a_link edit_path,
48
- color: :primary,
49
- style: :primary,
50
- title: control.title,
51
- data: {
52
- tippy: control.title ? :tooltip : nil,
53
- },
54
- icon: 'edit' do %>
55
- <%= control.label %>
46
+ <%= a_link edit_path,
47
+ color: :primary,
48
+ style: :primary,
49
+ title: control.title,
50
+ data: {
51
+ tippy: control.title ? :tooltip : nil,
52
+ },
53
+ icon: 'edit' do %>
54
+ <%= control.label %>
55
+ <% end %>
56
56
  <% end %>
57
57
  <% elsif control.action? %>
58
58
  <%= a_link control.path,
@@ -1,5 +1,5 @@
1
1
  import { Controller } from '@hotwired/stimulus'
2
- import SimpleMDE from 'simplemde'
2
+ import EasyMDE from 'easymde'
3
3
 
4
4
  export default class extends Controller {
5
5
  static targets = ['element']
@@ -27,9 +27,9 @@ export default class extends Controller {
27
27
  options.status = false
28
28
  }
29
29
 
30
- const simpleMde = new SimpleMDE(options)
30
+ const easyMde = new EasyMDE(options)
31
31
  if (this.view === 'show') {
32
- simpleMde.codemirror.options.readOnly = true
32
+ easyMde.codemirror.options.readOnly = true
33
33
  }
34
34
  }
35
35
  }
@@ -9,6 +9,7 @@ import CodeFieldController from './controllers/fields/code_field_controller'
9
9
  import CopyToClipboardController from './controllers/copy_to_clipboard_controller'
10
10
  import DashboardCardController from './controllers/dashboard_card_controller'
11
11
  import DateFieldController from './controllers/fields/date_field_controller'
12
+ import EasyMdeController from './controllers/fields/easy_mde_controller'
12
13
  import FilterController from './controllers/filter_controller'
13
14
  import HiddenInputController from './controllers/hidden_input_controller'
14
15
  import ItemSelectAllController from './controllers/item_select_all_controller'
@@ -27,7 +28,6 @@ import SearchController from './controllers/search_controller'
27
28
  import SelectController from './controllers/select_controller'
28
29
  import SelectFilterController from './controllers/select_filter_controller'
29
30
  import SidebarController from './controllers/sidebar_controller'
30
- import SimpleMdeController from './controllers/fields/simple_mde_controller'
31
31
  import TabsController from './controllers/tabs_controller'
32
32
  import TagsFieldController from './controllers/fields/tags_field_controller'
33
33
  import TextFilterController from './controllers/text_filter_controller'
@@ -67,9 +67,9 @@ application.register('toggle-panel', TogglePanelController)
67
67
  application.register('belongs-to-field', BelongsToFieldController)
68
68
  application.register('code-field', CodeFieldController)
69
69
  application.register('date-field', DateFieldController)
70
+ application.register('easy-mde', EasyMdeController)
70
71
  application.register('key-value', KeyValueController)
71
72
  application.register('progress-bar-field', ProgressBarFieldController)
72
- application.register('simple-mde', SimpleMdeController)
73
73
  application.register('trix-field', TrixFieldController)
74
74
 
75
75
  // Custom controllers
@@ -82,7 +82,12 @@ module Avo
82
82
 
83
83
  def get_attributes_for_action
84
84
  get_fields.map do |field|
85
- [field.id, field.value || field.default]
85
+ default_value = if field.default.respond_to? :call
86
+ Avo::Hosts::ResourceViewRecordHost.new(block: field.default, record: self.class.model, view: view, resource: self.class.resource).handle
87
+ else
88
+ field.default
89
+ end
90
+ [field.id, field.value || default_value]
86
91
  end.to_h
87
92
  end
88
93
 
@@ -1,4 +1,3 @@
1
-
2
1
  module Avo
3
2
  module Concerns
4
3
  module FiltersSessionHandler
@@ -2,8 +2,9 @@ module Avo
2
2
  class Configuration
3
3
  include ResourceConfiguration
4
4
 
5
+ attr_writer :app_name
6
+ attr_writer :branding
5
7
  attr_writer :root_path
6
- attr_accessor :app_name
7
8
  attr_accessor :timezone
8
9
  attr_accessor :per_page
9
10
  attr_accessor :per_page_steps
@@ -43,7 +44,6 @@ module Avo
43
44
  attr_accessor :sign_out_path_name
44
45
  attr_accessor :resources
45
46
  attr_accessor :prefix_path
46
- attr_writer :branding
47
47
 
48
48
  def initialize
49
49
  @root_path = "/avo"
@@ -139,6 +139,14 @@ module Avo
139
139
  def branding
140
140
  Avo::Configuration::Branding.new(**@branding || {})
141
141
  end
142
+
143
+ def app_name
144
+ if @app_name.respond_to? :call
145
+ Avo::Hosts::BaseHost.new(block: @app_name).handle
146
+ else
147
+ @app_name
148
+ end
149
+ end
142
150
  end
143
151
 
144
152
  def self.configuration
@@ -6,6 +6,10 @@ module Avo
6
6
  Array.wrap(@args[:exclude]) || []
7
7
  end
8
8
 
9
+ def include
10
+ Array.wrap(@args[:include]) || []
11
+ end
12
+
9
13
  def color
10
14
  @args[:color] || :primary
11
15
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.32.5" unless const_defined?(:VERSION)
2
+ VERSION = "2.32.6" unless const_defined?(:VERSION)
3
3
  end
@@ -181,7 +181,7 @@ module Generators
181
181
  end
182
182
 
183
183
  def field_from_through_association(association)
184
- if association.through_reflection.is_a? ActiveRecord::Reflection::HasManyReflection
184
+ if association.through_reflection.is_a?(ActiveRecord::Reflection::HasManyReflection) || association.through_reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
185
185
  {
186
186
  field: "has_many",
187
187
  options: {