lib/avo/base_resource.rb in avo-3.0.0.pre11 vs lib/avo/base_resource.rb in avo-3.0.0.pre12

- old
+ new

@@ -6,10 +6,11 @@ include Avo::Concerns::HasItems include Avo::Concerns::CanReplaceItems include Avo::Concerns::HasControls include Avo::Concerns::HasStimulusControllers include Avo::Concerns::ModelClassConstantized + include Avo::Concerns::HasDescription # Avo::Current methods delegate :context, to: Avo::Current delegate :current_user, to: Avo::Current delegate :params, to: Avo::Current @@ -36,11 +37,10 @@ attr_accessor :user attr_accessor :record class_attribute :id, default: :id class_attribute :title, default: :id - class_attribute :description, default: :id class_attribute :search_query, default: nil class_attribute :search_query_help, default: "" class_attribute :search_result_path class_attribute :includes, default: [] class_attribute :authorization_policy @@ -278,20 +278,10 @@ @record.id rescue name end - def resource_description - return instance_exec(&self.class.description) if self.class.description.respond_to? :call - - # Show the description only on the resource index view. - # If the user wants to conditionally it on all pages, they should use a block. - if view == :index - return self.class.description if self.class.description.is_a? String - end - end - def translation_key self.class.translation_key || "avo.resource_translations.#{class_name.underscore}" end def name @@ -513,11 +503,11 @@ end rescue nil end - def description + def search_description description_field&.value end def form_scope model_class.base_class.to_s.underscore.downcase @@ -540,8 +530,16 @@ :id end def record_id record.send(id_attribute) + end + + def description_attributes + { + view: view, + resource: self, + record: record + } end end end