Sha256: 9d78e7bf0a2f57409a2f4a78cc98882f322f896f9dcc4d1c0243dd93ee378eb2
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true class Avo::Fields::TrixField::EditComponent < Avo::Fields::EditComponent attr_reader :resource def initialize(**args) @resource = args[:resource] @resource_id = args[:resource_id] || @resource&.record&.to_param @resource_name = args[:resource_name] || @resource&.singular_route_key super(**args) @input_id = if @resource_name.present? "#{@field.type}_#{@resource_name}_#{@field.id}" elsif form.present? "#{@field.type}_#{form.index}_#{@field.id}" end end # The controller element should have a unique_selector attribute. # It's used to identify the specific editor for the media library to delegate the attach event to. def data values = { resource_name: @resource_name, resource_id: @resource_id, unique_selector: ".#{@input_id}", # mandatory attachments_disabled: @field.attachments_disabled, attachment_key: @field.attachment_key, hide_attachment_filename: @field.hide_attachment_filename, hide_attachment_filesize: @field.hide_attachment_filesize, hide_attachment_url: @field.hide_attachment_url, is_action_text: @field.is_action_text?, upload_warning: t("avo.you_cant_upload_new_resource"), attachment_disable_warning: t("avo.this_field_has_attachments_disabled"), attachment_key_warning: t("avo.you_havent_set_attachment_key") }.transform_keys { |key| "trix_field_#{key}_value" } { controller: "trix-field", trix_field_target: "controller", action: "insert-attachment->trix-field#insertAttachment", **values, } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
avo-3.16.4 | app/components/avo/fields/trix_field/edit_component.rb |
avo-3.16.3 | app/components/avo/fields/trix_field/edit_component.rb |