Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated price policies index to correctly show edit links.

  • Loading branch information...
commit 110557f41f31ac49316f5315d82cf88c1420a31e 1 parent 8bd1bb3
@johntxi johntxi authored
View
4 app/models/price_policy.rb
@@ -120,6 +120,10 @@ def before_create
self.expire_date=self.class.generate_expire_date(self) unless expire_date
end
+ def editable?
+ !expired? && !assigned_to_order?
+ end
+
# def self.active(product)
# policies = product.send("#{product.class.name.downcase}_price_policies")
# max = nil
View
2  app/views/instrument_price_policies/_table.html.haml
@@ -15,7 +15,7 @@
- if instrument_price_policies.first == price_policy
%td.centered{ :rowspan => instrument_price_policies.length }
%ul.form
- - if !editable && price_policy.assigned_to_order?
+ - unless instrument_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
View
4 app/views/instrument_price_policies/index.html.haml
@@ -18,11 +18,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
- unless @next_dates.empty?
%h2 Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = InstrumentPricePolicy.for_date(@instrument, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
View
2  app/views/item_price_policies/_table.html.haml
@@ -12,7 +12,7 @@
- if item_price_policies.first == price_policy
%td.centered{ :rowspan => item_price_policies.length }
%ul.form
- - if !editable && price_policy.assigned_to_order?
+ - unless item_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
View
4 app/views/item_price_policies/index.html.haml
@@ -19,11 +19,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
- unless @next_dates.empty?
%h2== Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = ItemPricePolicy.for_date(@item, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :item_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :item_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
View
2  app/views/service_price_policies/_table.html.haml
@@ -12,7 +12,7 @@
- if service_price_policies.first == price_policy
%td.centered{ :rowspan => service_price_policies.length }
%ul.form
- - if !editable && price_policy.assigned_to_order?
+ - unless service_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
View
4 app/views/service_price_policies/index.html.haml
@@ -18,11 +18,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
- unless @next_dates.empty?
%h2 Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = ServicePricePolicy.for_date(@service, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
- = render :partial => "table", :locals => { :service_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
+ = render :partial => "table", :locals => { :service_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
Please sign in to comment.
Something went wrong with that request. Please try again.