Commit d5cb8c4b authored by Ondřej Ezr's avatar Ondřej Ezr
Browse files

formatter is actually a presenter

parent 3135fd74
Pipeline #13 failed with stage
......@@ -69,11 +69,11 @@ module AzaharaSchema
end
def azahara_attribute_for(model, name)
AzaharaSchema::Schema.schema_class_for(model).attribute(model, name)
::AzaharaSchema::Schema.schema_class_for(model).attribute(model, name)
end
def attribute_formatter_for(schema_or_model, **options)
AttributeFormatter.formatter_for(schema_or_model).new(schema_or_model, self, options)
::AzaharaSchema::Presenter.formatter_for(schema_or_model).new(schema_or_model, self, options)
end
def unfilled_attribute_message
......
......@@ -2,6 +2,8 @@
create_attributes ||= {}
create_model ||= schema.model
create_model = create_model.new
create_scope ||= []
create_scope = create_scope.dup.push(create_model)
%>
<% if local_assigns.fetch(:filters, true) %>
......@@ -11,7 +13,7 @@
<div class="btn-toolbar text-right" role="toolbar" aria-label="Toolbar">
<% if can?(:create, create_model) %>
<div class="btn-group" role="group" aria-label="<%= t('label_actions') %>">
<%= link_to label_record_action(create_model), new_polymorphic_path(create_model, create_attributes), class: 'btn btn-primary' %>
<%= link_to label_record_action(create_model), new_polymorphic_path(create_scope, create_attributes), class: 'btn btn-primary' %>
</div>
<% end %>
</div>
......
......@@ -8,7 +8,7 @@ require 'azahara_schema/outputs'
require 'azahara_schema/output'
require 'azahara_schema/schema'
require 'azahara_schema/model_schema'
require 'azahara_schema/attribute_formatter'
require 'azahara_schema/presenter'
if Object.const_defined?('Rails')
require "azahara_schema/engine"
......
module AzaharaSchema
class AttributeFormatter
class Presenter
def self.default_formatter=(formatter_klass)
@default_formatter = formatter_klass
end
def self.default_formatter
@default_formatter || AzaharaSchema::AttributeFormatter
@default_formatter || AzaharaSchema::Presenter
end
def self.formatter_for(schema_or_entity)
......@@ -19,7 +19,7 @@ module AzaharaSchema
klasses << klass
end
klasses.each do |kls|
schema_klass = "#{kls.name}Formatter".safe_constantize || "Formatters::#{kls.name}Formatter".safe_constantize
schema_klass = "#{kls.name}Presenter".safe_constantize || "Presenters::#{kls.name}Presenter".safe_constantize
return schema_klass if schema_klass
end
default_formatter
......
module AzaharaSchema
VERSION = '0.3.17'
VERSION = '0.3.18'
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment