avo-rhino_field 0.0.12 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,9 @@
1
1
  <%= field_wrapper **field_wrapper_args, full_width: true do %>
2
2
  <%= content_tag :div, class: "relative block overflow-x-auto max-w-4xl" do %>
3
3
  <%= content_tag 'avo-rhino-editor',
4
- data: {
5
- controller: "rhino-field",
6
- blob_url_template: helpers.main_app.rails_service_blob_url(":signed_id", ":filename"),
7
- direct_upload_url: helpers.main_app.rails_direct_uploads_url,
8
- action: "rhino-before-initialize->rhino-field#onRhinoBeforeInitialize rhino-initialize->rhino-field#onRhinoInitialize rhino-change->rhino-field#onRhinoChange rhino-paste->rhino-field#onRhinoPaste rhino-selection-change->rhino-field#onRhinoSelectionChange rhino-focus->rhino-field#onRhinoFocus rhino-blur->rhino-field#onRhinoBlur rhino-file-accept->rhino-field#onRhinoFileAccept rhino-attachment-add->rhino-field#onRhinoAttachmentAdd rhino-attachment-remove->rhino-field#onRhinoAttachmentRemove",
9
- **@field.get_html(:data, view: view, element: :input)
10
- },
11
- input: field_id,
4
+ data:,
5
+ input: unique_id,
6
+ class: class_names(unique_id),
12
7
  placeholder: @field.placeholder do %>
13
8
  <button
14
9
  type="button"
@@ -44,13 +39,23 @@
44
39
  class="h-3.5 w-5 bg-transparent -mt-px -mb-1"
45
40
  />
46
41
  </button>
42
+ <a
43
+ slot="before-attach-files-button"
44
+ class="toolbar__button rhino-toolbar-button flex flex-col items-center grow-0 text-sm hidden-until-rhino-boots-up"
45
+ data-role="toolbar-item"
46
+ tabindex="-1"
47
+ href="<%= helpers.avo.attach_media_path(resource_name: @resource.name, record_id: @resource.id, controller_selector: ".#{unique_id}", controller_name: 'rhino-field') %>"
48
+ data-turbo-frame="<%= ::Avo::MODAL_FRAME_ID %>"
49
+ >
50
+ <%= helpers.svg "heroicons/outline/photo", class: "!min-h-4 !max-h-4" %>
51
+ </a>
47
52
  <% end %>
48
53
  <%= @form.text_area @field.id,
49
54
  value: @field.value.try(:to_trix_html) || @field.value,
50
55
  class: classes("w-full hidden"),
51
56
  data: @field.get_html(:data, view: view, element: :input),
52
57
  disabled: disabled?,
53
- id: field_id,
58
+ id: unique_id,
54
59
  placeholder: @field.placeholder,
55
60
  style: @field.get_html(:style, view: view, element: :input)
56
61
  %>
@@ -9,13 +9,30 @@ class Avo::Fields::RhinoField::EditComponent < Avo::Fields::EditComponent
9
9
  @resource_name = args[:resource_name] || @resource&.singular_route_key
10
10
 
11
11
  super(**args)
12
+
13
+ @unique_random_id = SecureRandom.hex(4)
12
14
  end
13
15
 
14
- def field_id
16
+ def unique_id
15
17
  if @resource_name.present?
16
- "rhino_#{@resource_name}_#{@field.id}"
18
+ "rhino_#{@resource_name}_#{@field.id}_#{@unique_random_id}"
17
19
  elsif form.present?
18
- "rhino_#{form.index}_#{@field.id}"
20
+ "rhino_#{form.index}_#{@field.id}_#{@unique_random_id}"
19
21
  end
20
22
  end
23
+
24
+ def unique_selector = ".#{unique_id}"
25
+
26
+ def data
27
+ {
28
+ controller: "rhino-field",
29
+ rhino_field_unique_selector_value: unique_selector, # mandatory
30
+ rhino_field_resource_name_value: @resource_name,
31
+ rhino_field_resource_id_value: @resource_id,
32
+ blob_url_template: helpers.main_app.rails_service_blob_url(":signed_id", ":filename"),
33
+ direct_upload_url: helpers.main_app.rails_direct_uploads_url,
34
+ action: "rhino-before-initialize->rhino-field#onRhinoBeforeInitialize rhino-initialize->rhino-field#onRhinoInitialize rhino-change->rhino-field#onRhinoChange rhino-paste->rhino-field#onRhinoPaste rhino-selection-change->rhino-field#onRhinoSelectionChange rhino-focus->rhino-field#onRhinoFocus rhino-blur->rhino-field#onRhinoBlur rhino-file-accept->rhino-field#onRhinoFileAccept rhino-attachment-add->rhino-field#onRhinoAttachmentAdd rhino-attachment-remove->rhino-field#onRhinoAttachmentRemove",
35
+ **@field.get_html(:data, view: view, element: :input)
36
+ }
37
+ end
21
38
  end
@@ -1,14 +1,21 @@
1
- <%= field_wrapper **field_wrapper_args do %>
2
- <%
3
- content_classes = 'trix-content py-2 max-w-4xl'
4
- content_classes << ' hidden' unless @field.always_show
5
- %>
6
- <div data-controller="hidden-input">
7
- <% unless @field.always_show %>
8
- <%= link_to t('avo.show_content'), 'javascript:void(0);', class: 'font-bold inline-block', data: { action: 'click->hidden-input#showContent' } %>
9
- <% end %>
10
- <div class="<%= content_classes %> " data-hidden-input-target="content">
11
- <%= @field.value.html_safe %>
1
+ <%= field_wrapper(**field_wrapper_args, full_width: true, data: { controller: 'hidden-input' }) do %>
2
+ <% button_classes = 'font-semibold inline-block pt-3 text-sm' %>
3
+ <%= content_tag :div,
4
+ class: "flex flex-col w-full",
5
+ data: {
6
+ controller: "trix-body hidden-input",
7
+ trix_body_always_show_value: @field.always_show
8
+ } do %>
9
+ <div class="<%= class_names("trix-content border-none px-0 py-2 max-w-4xl", "hidden": !@field.always_show) %>" data-trix-body-target="content" data-hidden-input-target="content">
10
+ <%== @field.value %>
12
11
  </div>
13
- </div>
12
+ <% if true %>
13
+ <div class="hidden" data-trix-body-target="moreContentButton">
14
+ <%= link_to t('avo.more_content'), 'javascript:void(0);', class: button_classes, data: { action: 'click->trix-body#toggleContent' } %>
15
+ </div>
16
+ <div class="hidden" data-trix-body-target="lessContentButton">
17
+ <%= link_to t('avo.less_content'), 'javascript:void(0);', class: button_classes, data: { action: 'click->trix-body#toggleContent' } %>
18
+ </div>
19
+ <% end %>
20
+ <% end %>
14
21
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module Avo
2
2
  module RhinoField
3
- VERSION = "0.0.12" unless const_defined?(:VERSION)
3
+ VERSION = "0.0.15"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo-rhino_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2025-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: rhino field for Avo.
14
14
  email: adrian@adrianthedev.com
@@ -35,7 +35,7 @@ files:
35
35
  homepage: https://avohq.io
36
36
  licenses: []
37
37
  metadata: {}
38
- post_install_message:
38
+ post_install_message:
39
39
  rdoc_options: []
40
40
  require_paths:
41
41
  - lib
@@ -50,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
- rubygems_version: 3.5.22
54
- signing_key:
53
+ rubygems_version: 3.4.10
54
+ signing_key:
55
55
  specification_version: 4
56
56
  summary: rhino field for Avo.
57
57
  test_files: []