avo 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb42ab88f48186d0bb1c3f058e0ef460bbe8adfa928b6de1dc7b44709a0cc3b2
4
- data.tar.gz: b7538d63d82cccf98f9f225487df2030d6a423c2e2297d49443f869f2b0fed41
3
+ metadata.gz: bd49dafaf80ec79f2e45eab2d26786c9cfa9d65c2f3608ab61540f7d40038b35
4
+ data.tar.gz: 5750e2b37680c30a6732ec99af57e08ae504ac8ddffa2a75d78c00bf14dd39ae
5
5
  SHA512:
6
- metadata.gz: c6d2389378b306156b20cea6983509f1eca9f6923b026b4d66f8736524b129b59570286d463bcdb64105911e195920bed8b8576066623f91153062c27170d12f
7
- data.tar.gz: 5fd227e9d5eefc30bbaf66ffccde8d00acebe300854d4ad971f34b49fb95cccb6b4ea42e8fd0de59cc61e193f270892428939a8978268414a15c2a50f5a4ab3b
6
+ metadata.gz: 2ad055e02c197a6c50af642c782a585c5e8584d8d90f7171f83a94acb9b4f5c19edb109d8037c2bfd338224b9e21a8bf92f41f7a7295c0caddd1a554f79741c3
7
+ data.tar.gz: d82297c31658bc94638a4f9504eaac9dedd59843db4580c6b09231748dd1ba61697b2c008dce6c2b6ad759b46542d8a0ffd55cdd2a5b3e50ab28be55f8769c84
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.4.2)
4
+ avo (3.4.3)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -534,7 +534,7 @@ GEM
534
534
  websocket-extensions (0.1.5)
535
535
  xpath (3.2.0)
536
536
  nokogiri (~> 1.8)
537
- yard (0.9.34)
537
+ yard (0.9.35)
538
538
  zeitwerk (2.6.13)
539
539
 
540
540
  PLATFORMS
@@ -32,16 +32,16 @@
32
32
  >
33
33
  <div data-target="actions-list" class="w-full space divide-y">
34
34
  <% actions.each_with_index do |action, index| %>
35
- <% link, data = action.class.link_arguments(resource: @resource, arguments: action.arguments) %>
36
- <%= link_to link,
35
+ <%= link_to action_path(action),
37
36
  data: {
38
37
  action_name: action.action_name,
38
+ 'turbo-frame': Avo::ACTIONS_TURBO_FRAME_ID,
39
39
  'action': 'click->actions-picker#visitAction',
40
40
  'actions-picker-target': action.standalone ? 'standaloneAction' : 'resourceAction',
41
41
  'disabled': is_disabled?(action),
42
42
  # for some reason InstantClick fetches the URL even if it's prefetched.
43
43
  turbo_prefetch: false,
44
- }.merge(data),
44
+ },
45
45
  title: action.action_name,
46
46
  class: "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 #{is_disabled?(action) ? 'text-gray-500' : 'text-black'}" do %>
47
47
  <%= svg 'play', class: 'h-5 mr-1 inline pointer-events-none' %> <%= action.action_name %>
@@ -31,6 +31,19 @@ class Avo::ActionsComponent < ViewComponent::Base
31
31
  end
32
32
  end
33
33
 
34
+ # When running an action for one record we should do it on a special path.
35
+ # We do that so we get the `record` param inside the action so we can prefill fields.
36
+ def action_path(action)
37
+ return single_record_path(action) if as_row_control
38
+ return many_records_path(action) unless @resource.has_record_id?
39
+
40
+ if on_record_page?
41
+ single_record_path action
42
+ else
43
+ many_records_path action
44
+ end
45
+ end
46
+
34
47
  # How should the action be displayed by default
35
48
  def is_disabled?(action)
36
49
  return false if action.standalone || as_row_control
@@ -47,4 +60,23 @@ class Avo::ActionsComponent < ViewComponent::Base
47
60
  def on_index_page?
48
61
  !on_record_page?
49
62
  end
63
+
64
+ def single_record_path(action)
65
+ action_url(action, @resource.record_path)
66
+ end
67
+
68
+ def many_records_path(action)
69
+ action_url(action, @resource.records_path)
70
+ end
71
+
72
+ def action_url(action, path)
73
+ Avo::Services::URIService.parse(path)
74
+ .append_paths("actions")
75
+ .append_query(
76
+ {
77
+ action_id: action.to_param,
78
+ arguments: Avo::BaseAction.encode_arguments(action.arguments)
79
+ }.compact
80
+ ).to_s
81
+ end
50
82
  end
@@ -71,8 +71,11 @@
71
71
  <% create_href = create_path(Avo.resource_manager.get_resource_by_model_class(type.to_s)) %>
72
72
  <% if !disabled && create_href.present? %>
73
73
  <%= link_to t("avo.create_new_item", item: type.to_s.downcase),
74
- create_href,
75
- class: "text-sm"
74
+ create_href,
75
+ class: "text-sm",
76
+ data: {
77
+ turbo_prefetch: false
78
+ }
76
79
  %>
77
80
  <% end %>
78
81
  <% end %>
@@ -115,7 +118,13 @@
115
118
  <% end %>
116
119
  <% if field.can_create? %>
117
120
  <% if !disabled && create_path.present? %>
118
- <%= link_to t("avo.create_new_item", item: @field.name.downcase), create_path, class: "text-sm" %>
121
+ <%= link_to t("avo.create_new_item", item: @field.name.downcase),
122
+ create_path,
123
+ class: "text-sm",
124
+ data: {
125
+ turbo_prefetch: false
126
+ }
127
+ %>
119
128
  <% end %>
120
129
  <% end %>
121
130
  <% end %>
@@ -63,10 +63,16 @@ module Avo
63
63
 
64
64
  # Create resources for each record
65
65
  # Duplicate the @resource before hydration to avoid @resource keeping last record.
66
+ @resource.hydrate(params: params)
66
67
  @resources = @records.map do |record|
67
- @resource.dup.hydrate(record: record, params: params)
68
+ @resource.dup.hydrate(record: record)
68
69
  end
69
70
 
71
+ # Temporary fix for visible blocks when geting fields for header
72
+ # Hydrating with last record so resource.record != nil
73
+ # This is keeping same behavior from <= 3.4.1
74
+ @resource.hydrate(record: @records.last)
75
+
70
76
  set_component_for __method__
71
77
  end
72
78
 
@@ -13,7 +13,7 @@ module Avo
13
13
  def close_action_modal
14
14
  turbo_stream_action_tag :replace,
15
15
  target: Avo::ACTIONS_TURBO_FRAME_ID,
16
- html: @view_context.turbo_frame_tag(Avo::ACTIONS_TURBO_FRAME_ID)
16
+ template: @view_context.turbo_frame_tag(Avo::ACTIONS_TURBO_FRAME_ID, data: {turbo_temporary: 1})
17
17
  end
18
18
  end
19
19
  end
@@ -12,7 +12,6 @@
12
12
  data: {
13
13
  action_target: :form,
14
14
  **@action.class.form_data_attributes,
15
- turbo_frame: Avo::ACTIONS_TURBO_FRAME_ID,
16
15
  } do |form|
17
16
  %>
18
17
  <%= render Avo::ModalComponent.new do |c| %>
@@ -1,11 +1 @@
1
- <div class="flex">
2
- <%= link_to Avo.configuration.app_name, '/', class: 'text-primary-500 font-semibold', target: :_blank %>
3
-
4
- <% if false %>
5
- <div class="ml-12">
6
- <% current_user.accounts.each do |account| %>
7
- <%= link_to account.name, switch_account_path(account.id), class: class_names({"underline": session[:tenant_id].to_s == account.id.to_s}), data: {turbo_method: :put} %>
8
- <% end %>
9
- </div>
10
- <% end %>
11
- </div>
1
+ <%= link_to Avo.configuration.app_name, '/', class: 'text-primary-500 font-semibold', target: :_blank %>
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <head>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <% if !Avo.configuration.turbo[:instantclick] %>
6
+ <% if !Avo.configuration.turbo[:instant_click] %>
7
7
  <meta name="turbo-prefetch" content="false">
8
8
  <% end %>
9
9
  <%= display_meta_tags site: Avo.configuration.app_name, reverse: true, separator: "—" %>
@@ -228,7 +228,7 @@ module Avo
228
228
  def default_turbo
229
229
  -> do
230
230
  {
231
- instantclick: true
231
+ instant_click: true
232
232
  }
233
233
  end
234
234
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.4.2" unless const_defined?(:VERSION)
2
+ VERSION = "3.4.3" unless const_defined?(:VERSION)
3
3
  end
data/lib/avo.rb CHANGED
@@ -40,7 +40,7 @@ module Avo
40
40
  private
41
41
 
42
42
  def missing_resource_message(resource_name)
43
- name = resource_name.to_s.downcase
43
+ name = resource_name.to_s.underscore
44
44
 
45
45
  "Failed to find a resource while rendering the :#{name} field.\n" \
46
46
  "You may generate a resource for it by running 'rails generate avo:resource #{name.singularize}'.\n" \
@@ -68,7 +68,7 @@ Avo.configure do |config|
68
68
  ## == Turbo options ==
69
69
  # config.turbo = -> do
70
70
  # {
71
- # instantclick: true
71
+ # instant_click: true
72
72
  # }
73
73
  # end
74
74
 
@@ -7102,10 +7102,6 @@ tag.tagify__tag{
7102
7102
  margin-left:2.5rem
7103
7103
  }
7104
7104
 
7105
- .ml-12{
7106
- margin-left:3rem
7107
- }
7108
-
7109
7105
  .ml-2{
7110
7106
  margin-left:0.5rem
7111
7107
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-02-28 00:00:00.000000000 Z
13
+ date: 2024-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord