supplier improvements
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
module ProductCategoryDecorator
|
||||
|
||||
def products
|
||||
#ProductDecorator.decorate_collection(model.products)
|
||||
@decorated_products ||= ActiveDecorator::Decorator.instance.decorate(super)
|
||||
end
|
||||
|
||||
def visible_on
|
||||
sum = week_days.sum
|
||||
return content_tag(:span, '', class: 'icon-eye-close icon-white') if sum.zero?
|
||||
return content_tag(:span, '', class: 'icon-refresh icon-white') if sum == 7 && full_day
|
||||
day_names = I18n.t('date.day_names')
|
||||
days = week_days.map.with_index{|v,i| v == 1 ? day_names[i] : nil}.compact
|
||||
days << days.shift if week_days.first == 1 && supplier.week_starts_on_monday?
|
||||
days = days.join(', ')
|
||||
unless full_day
|
||||
from_time = start_from
|
||||
from_time -= 1440 if from_time > 1440
|
||||
from_hour = from_time / 60.0
|
||||
to_time = end_on
|
||||
to_time -= 1440 if to_time > 1440
|
||||
to_hour = to_time / 60.0
|
||||
time_display = "#{from_hour.floor}:#{'%02d' % (from_hour.modulo(1) * 60)} - #{to_hour.floor}:#{'%02d' % (to_hour.modulo(1)*60)}"
|
||||
return time_display if sum == 7
|
||||
days << " #{time_display}"
|
||||
end
|
||||
days
|
||||
end
|
||||
end
|
||||
@@ -1,17 +1,15 @@
|
||||
class ProductDecorator < Draper::Decorator
|
||||
decorates :product
|
||||
delegate_all
|
||||
module ProductDecorator
|
||||
|
||||
def category_links(options = {})
|
||||
if namespace = options[:namespace]
|
||||
product_categories.map{|pc| h.link_to pc.name, [namespace, pc]}.join(', ').html_safe
|
||||
product_categories.map{|pc| link_to pc.name, [namespace, pc]}.join(', ').html_safe
|
||||
else
|
||||
product_categories.map{|pc| h.link_to pc.name, pc}.join(', ').html_safe
|
||||
product_categories.map{|pc| link_to pc.name, pc}.join(', ').html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def display
|
||||
"#{model.name} (#{h.currency(model.price)})".html_safe
|
||||
"#{name} (#{currency(price)})".html_safe
|
||||
end
|
||||
|
||||
# Accessing Helpers
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module SupplierDecorator
|
||||
def products
|
||||
ActiveDecorator::Decorator.instance.decorate super
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user