Added toggle for the fixed cost, #1135
This commit is contained in:
1 parent
8548d46637
commit
bdec36e7ea
2 files changed
+24
-2
No files matched your search
@@ -9,6 +9,7 @@ class Deliverable < ActiveRecord::Base
|
|||||||
attr_accessor :profit
|
attr_accessor :profit
|
||||||
attr_accessor :cost_per_hour
|
attr_accessor :cost_per_hour
|
||||||
attr_accessor :total_hours
|
attr_accessor :total_hours
|
||||||
|
attr_accessor :fixed_cost
|
||||||
|
|
||||||
# TODO: mocked
|
# TODO: mocked
|
||||||
def score
|
def score
|
||||||
|
|||||||
@@ -21,16 +21,23 @@
|
|||||||
<label for="deliverable_type">Fixed Cost</label>
|
<label for="deliverable_type">Fixed Cost</label>
|
||||||
<%= check_box(:deliverable, :type, {}, FixedDeliverable.name, HourlyDeliverable.name) %>
|
<%= check_box(:deliverable, :type, {}, FixedDeliverable.name, HourlyDeliverable.name) %>
|
||||||
</p>
|
</p>
|
||||||
|
<%= observe_field('deliverable_type', :function => "new Budget.changeType();") %>
|
||||||
|
|
||||||
<p><%= f.text_field :cost_per_hour, :size => 7 %></p>
|
<p class="budget-hourly"><%= f.text_field :cost_per_hour, :size => 7 %></p>
|
||||||
<%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %>
|
<%= observe_field('deliverable_cost_per_hour', :function => "new Budget.updateAmounts();") %>
|
||||||
|
|
||||||
<p>
|
<p class="budget-hourly">
|
||||||
<%= f.text_field :total_hours, :size => 7 %>
|
<%= f.text_field :total_hours, :size => 7 %>
|
||||||
<%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %>
|
<%= content_tag(:span, 0, :class => "budget-calculation", :id => 'variableCost') %>
|
||||||
</p>
|
</p>
|
||||||
<%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %>
|
<%= observe_field('deliverable_total_hours', :function => "new Budget.updateAmounts();") %>
|
||||||
|
|
||||||
|
<p class="budget-fixed" style="display:none;">
|
||||||
|
<%= f.text_field :fixed_cost, :size => 7 %>
|
||||||
|
<%= content_tag(:span, 0, :class => "budget-calculation", :id => 'fixedCost') %>
|
||||||
|
</p>
|
||||||
|
<%= observe_field('deliverable_fixed_cost', :function => "new Budget.updateAmounts();") %>
|
||||||
|
|
||||||
<%= field_with_budget_observer_and_totals(f, :overhead) %>
|
<%= field_with_budget_observer_and_totals(f, :overhead) %>
|
||||||
<%= field_with_budget_observer_and_totals(f, :materials) %>
|
<%= field_with_budget_observer_and_totals(f, :materials) %>
|
||||||
<%= field_with_budget_observer_and_totals(f, :profit) %>
|
<%= field_with_budget_observer_and_totals(f, :profit) %>
|
||||||
@@ -122,6 +129,20 @@ Object.extend(BudgetModule.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changeType: function() {
|
||||||
|
if ($('deliverable_type').checked) {
|
||||||
|
// Fixed
|
||||||
|
$$('.budget-hourly').each(function(ele) { ele.hide(); });
|
||||||
|
$$('.budget-fixed').each(function(ele) { ele.show(); });
|
||||||
|
} else {
|
||||||
|
// Variable
|
||||||
|
$$('.budget-hourly').each(function(ele) { ele.show(); });
|
||||||
|
$$('.budget-fixed').each(function(ele) { ele.hide(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
Budget.updateAmounts();
|
||||||
|
},
|
||||||
|
|
||||||
// Rails-like number_to_currency currency formatting
|
// Rails-like number_to_currency currency formatting
|
||||||
// http://snippets.dzone.com/posts/show/4646
|
// http://snippets.dzone.com/posts/show/4646
|
||||||
number_to_currency: function (number, options) {
|
number_to_currency: function (number, options) {
|
||||||
|
|||||||
Reference in new issue
Block a user