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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/avo.base.css +1 -1
- data/app/components/avo/actions_component.rb +9 -2
- data/app/components/avo/fields/markdown_field/edit_component.html.erb +3 -3
- data/app/components/avo/fields/markdown_field/show_component.html.erb +3 -3
- data/app/components/avo/views/resource_show_component.html.erb +11 -11
- data/app/javascript/js/controllers/fields/{simple_mde_controller.js → easy_mde_controller.js} +3 -3
- data/app/javascript/js/controllers.js +2 -2
- data/lib/avo/base_action.rb +6 -1
- data/lib/avo/concerns/filters_session_handler.rb +0 -1
- data/lib/avo/configuration.rb +10 -2
- data/lib/avo/resources/controls/actions_list.rb +4 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/resource_generator.rb +1 -1
- data/public/avo-assets/avo.base.css +256 -130
- data/public/avo-assets/avo.base.js +291 -264
- data/public/avo-assets/avo.base.js.map +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cd2f99c299bdf5412dbf9650696b335b9157c226c3f24fb0d80b04b6d9a5eae
|
4
|
+
data.tar.gz: 3586667c9311be37ed01fc950afca11455e08a3e02fa14965797c7c25119dbb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76635e0735361495b584e9cff07913733c10016403c6d572098f9c6d793cb8403741d2eb789dd1105941cbff3232b98ab2882314ccb3c5172532fe5f3bf8e3cb
|
7
|
+
data.tar.gz: a0a1799b442787df8e39537f64ad8380a1a82d30baa4c58fe4f14eee294100ba814187ecfbbed8c2471bf04b0287ae0bbe10c2151a8573e2c1c40a282fb8a7b0
|
data/Gemfile.lock
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
@import './../../../node_modules/
|
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
|
-
@
|
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="
|
2
|
+
<div data-controller="easy-mde">
|
3
3
|
<%= @form.text_area @field.id,
|
4
|
-
class: classes("w-full js-has-
|
4
|
+
class: classes("w-full js-has-easy-mde-editor"),
|
5
5
|
data: {
|
6
6
|
view: view,
|
7
|
-
'
|
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="
|
2
|
+
<div data-controller="easy-mde">
|
3
3
|
<%= text_area_tag @field.id, @field.value,
|
4
|
-
class: helpers.input_classes('w-full js-has-
|
4
|
+
class: helpers.input_classes('w-full js-has-easy-mde-editor'),
|
5
5
|
placeholder: @field.placeholder,
|
6
6
|
disabled: disabled?,
|
7
|
-
'data-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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,
|
data/app/javascript/js/controllers/fields/{simple_mde_controller.js → easy_mde_controller.js}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Controller } from '@hotwired/stimulus'
|
2
|
-
import
|
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
|
30
|
+
const easyMde = new EasyMDE(options)
|
31
31
|
if (this.view === 'show') {
|
32
|
-
|
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
|
data/lib/avo/base_action.rb
CHANGED
@@ -82,7 +82,12 @@ module Avo
|
|
82
82
|
|
83
83
|
def get_attributes_for_action
|
84
84
|
get_fields.map do |field|
|
85
|
-
|
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
|
|
data/lib/avo/configuration.rb
CHANGED
@@ -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
|
data/lib/avo/version.rb
CHANGED
@@ -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::
|
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: {
|