avo 2.30.1.pre4.pr1683 → 2.30.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7026eb5ccd2fa76aab49f686e6e3d87e310e54ed6d220aab367c87283690d29e
4
- data.tar.gz: 3de5de591bb61c2d022eb71e25b08cceb225dc5af6f92ba2d4431abf594bbe45
3
+ metadata.gz: fc6bc41d1c4845492b9ee785b1ccd4895d0369ec54d2b307c67835a112059923
4
+ data.tar.gz: a04214b31f49e408ecf64166c126dd8a114543f4c3ad01383f33ba1d7216c88d
5
5
  SHA512:
6
- metadata.gz: 005c54601761b2d69acea075c89a433c9a170d591db6e7d3cfdfd6b7cc75d36d87eee9eedec207aea59413c6ebc9efebed14896e5ed2a51eb46bfbd532a8c4e7
7
- data.tar.gz: 89376982016bd362d2148cd57244fe9e8c3b5e998f081f3b34557e484a09e55c7d7370a22d2f7047bb418813c5edc7b7b124284a53a7eb58c59481183cb0229f
6
+ metadata.gz: e36a294bc70cd7568ea15c7e5d4323b1d261bfeaf7295ae2439cf581bef67ea0efcebe9995d23bfb416904e89810342df73d20591aa6790d128593ffceca7a16
7
+ data.tar.gz: d2eac35c9568ed230c05155823be7f52add0e4a86fa0f43ec85dbe2c69e84e5cb6188b7799714c739922269ba16b4919e3a0e7e7eb5f8d79cd4220669e0671ba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.30.1.pre4.pr1683)
4
+ avo (2.30.2)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -9,6 +9,5 @@
9
9
  <defs>
10
10
  <stop stop-color="#E3ECFA"/>
11
11
  <stop offset="1" stop-color="#DAE7FF"/>
12
- </linearGradient>
13
12
  </defs>
14
13
  </svg>
@@ -22,7 +22,6 @@
22
22
  <feColorMatrix type="matrix" values="0 0 0 0 0.788235 0 0 0 0 0.803922 0 0 0 0 0.85098 0 0 0 0.349 0"/>
23
23
  <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_577_1090"/>
24
24
  <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_577_1090" result="shape"/>
25
- </filter>
26
25
  <filter id="filter1_d_577_1090" x="38.6401" y="0" width="170.72" height="78.1333" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
27
26
  <feFlood flood-opacity="0" result="BackgroundImageFix"/>
28
27
  <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
@@ -51,6 +51,5 @@
51
51
  </filter>
52
52
  <stop stop-color="#E3ECFA"/>
53
53
  <stop offset="1" stop-color="#DAE7FF"/>
54
- </linearGradient>
55
54
  </defs>
56
55
  </svg>
@@ -11,7 +11,7 @@
11
11
  <% if on_edit? && field.is_required? %> <span class="text-red-600 ml-1">*</span> <% end %>
12
12
  </div>
13
13
  <div class="flex-1 flex flex-row md:min-h-inherit py-2 <% if stacked? %> pb-4 <% else %><% end %> px-6 <%= @field.get_html(:classes, view: view, element: :content) %>" data-slot="value">
14
- <div class="self-center w-full <% if full_width? || compact? || stacked? %> <% else %> md:w-8/12 <% end %>">
14
+ <div class="self-center w-full <% unless full_width? || compact? || stacked? %> md:w-8/12 <% end %>">
15
15
  <% if on_show? %>
16
16
  <% if field.value.blank? and dash_if_blank %>
17
17
 
@@ -2,12 +2,18 @@
2
2
  <%= turbo_frame_tag @field.id do %>
3
3
  <% unless @field.hide_view_type_switcher %>
4
4
  <div class="justify-self-end flex justify-end items-center space-x-3">
5
- <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: @field.view_type, turbo_frame: @field.id } %>
5
+ <%= render partial: 'avo/partials/view_toggle_button',
6
+ locals: {
7
+ available_view_types: available_view_types,
8
+ view_type: view_type,
9
+ turbo_frame: @field.id,
10
+ }
11
+ %>
6
12
  </div>
7
13
  <% end %>
8
14
  <div class="<%= classes %>">
9
15
  <% @field.value.attachments.each do |file| %>
10
- <%= render @field.viewer_component.new field: @field, resource: @resource, file: file %>
16
+ <%= render view_type_component(file) %>
11
17
  <% end %>
12
18
  </div>
13
19
  <% end %>
@@ -3,7 +3,7 @@
3
3
  class Avo::Fields::Common::Files::ListViewerComponent < ViewComponent::Base
4
4
  include Turbo::FramesHelper
5
5
 
6
- attr_reader :field
6
+ attr_reader :field, :resource
7
7
 
8
8
  def initialize(field:, resource:)
9
9
  @field = field
@@ -13,7 +13,7 @@ class Avo::Fields::Common::Files::ListViewerComponent < ViewComponent::Base
13
13
  def classes
14
14
  base_classes = "py-4 rounded-xl max-w-full"
15
15
 
16
- view_type_classes = if @field.view_type == :list
16
+ view_type_classes = if view_type == :list
17
17
  "flex flex-col space-y-2"
18
18
  else
19
19
  "relative grid xs:grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6"
@@ -29,4 +29,13 @@ class Avo::Fields::Common::Files::ListViewerComponent < ViewComponent::Base
29
29
  def available_view_types
30
30
  [:list, :grid]
31
31
  end
32
+
33
+ def view_type_component(file)
34
+ component = "Avo::Fields::Common::Files::ViewType::#{view_type.to_s.capitalize}Component".constantize
35
+ component.new(field: field, resource: resource, file: file)
36
+ end
37
+
38
+ def view_type
39
+ (resource.params.dig(:view_type) || field.view_type).to_sym
40
+ end
32
41
  end
@@ -1,4 +1,4 @@
1
- <div class="relative min-h-full max-w-full flex-1 flex flex-col justify-between space-y-2">
1
+ <div id="<%= dom_id file %>" class="relative min-h-full max-w-full flex-1 flex flex-col justify-between space-y-2">
2
2
  <% if file.present? %>
3
3
  <div class="flex flex-col justify-between h-full">
4
4
  <% if file.representable? && is_image? %>
@@ -1,4 +1,4 @@
1
- <div class="relative min-h-full max-w-full flex-1 flex">
1
+ <div id="<%= dom_id file %>" class="relative min-h-full max-w-full flex-1 flex">
2
2
  <% if file.present? %>
3
3
  <div class="grid grid-cols-6 gap-2 items-center max-w-full w-full">
4
4
  <div class="col-span-4 flex-1 flex flex-row items-center text-gray-700 overflow-x-auto mac-styled-scrollbar ">
@@ -23,17 +23,24 @@ module Avo
23
23
  end
24
24
 
25
25
  def destroy
26
- raise Avo::NotAuthorizedError.new unless authorized_to :delete
26
+ if authorized_to :delete
27
+ attachment = ActiveStorage::Attachment.find(params[:attachment_id])
27
28
 
28
- attachment = ActiveStorage::Attachment.find(params[:attachment_id])
29
- path = resource_path(model: @model, resource: @resource)
29
+ flash[:notice] = if attachment.present?
30
+ @destroyed = attachment.destroy
30
31
 
31
- if attachment.present?
32
- attachment.destroy
33
-
34
- redirect_to params[:referrer] || path, notice: t("avo.attachment_destroyed")
32
+ t("avo.attachment_destroyed")
33
+ else
34
+ t("avo.failed_to_find_attachment")
35
+ end
35
36
  else
36
- redirect_back fallback_location: path, notice: t("avo.failed_to_find_attachment")
37
+ flash[:notice] = t("avo.not_authorized")
38
+ end
39
+
40
+ respond_to do |format|
41
+ format.turbo_stream do
42
+ render "destroy"
43
+ end
37
44
  end
38
45
  end
39
46
 
@@ -111,6 +111,14 @@ module Avo
111
111
  Avo::Engine.routes.find_script_name(params.permit!.to_h.symbolize_keys)
112
112
  end
113
113
 
114
+ def decode_filter_params(encoded_params)
115
+ Avo::Filters::BaseFilter.decode_filters(encoded_params)
116
+ end
117
+
118
+ def encode_filter_params(filter_params)
119
+ Avo::Filters::BaseFilter.encode_filters(filter_params)
120
+ end
121
+
114
122
  private
115
123
 
116
124
  # Taken from the original library
@@ -0,0 +1,7 @@
1
+ <%= turbo_stream.remove dom_id(@destroyed) if @destroyed.present? %>
2
+
3
+ <turbo-stream action="append" target="alerts">
4
+ <template>
5
+ <%= render Avo::FlashAlertsComponent.new flashes: flash %>
6
+ </template>
7
+ </turbo-stream>
data/db/factories.rb CHANGED
@@ -42,6 +42,20 @@ FactoryBot.define do
42
42
  progress { Faker::Number.between(from: 0, to: 100) }
43
43
  end
44
44
 
45
+ trait :with_files do
46
+ after(:create) do |project|
47
+ ["watch.jpg", "dummy-video.mp4"].each do |filename|
48
+ file = Rails.root.join("db", "seed_files", filename)
49
+ project.files.attach(io: file.open, filename: filename)
50
+ end
51
+
52
+ ["dummy-file.txt", "dummy-audio.mp3"].each do |filename|
53
+ file = Avo::Engine.root.join("spec", "dummy", filename)
54
+ project.files.attach(io: file.open, filename: filename)
55
+ end
56
+ end
57
+ end
58
+
45
59
  factory :comment do
46
60
  body { Faker::Lorem.paragraphs(number: rand(4...10)).join(" ") }
47
61
  posted_at { Time.now - rand(10...365).days }
@@ -71,7 +71,7 @@ module Avo
71
71
  @id_links_to_resource = false
72
72
  @full_width_container = false
73
73
  @full_width_index_view = false
74
- @cache_resources_on_index_view = false
74
+ @cache_resources_on_index_view = Avo::PACKED
75
75
  @cache_resource_filters = false
76
76
  @context = proc {}
77
77
  @initial_breadcrumbs = proc {
@@ -40,7 +40,6 @@ module Avo
40
40
  attr_reader :stacked
41
41
 
42
42
  # Private options
43
- attr_reader :updatable
44
43
  attr_reader :computable # if allowed to be computable
45
44
  attr_reader :computed # if block is present
46
45
  attr_reader :computed_value # the value after computation
@@ -257,6 +256,10 @@ module Avo
257
256
  !visible_in_reflection?
258
257
  end
259
258
 
259
+ def updatable
260
+ @updatable && visible?
261
+ end
262
+
260
263
  private
261
264
 
262
265
  def model_or_class(model)
@@ -6,6 +6,7 @@ module Avo
6
6
  attr_accessor :direct_upload
7
7
  attr_accessor :accept
8
8
  attr_reader :display_filename
9
+ attr_reader :view_type
9
10
  attr_reader :hide_view_type_switcher
10
11
 
11
12
  def initialize(id, **args, &block)
@@ -40,14 +41,6 @@ module Avo
40
41
 
41
42
  model
42
43
  end
43
-
44
- def viewer_component
45
- "Avo::Fields::Common::Files::ViewType::#{view_type.to_s.capitalize}Component".constantize
46
- end
47
-
48
- def view_type
49
- (@resource.params.dig(:view_type) || @view_type).to_sym
50
- end
51
44
  end
52
45
  end
53
46
  end
@@ -21,6 +21,10 @@ module Avo
21
21
  {}
22
22
  end
23
23
 
24
+ def encode_filters(filter_params)
25
+ Base64.encode64(filter_params.to_json)
26
+ end
27
+
24
28
  def get_empty_message
25
29
  empty_message || I18n.t("avo.no_options_available")
26
30
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.30.1.pre4.pr1683" unless const_defined?(:VERSION)
2
+ VERSION = "2.30.2" unless const_defined?(:VERSION)
3
3
  end
@@ -21,7 +21,7 @@ module Generators
21
21
  end
22
22
 
23
23
  if Rails.root.join("Procfile.dev").exist?
24
- append_to_file "Procfile.dev", "avo_css: bin/rails avo:tailwindcss:watch\n"
24
+ append_to_file "Procfile.dev", "avo_css: yarn avo:tailwindcss --watch\n"
25
25
  else
26
26
  say "Add default Procfile.dev"
27
27
  copy_file template_path("Procfile.dev"), "Procfile.dev"
@@ -38,6 +38,9 @@ module Generators
38
38
 
39
39
  say "Adding the CSS asset to the partial"
40
40
  prepend_to_file Rails.root.join("app", "views", "avo", "partials", "_pre_head.html.erb"), "<%= stylesheet_link_tag \"avo.tailwind.css\", media: \"all\" %>"
41
+
42
+ say "Ensure you have the following script in your package.json file.", :yellow
43
+ say %("scripts": { "avo:tailwindcss": "tailwindcss -i ./app/assets/stylesheets/avo.tailwind.css -o ./app/assets/builds/avo.tailwind.css --minify" }), :green
41
44
  end
42
45
 
43
46
  no_tasks do
@@ -47,7 +47,7 @@ Avo.configure do |config|
47
47
  # config.per_page_steps = [12, 24, 48, 72]
48
48
  # config.via_per_page = 8
49
49
  # config.id_links_to_resource = false
50
- # config.cache_resources_on_index_view = false
50
+ # config.cache_resources_on_index_view = true
51
51
  ## permanent enable or disable cache_resource_filters, default value is false
52
52
  # config.cache_resource_filters = false
53
53
  ## provide a lambda to enable or disable cache_resource_filters per user/resource.
@@ -1,2 +1,2 @@
1
1
  web: bin/rails server -p 3000
2
- avo_css: bin/rails avo:tailwindcss:watch
2
+ avo_css: yarn avo:tailwindcss --watch
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: 2.30.1.pre4.pr1683
4
+ version: 2.30.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-17 00:00:00.000000000 Z
12
+ date: 2023-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -1646,6 +1646,7 @@ files:
1646
1646
  - app/views/avo/actions/keep_modal_open.turbo_stream.erb
1647
1647
  - app/views/avo/actions/show.html.erb
1648
1648
  - app/views/avo/associations/new.html.erb
1649
+ - app/views/avo/attachments/destroy.turbo_stream.erb
1649
1650
  - app/views/avo/base/_boolean_filter.html.erb
1650
1651
  - app/views/avo/base/_multiple_select_filter.html.erb
1651
1652
  - app/views/avo/base/_select_filter.html.erb
@@ -1704,7 +1705,6 @@ files:
1704
1705
  - config/credentials.yml.enc
1705
1706
  - config/i18n-tasks.yml
1706
1707
  - config/initializers/pagy.rb
1707
- - config/master.key
1708
1708
  - config/routes.rb
1709
1709
  - config/spring.rb
1710
1710
  - db/factories.rb
@@ -1966,9 +1966,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1966
1966
  version: 2.6.0
1967
1967
  required_rubygems_version: !ruby/object:Gem::Requirement
1968
1968
  requirements:
1969
- - - ">"
1969
+ - - ">="
1970
1970
  - !ruby/object:Gem::Version
1971
- version: 1.3.1
1971
+ version: '0'
1972
1972
  requirements: []
1973
1973
  rubygems_version: 3.3.3
1974
1974
  signing_key:
data/config/master.key DELETED
@@ -1 +0,0 @@
1
- 2aeb23d82b909d9c6b5abb62f7058c2a