app/helpers/crud_helper.rb in templus_models-1.6.9 vs app/helpers/crud_helper.rb in templus_models-2.0.0
- old
+ new
@@ -59,16 +59,17 @@
params[:action] == "query"
end
def render_link(link,url)
+ nome_modelo = I18n.t("model.#{link[:modelo].underscore}")
if link[:partial].present?
render link[:partial]
elsif link[:link].present?
- link_to "#{gen_icon(link[:icon])} #{link[:text]}".html_safe, "#{url}/#{link[:link]}", class: link[:class], data: data(link)
+ link_to "#{gen_icon(link[:icon])} #{I18n.t(link[:text], model: nome_modelo)}".html_safe, "#{url}/#{link[:link]}", class: link[:class], data: data(link)
else
- link_to "#{gen_icon(link[:icon])} #{link[:text]}".html_safe, link[:url], class: link[:class], data: data(link)
+ link_to "#{gen_icon(link[:icon])} #{I18n.t(link[:text], model: nome_modelo)}".html_safe, link[:url], class: link[:class], data: data(link)
end
end
def gen_icon(i)
if i
@@ -117,10 +118,11 @@
def render_field(field,f,modelo,record)
field[:sf][:wrapper] ||= :default
if field[:sf].present? && field[:sf][:if].present?
return unless field[:sf][:if].call(f.object)
end
+ field[:sf][:hint] = false if field[:sf].present? && !field[:sf][:hint].present?
if field[:sf].present? && field[:sf][:date_format].present? && f.object.send(field[:attribute]).present? && Date <= modelo.columns_hash[field[:attribute].to_s].type.to_s.camelcase.constantize
field[:sf][:input_html] ||= {}
field[:sf][:input_html][:value] = f.object.send(field[:attribute]).strftime(field[:sf][:date_format])
end
if !field[:sf][:edit].nil? || !field[:sf][:create].nil?
@@ -169,11 +171,15 @@
!(video?(file) || imagem?(file))
end
def render_field_file(field)
if imagem?(field) && field.url(:thumb)
- image_tag(field.url(:thumb))
+ if is_active_action("printing")
+ wicked_pdf_image_tag(field.url(:thumb))
+ else
+ image_tag(field.url(:thumb))
+ end
elsif video?(field)
link_to field, field.url, target: "_blank"
else
link_to field, field.url, target: "_blank"
end
@@ -208,7 +214,25 @@
def should_listing?(crud_helper,model)
return false unless can?(:read, model)
return true if crud_helper.condition_listing_action.nil?
crud_helper.condition_listing_action.call(model)
+ end
+
+ def should_listing_excel?(crud_helper,model)
+ return false unless can?(:read, model)
+ return true if crud_helper.condition_listing_excel.nil?
+ crud_helper.condition_listing_excel.call(model)
+ end
+
+ def should_listing_pdf?(crud_helper,model)
+ return false unless can?(:read, model)
+ return true if crud_helper.condition_listing_pdf.nil?
+ crud_helper.condition_listing_pdf.call(model)
+ end
+
+ def should_printing?(crud_helper,record)
+ return false unless can?(:read, record)
+ return true if crud_helper.condition_printing_action.nil?
+ crud_helper.condition_printing_action.call(record)
end
end