avo 2.11.1.pre.3 → 2.11.2.pre.2

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.

Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/stylesheets/css/sidebar.css +0 -10
  4. data/app/assets/svgs/failed_to_load.svg +15 -0
  5. data/app/components/avo/common_field_wrapper_component.html.erb +4 -0
  6. data/app/components/avo/fields/date_field/show_component.html.erb +0 -4
  7. data/app/components/avo/fields/trix_field/edit_component.rb +1 -1
  8. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  9. data/app/components/avo/index/resource_controls_component.html.erb +3 -0
  10. data/app/components/avo/index/table_row_component.html.erb +14 -5
  11. data/app/components/avo/item_switcher_component.html.erb +1 -1
  12. data/app/components/avo/sidebar_component.html.erb +8 -2
  13. data/app/components/avo/sidebar_component.rb +9 -0
  14. data/app/controllers/avo/application_controller.rb +2 -2
  15. data/app/controllers/avo/base_controller.rb +6 -2
  16. data/app/javascript/js/controllers/fields/key_value_controller.js +3 -1
  17. data/app/javascript/js/controllers/sidebar_controller.js +5 -2
  18. data/app/views/avo/home/failed_to_load.html copy.erb +23 -0
  19. data/app/views/avo/home/failed_to_load.html.erb +9 -15
  20. data/app/views/avo/partials/_table_header.html.erb +12 -5
  21. data/app/views/layouts/avo/application.html.erb +6 -1
  22. data/bin/init +5 -0
  23. data/lib/avo/base_resource.rb +16 -1
  24. data/lib/avo/concerns/has_fields.rb +7 -3
  25. data/lib/avo/concerns/model_class_constantized.rb +1 -1
  26. data/lib/avo/configuration/resource_configuration.rb +21 -0
  27. data/lib/avo/configuration.rb +2 -0
  28. data/lib/avo/items_holder.rb +6 -0
  29. data/lib/avo/panel_builder.rb +1 -0
  30. data/lib/avo/version.rb +1 -1
  31. data/public/avo-assets/avo.css +51 -21
  32. data/public/avo-assets/avo.js +54 -54
  33. data/public/avo-assets/avo.js.map +3 -3
  34. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 794b7326ae2257afd693641ff51ba513d09d4729a77a671a96f1291f0b31b8e3
4
- data.tar.gz: a3b8b5d2f19e9ac16164ae6cb634a0f53d92da7af1b4bc3c829704327f112c91
3
+ metadata.gz: ab1a9ef1d382202009c6238b84e53b78cde379babde8bbfbdf95c94d64f422ae
4
+ data.tar.gz: d73bd4cf8b9125695e835f41971eff6ea37a4e0df79fb802e8eeb87b62eeb4c9
5
5
  SHA512:
6
- metadata.gz: 15b95f8cef9a7ec9af6a272dd2abddbb7d8471f5edefb568b16e84f3b26165f7ac4f913974d70291463c8fcbc4427d7608a41a01c0167864d0368178ebf1e755
7
- data.tar.gz: 7a7b600d0cc554e8aa30377199dad939e82c8165310b9f81cfe911c06a4d3cac3c72617fdad432475cd61bfcb60a1d00ee5ba4101a2d204940f48f6c6f03ba72
6
+ metadata.gz: 0b6d7c8732f5e27e6963ef7e660c55a92c32740449a09924a4f0b300bf98ccb64637eb662d9f111e24d6c1a46fe0ebaa4ffc91b2e667de2189de2ba9dfbfe0c9
7
+ data.tar.gz: 57c439b934e2ef860157cec05d4da4e2652d45b1da258cc4410911ef81c9e99f011acc9ef0c8fd06f5c0452a765ccb89b6c5d91af46ef3a94ca9a85fbf9cd8c0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.11.1.pre.3)
4
+ avo (2.11.2.pre.2)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -9,20 +9,10 @@
9
9
  @apply lg:pl-0;
10
10
  }
11
11
 
12
- /* Hide the sidebar by default. */
13
- .avo-sidebar {
14
- @apply lg:hidden;
15
- }
16
-
17
12
  &.sidebar-open {
18
13
  /* Add padding to the main area to allow for the sidebar to expand. */
19
14
  .main-content-area {
20
15
  @apply lg:pl-64;
21
16
  }
22
-
23
- /* Show the sidebar. */
24
- .avo-sidebar {
25
- @apply lg:block;
26
- }
27
17
  }
28
18
  }
@@ -0,0 +1,15 @@
1
+ <svg width="275" height="275" viewBox="0 0 275 275" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M137.714 274.227C213.377 274.227 274.714 212.89 274.714 137.227C274.714 61.5636 213.377 0.226593 137.714 0.226593C62.0512 0.226593 0.714233 61.5636 0.714233 137.227C0.714233 212.89 62.0512 274.227 137.714 274.227Z" fill="url(#paint0_linear_663_759)"/>
3
+ <rect x="55.5142" y="67.8133" width="164.4" height="32.88" fill="white"/>
4
+ <path d="M219.914 274.227H55.5142V97.0399C63.2629 97.0312 70.6918 93.9492 76.171 88.4701C81.6502 82.9909 84.7322 75.562 84.7409 67.8133H190.688C190.679 71.6518 191.432 75.4538 192.903 78.9994C194.374 82.5449 196.533 85.7636 199.256 88.4692C201.962 91.1929 205.181 93.353 208.727 94.8242C212.273 96.2953 216.075 97.0484 219.914 97.0399V274.227Z" fill="white"/>
5
+ <path d="M137.714 186.547C161.926 186.547 181.554 166.919 181.554 142.707C181.554 118.494 161.926 98.8666 137.714 98.8666C113.502 98.8666 93.8743 118.494 93.8743 142.707C93.8743 166.919 113.502 186.547 137.714 186.547Z" fill="#4285F4"/>
6
+ <path d="M153.214 163.373L137.714 147.874L122.214 163.373L117.048 158.207L132.548 142.707L117.048 127.207L122.214 122.041L137.714 137.54L153.214 122.041L158.381 127.207L142.881 142.707L158.381 158.207L153.214 163.373Z" fill="white"/>
7
+ <path d="M161.461 197.507H113.968C110.941 197.507 108.488 199.96 108.488 202.987C108.488 206.013 110.941 208.467 113.968 208.467H161.461C164.487 208.467 166.941 206.013 166.941 202.987C166.941 199.96 164.487 197.507 161.461 197.507Z" fill="#DFEAFB"/>
8
+ <path d="M177.901 219.427H97.5275C94.501 219.427 92.0475 221.88 92.0475 224.907C92.0475 227.933 94.501 230.387 97.5275 230.387H177.901C180.927 230.387 183.381 227.933 183.381 224.907C183.381 221.88 180.927 219.427 177.901 219.427Z" fill="#DFEAFB"/>
9
+ <defs>
10
+ <linearGradient id="paint0_linear_663_759" x1="137.714" y1="0.226593" x2="137.714" y2="274.227" gradientUnits="userSpaceOnUse">
11
+ <stop stop-color="#E3ECFA"/>
12
+ <stop offset="1" stop-color="#DAE7FF"/>
13
+ </linearGradient>
14
+ </defs>
15
+ </svg>
@@ -19,4 +19,8 @@
19
19
  <div class="flex-1 flex flex-row md:min-h-inherit py-2 <% unless @displayed_in_modal %> px-6 <% end %>">
20
20
  <%= content %>
21
21
  </div>
22
+ <% if params[:avo_debug].present? %>
23
+ <!-- Raw value: -->
24
+ <!-- <%== @field.value.inspect %> -->
25
+ <% end %>
22
26
  <% end %>
@@ -5,9 +5,5 @@
5
5
  date_field_format_value: @field.format,
6
6
  } do %>
7
7
  <%= @field.formatted_value %>
8
- <% if params[:avo_debug].present? %>
9
- <!-- Raw value: -->
10
- <!-- <%= @field.formatted_value.inspect %> -->
11
- <% end %>
12
8
  <% end %>
13
9
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Avo::Fields::TrixField::EditComponent < Avo::Fields::EditComponent
4
4
  def trix_id
5
- "trix_#{@resource.name.underscore}_#{@field.id}"
5
+ "trix_#{@resource.class_name_without_resource.underscore}_#{@field.id}"
6
6
  end
7
7
  end
@@ -19,6 +19,6 @@
19
19
  <% end %>
20
20
  <% if params[:avo_debug].present? %>
21
21
  <!-- Raw value: -->
22
- <!-- <%= @field.value.inspect %> -->
22
+ <!-- <%== @field.value.inspect %> -->
23
23
  <% end %>
24
24
  <% end %>
@@ -5,6 +5,7 @@
5
5
  <% if can_view? %>
6
6
  <%= link_to helpers.svg('eye', class: button_classes),
7
7
  show_path,
8
+ class: 'flex items-center',
8
9
  title: t('avo.view_item', item: singular_resource_name).capitalize,
9
10
  data: {
10
11
  target: 'control:view',
@@ -17,6 +18,7 @@
17
18
  <% if can_edit? %>
18
19
  <%= link_to helpers.svg('edit', class: button_classes),
19
20
  edit_path,
21
+ class: 'flex items-center',
20
22
  title: t('avo.edit_item', item: singular_resource_name).capitalize,
21
23
  data: {
22
24
  target: 'control:edit',
@@ -31,6 +33,7 @@
31
33
  <%= form_with url: helpers.resource_detach_path(params[:resource_name], params[:id], params[:related_name], @resource.model.id),
32
34
  method: :delete,
33
35
  local: true,
36
+ class: 'flex items-center',
34
37
  html: {
35
38
  'data-turbo-frame': params[:turbo_frame]
36
39
  } do |form| %>
@@ -9,12 +9,21 @@
9
9
  </div>
10
10
  </td>
11
11
  <% end %>
12
+ <% if Avo.configuration.resource_controls_on_the_left? %>
13
+ <td class="text-right whitespace-nowrap px-2" data-control="resource-controls">
14
+ <div class="flex items-center justify-end flex-grow-0 h-full w-full">
15
+ <%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource, view_type: :table)) %>
16
+ </div>
17
+ </td>
18
+ <% end %>
12
19
  <% @resource.get_fields(reflection: @reflection, only_root: true).each_with_index do |field, index| %>
13
20
  <%= render field.component_for_view(:index).new(field: field, resource: @resource, index: index, parent_model: @parent_model) %>
14
21
  <% end %>
15
- <td class="text-right whitespace-nowrap px-2">
16
- <div class="flex items-center justify-end flex-grow-0 h-full w-full">
17
- <%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource, view_type: :table)) %>
18
- </div>
19
- </td>
22
+ <% if Avo.configuration.resource_controls_on_the_right? %>
23
+ <td class="text-right whitespace-nowrap px-2" data-control="resource-controls">
24
+ <div class="flex items-center justify-end flex-grow-0 h-full w-full">
25
+ <%= render(Avo::Index::ResourceControlsComponent.new(resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource, view_type: :table)) %>
26
+ </div>
27
+ </td>
28
+ <% end %>
20
29
  </tr>
@@ -1,6 +1,6 @@
1
1
  <% if item.is_tool? %>
2
2
  <% if item&.partial.present? %>
3
- <%= render item.partial, tool: item %>
3
+ <%= render item.partial, tool: item, form: @form %>
4
4
  <% end %>
5
5
  <% elsif item.is_panel? %>
6
6
  <%= render Avo::PanelComponent.new(title: item.name, description: item.description, index: index, view: view) do |c| %>
@@ -1,6 +1,12 @@
1
1
  <div
2
- class="avo-sidebar fixed z-[60] t-0 application-sidebar w-64 hidden lg:flex flex-1 border-r lg:border-none bg-none h-[calc(100vh-4rem)] bg-gray-25 lg:bg-transparent <%= 'print:hidden' if Avo.configuration.hide_layout_when_printing %>";
3
- data-sidebar-target="sidebar"
2
+ class="avo-sidebar fixed z-[60] t-0 application-sidebar w-64 flex-1 border-r lg:border-none bg-none h-[calc(100vh-4rem)] bg-gray-25 lg:bg-transparent <%= 'print:hidden' if Avo.configuration.hide_layout_when_printing %> <%= @sidebar_open ? 'flex' : 'hidden' %>"
3
+ data-sidebar-target="<%= stimulus_target %>"
4
+ data-transition-enter="transition ease-out duration-100"
5
+ data-transition-enter-start="transform opacity-0 -translate-x-full"
6
+ data-transition-enter-end="transform opacity-100 translate-x-0"
7
+ data-transition-leave="transition ease-in duration-75"
8
+ data-transition-leave-start="transform opacity-100 translate-x-0"
9
+ data-transition-leave-end="transform opacity-0 -translate-x-full"
4
10
  >
5
11
  <div class="flex flex-col w-full h-full">
6
12
  <div class="flex-1 flex flex-col justify-between overflow-auto h-full pt-3 scroll-shadows">
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::SidebarComponent < ViewComponent::Base
4
+ def initialize(sidebar_open: nil, for_mobile: false)
5
+ @sidebar_open = sidebar_open
6
+ @for_mobile = for_mobile
7
+ end
8
+
4
9
  def dashboards
5
10
  Avo::App.dashboards_for_navigation
6
11
  end
@@ -12,4 +17,8 @@ class Avo::SidebarComponent < ViewComponent::Base
12
17
  def tools
13
18
  Avo::App.tools_for_navigation
14
19
  end
20
+
21
+ def stimulus_target
22
+ @for_mobile ? "mobileSidebar" : "sidebar"
23
+ end
15
24
  end
@@ -151,7 +151,7 @@ module Avo
151
151
  is_attach_action = params[model_param_key].blank? && params[:related_name].present? && params[:fields].present?
152
152
 
153
153
  unless is_attach_action
154
- @model = @resource.fill_model(@model_to_fill, cast_nullable(model_params))
154
+ @model = @resource.fill_model(@model_to_fill, cast_nullable(model_params), extra_params: extra_params)
155
155
  end
156
156
  end
157
157
 
@@ -328,7 +328,7 @@ module Avo
328
328
 
329
329
  def set_sidebar_open
330
330
  value = cookies["#{Avo::COOKIES_KEY}.sidebar.open"]
331
- @sidebar_open = value.blank? || value == '1'
331
+ @sidebar_open = value.blank? || value == "1"
332
332
  end
333
333
  end
334
334
  end
@@ -11,7 +11,7 @@ module Avo
11
11
  before_action :set_edit_title_and_breadcrumbs, only: [:edit, :update]
12
12
  before_action :fill_model, only: [:create, :update]
13
13
  # Don't run base authorizations for associations
14
- before_action :authorize_base_action, if: -> {controller_name != "associations"}
14
+ before_action :authorize_base_action, if: -> { controller_name != "associations" }
15
15
 
16
16
  def index
17
17
  @page_title = @resource.plural_name.humanize
@@ -248,7 +248,11 @@ module Avo
248
248
  end
249
249
 
250
250
  def permitted_params
251
- @resource.get_field_definitions.select(&:updatable).map(&:to_permitted_param)
251
+ @resource.get_field_definitions.select(&:updatable).map(&:to_permitted_param).concat extra_params
252
+ end
253
+
254
+ def extra_params
255
+ @resource.class.extra_params || []
252
256
  end
253
257
 
254
258
  def cast_nullable(params)
@@ -110,13 +110,15 @@ export default class extends Controller {
110
110
  }
111
111
 
112
112
  inputField(id = 'key', index, key, value) {
113
+ const inputValue = id === 'key' ? key : value
114
+
113
115
  return `<input
114
116
  class="${this.options.inputClasses} focus:bg-gray-100 !rounded-none border-gray-600 border-r border-l-0 border-b-0 border-t-0 focus:border-gray-300 w-1/2 focus:outline-none outline-none key-value-input-${id}"
115
117
  data-action="input->key-value#${id}FieldUpdated"
116
118
  placeholder="${this.options[`${id}_label`]}"
117
119
  data-index="${index}"
118
120
  ${this[`${id}InputDisabled`] ? "disabled='disabled'" : ''}
119
- value="${id === 'key' ? key : value}"
121
+ value="${typeof inputValue === 'undefined' || inputValue === null ? '' : inputValue}"
120
122
  />`
121
123
  }
122
124
 
@@ -1,8 +1,9 @@
1
1
  import { Controller } from '@hotwired/stimulus'
2
+ import { enter, leave, toggle } from 'el-transition'
2
3
  import Cookies from 'js-cookie'
3
4
 
4
5
  export default class extends Controller {
5
- static targets = ['sidebar', 'mainArea']
6
+ static targets = ['sidebar', 'mobileSidebar', 'mainArea']
6
7
 
7
8
  static values = {
8
9
  open: Boolean,
@@ -23,12 +24,14 @@ export default class extends Controller {
23
24
  markSidebarClosed() {
24
25
  Cookies.set(this.cookieKey, '0')
25
26
  this.openValue = false
27
+ leave(this.sidebarTarget)
26
28
  this.mainAreaTarget.classList.remove('sidebar-open')
27
29
  }
28
30
 
29
31
  markSidebarOpen() {
30
32
  Cookies.set(this.cookieKey, '1')
31
33
  this.openValue = true
34
+ enter(this.sidebarTarget)
32
35
  this.mainAreaTarget.classList.add('sidebar-open')
33
36
  }
34
37
 
@@ -41,6 +44,6 @@ export default class extends Controller {
41
44
  }
42
45
 
43
46
  toggleSidebarOnMobile() {
44
- this.sidebarTarget.classList.toggle('hidden')
47
+ toggle(this.mobileSidebarTarget)
45
48
  }
46
49
  }
@@ -0,0 +1,23 @@
1
+ <%= render Avo::TurboFrameWrapperComponent.new(params[:turbo_frame]) do %>
2
+ <%
3
+ classes = 'absolute inset-auto left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2'
4
+ label = t 'avo.failed_to_load'
5
+ %>
6
+ <div class="relative flex-1 py-12">
7
+ <div class="relative block text-gray-300 h-40 w-full">
8
+ <%= svg 'avocado', class: "#{classes} h-20 text-gray-400" %>
9
+ <%= svg 'code', class: "#{classes} h-8 -ml-20 -mt-12" %>
10
+ <%= svg 'fire', class: "#{classes} h-8 -ml-10 -mt-24" %>
11
+ <%= svg 'color-swatch', class: "#{classes} h-8 ml-8 -mt-24" %>
12
+ <%= svg 'globe', class: "#{classes} h-8 ml-20 -mt-12" %>
13
+ <%= svg 'library', class: "#{classes} h-8 -ml-20 mt-4" %>
14
+ <%= svg 'photograph', class: "#{classes} h-8 ml-20 mt-4" %>
15
+ </div>
16
+ <div class="relative block text-center text-lg text-gray-400 font-semibold -mt-10"><%= label %> <span class="border-b-2 border-dashed"><%= params[:turbo_frame].to_s.humanize.downcase if params[:turbo_frame].present? %></span> frame</div>
17
+ </div>
18
+ <% if Rails.env.development? %>
19
+ <div class="text-center text-sm w-full">
20
+ This is not an issue with Avo. Click <%= link_to 'this link', params[:src], target: :_blank %> to see why this frame failed to load.
21
+ </div>
22
+ <% end %>
23
+ <% end %>
@@ -3,21 +3,15 @@
3
3
  classes = 'absolute inset-auto left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2'
4
4
  label = t 'avo.failed_to_load'
5
5
  %>
6
- <div class="relative flex-1 py-12">
7
- <div class="relative block text-gray-300 h-40 w-full">
8
- <%= svg 'avocado', class: "#{classes} h-20 text-gray-400" %>
9
- <%= svg 'code', class: "#{classes} h-8 -ml-20 -mt-12" %>
10
- <%= svg 'fire', class: "#{classes} h-8 -ml-10 -mt-24" %>
11
- <%= svg 'color-swatch', class: "#{classes} h-8 ml-8 -mt-24" %>
12
- <%= svg 'globe', class: "#{classes} h-8 ml-20 -mt-12" %>
13
- <%= svg 'library', class: "#{classes} h-8 -ml-20 mt-4" %>
14
- <%= svg 'photograph', class: "#{classes} h-8 ml-20 mt-4" %>
6
+ <div class="relative flex-1 py-4">
7
+ <div class="relative block text-gray-300 h-64 w-full">
8
+ <%= svg 'failed_to_load', class: "#{classes} h-52 text-gray-400" %>
15
9
  </div>
16
- <div class="relative block text-center text-lg text-gray-400 font-semibold -mt-10"><%= label %> <span class="border-b-2 border-dashed"><%= params[:turbo_frame].to_s.humanize.downcase if params[:turbo_frame].present? %></span> frame</div>
10
+ <div class="relative block text-center text-lg text-gray-400 font-semibold pb-6"><%= label %> <span class="border-b-2 border-dashed"><%= params[:turbo_frame].to_s.humanize.downcase if params[:turbo_frame].present? %></span> frame</div>
11
+ <% if Rails.env.development? %>
12
+ <div class="text-center text-sm w-full pb-3">
13
+ This is not an issue with Avo. Use <%= link_to 'this page', params[:src], target: :_blank %> to see why this frame failed to load.
14
+ </div>
15
+ <% end %>
17
16
  </div>
18
- <% if Rails.env.development? %>
19
- <div class="text-center text-sm w-full">
20
- This is not an issue with Avo. Click <%= link_to 'this link', params[:src], target: :_blank %> to see why this frame failed to load.
21
- </div>
22
- <% end %>
23
17
  <% end %>
@@ -1,9 +1,14 @@
1
1
  <thead class="bg-white border-b border-gray-200 pb-1">
2
2
  <% if @resource.record_selector %>
3
- <th class="rounded-lg">
3
+ <th class="rounded-lg" data-control="item-select-th">
4
4
  <%== item_select_all_input %>
5
5
  </th>
6
6
  <% end %>
7
+ <% if Avo.configuration.resource_controls_on_the_left? %>
8
+ <th class="w-24" data-control="resource-controls-th">
9
+ <!-- Item controls cell -->
10
+ </th>
11
+ <% end %>
7
12
  <% fields.each_with_index do |field, index| %>
8
13
  <%
9
14
  if params[:sort_by] == field.id.to_s
@@ -39,7 +44,7 @@
39
44
  ""
40
45
  end
41
46
  %>
42
- <th class="text-left uppercase px-3 py-2 whitespace-nowrap rounded-l">
47
+ <th class="text-left uppercase px-3 py-2 whitespace-nowrap rounded-l" data-control="resource-field-th">
43
48
  <% if field.sortable %>
44
49
  <%= link_to params.permit!.merge(sort_by: sort_by, sort_direction: sort_direction), class: "flex items-center #{classes} #{'cursor-pointer' if field.sortable}", 'data-turbo-frame': params[:turbo_frame] do %>
45
50
  <%= field.name %>
@@ -52,7 +57,9 @@
52
57
  <% end %>
53
58
  </th>
54
59
  <% end %>
55
- <th class="w-24">
56
- <!-- Item controls cell -->
57
- </th>
60
+ <% if Avo.configuration.resource_controls_on_the_right? %>
61
+ <th class="w-24" data-control="resource-controls-th">
62
+ <!-- Item controls cell -->
63
+ </th>
64
+ <% end %>
58
65
  </thead>
@@ -23,7 +23,12 @@
23
23
  <div class="flex-1 flex flex-col max-w-full">
24
24
  <%= render partial: "avo/partials/navbar" %>
25
25
  <div data-sidebar-target="mainArea" class="content-area flex-1 flex pt-16 relative <%= 'sidebar-open' if @sidebar_open %>">
26
- <%= render Avo::SidebarComponent.new %>
26
+ <div class="hidden lg:flex">
27
+ <%= render Avo::SidebarComponent.new sidebar_open: @sidebar_open %>
28
+ </div>
29
+ <div class="flex lg:hidden">
30
+ <%= render Avo::SidebarComponent.new sidebar_open: false, for_mobile: true %>
31
+ </div>
27
32
  <div class="main-content-area flex-1 flex flex-col min-h-full max-w-full">
28
33
  <div class="content p-4 lg:p-6 flex-1 flex flex-col justify-between items-stretch <%= @container_classes %>">
29
34
  <%= render partial: "avo/partials/custom_tools_alert" %>
data/bin/init CHANGED
@@ -28,6 +28,11 @@ app_root do
28
28
  header 'Preparing the database'
29
29
  run! 'bin/rails db:setup'
30
30
 
31
+ header 'Building assets'
32
+ run! 'yarn build:js'
33
+ run! 'yarn build:custom-js'
34
+ run! 'yarn build:css'
35
+
31
36
  if use_docker == 'y'
32
37
  header 'Stopping the Docker image'
33
38
  run! 'docker-compose stop'
@@ -47,6 +47,7 @@ module Avo
47
47
  class_attribute :after_update_path, default: :show
48
48
  class_attribute :record_selector, default: true
49
49
  class_attribute :keep_filters_panel_open, default: false
50
+ class_attribute :extra_params
50
51
 
51
52
  class << self
52
53
  delegate :t, to: ::I18n
@@ -251,7 +252,7 @@ module Avo
251
252
  end
252
253
  end
253
254
 
254
- def fill_model(model, params)
255
+ def fill_model(model, params, extra_params: [])
255
256
  # Map the received params to their actual fields
256
257
  fields_by_database_id = get_field_definitions
257
258
  .reject do |field|
@@ -262,6 +263,7 @@ module Avo
262
263
  end
263
264
  .to_h
264
265
 
266
+ # Write the field values
265
267
  params.each do |key, value|
266
268
  field = fields_by_database_id[key]
267
269
 
@@ -270,6 +272,19 @@ module Avo
270
272
  model = field.fill_field model, key, value, params
271
273
  end
272
274
 
275
+ # Write the user configured extra params to the model
276
+ if extra_params.present?
277
+ extra_params.each do |param_id|
278
+ # if it's a nested array, use the key
279
+ param_id = param_id.first.first if param_id.is_a? Hash
280
+
281
+ next unless model.respond_to? "#{param_id}="
282
+
283
+ param_value = params[param_id]
284
+ model.send("#{param_id}=", param_value)
285
+ end
286
+ end
287
+
273
288
  model
274
289
  end
275
290
 
@@ -13,8 +13,6 @@ module Avo
13
13
  end
14
14
 
15
15
  class_methods do
16
- delegate :tool, to: :items_holder
17
-
18
16
  # DSL methods
19
17
  def field(name, **args, &block)
20
18
  ensure_items_holder_initialized
@@ -34,8 +32,14 @@ module Avo
34
32
  self.items_holder.tabs Avo::TabGroupBuilder.parse_block(&block)
35
33
  end
36
34
 
35
+ def tool(klass, **args)
36
+ ensure_items_holder_initialized
37
+
38
+ items_holder.tool klass, **args
39
+ end
40
+
37
41
  def heading(body, **args)
38
- self.items_holder.add_item Avo::Fields::HeadingField.new(body, order_index: items_index, **args)
42
+ self.items_holder.heading body, **args
39
43
  end
40
44
  # END DSL methods
41
45
 
@@ -14,7 +14,7 @@ module Avo
14
14
  when String, Symbol
15
15
  value.to_s.safe_constantize
16
16
  else
17
- raise ArgumentError.new "Failed to find a proper model class for #{self.to_s}"
17
+ raise ArgumentError.new "Failed to find a proper model class for #{self}"
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,21 @@
1
+ module Avo
2
+ class Configuration
3
+ module ResourceConfiguration
4
+ def resource_controls_placement=(val)
5
+ @resource_controls_placement_instance = val
6
+ end
7
+
8
+ def resource_controls_placement
9
+ @resource_controls_placement_instance || :right
10
+ end
11
+
12
+ def resource_controls_on_the_left?
13
+ resource_controls_placement == :left
14
+ end
15
+
16
+ def resource_controls_on_the_right?
17
+ resource_controls_placement == :right
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,7 @@
1
1
  module Avo
2
2
  class Configuration
3
+ include ResourceConfiguration
4
+
3
5
  attr_writer :root_path
4
6
  attr_accessor :app_name
5
7
  attr_accessor :timezone
@@ -49,6 +49,12 @@ module Avo
49
49
  add_item panel
50
50
  end
51
51
 
52
+ def heading(body = nil, **args, &block)
53
+ field = Avo::Fields::HeadingField.new(body, **args)
54
+
55
+ add_item field
56
+ end
57
+
52
58
  def add_item(instance)
53
59
  @items << instance
54
60
 
@@ -5,6 +5,7 @@ class Avo::PanelBuilder
5
5
  end
6
6
  end
7
7
 
8
+ delegate :heading, to: :items_holder
8
9
  delegate :field, to: :items_holder
9
10
  delegate :items, to: :items_holder
10
11
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.11.1.pre.3" unless const_defined?(:VERSION)
2
+ VERSION = "2.11.2.pre.2" unless const_defined?(:VERSION)
3
3
  end