Merge branch 'support/camping-2.2' into development (closes: #804d96)

This commit is contained in:
Paul van Tilburg 2012-06-06 11:41:00 +02:00
commit c6a19ec15a
2 changed files with 36 additions and 34 deletions

8
README
View file

@ -18,11 +18,11 @@ invoicing.
Stop… Camping Time! is a Camping application, so you need: Stop… Camping Time! is a Camping application, so you need:
* Ruby 1.8 (>= 1.8.6) or 1.9 (>= 1.9.1) * Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3)
* Camping (>= 2.0) with * Camping (>= 2.2) with
* Active Record (>= 2.3) * Active Record (>= 2.3)
* Markaby, and optionally: * Mab (>= 0.0.1) , and optionally:
* Mongrel (for testing and deployment without Apache/Rackup) * Thin or Mongrel (for testing and deployment without Apache/Rackup)
The following Ruby libraries are required: The following Ruby libraries are required:

View file

@ -12,11 +12,11 @@
require "action_view" require "action_view"
require "active_support" require "active_support"
require "camping" require "camping"
require "markaby" require "camping/mab"
require "camping/ar"
require "pathname" require "pathname"
require "sass/plugin/rack" require "sass/plugin/rack"
Markaby::Builder.set(:indent, 2)
Camping.goes :StopTime Camping.goes :StopTime
unless defined? PUBLIC_DIR unless defined? PUBLIC_DIR
@ -77,22 +77,24 @@ module StopTime
end end
# = The Stop… Camping Time! Markaby extensions # = The Stop… Camping Time! Markaby extensions
module StopTime::Helpers module StopTime::Mab
SUPPORTED = [:get, :post] SUPPORTED = [:get, :post]
# Adds a method override field in form tags for (usually) unsupported def mab_done(tag)
# methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. return super unless tag.name == :form
def tag!(tag, *attrs)
return super unless tag == :form && block_given? meth = tag.attributes[:method]
attrs = attrs.last.is_a?(Hash) ? attrs.last : {} tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth)
meth = attrs[:method] # Inject a hidden input element with the proper method to the tag block
attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) # if the form method is unsupported.
super(tag, attrs) do tag.block do |orig_blk|
input :type => 'hidden', :name => '_method', :value => meth if override input :type => 'hidden', :name => '_method', :value => meth
yield orig_blk.call
end end if override
end end
include Mab::Indentation
end end
# = The Stop… Camping Time! models # = The Stop… Camping Time! models
@ -1343,7 +1345,7 @@ module StopTime::Views
# The main layout used by all views. # The main layout used by all views.
def layout def layout
xhtml_strict do html do
head do head do
title "Stop… Camping Time!" title "Stop… Camping Time!"
# FIXME: improve static serving so that the hack below is not needed. # FIXME: improve static serving so that the hack below is not needed.
@ -1377,8 +1379,8 @@ module StopTime::Views
h3 { a customer.name, :href => R(CustomersN, customer.id) } h3 { a customer.name, :href => R(CustomersN, customer.id) }
if @tasks[customer].empty? if @tasks[customer].empty?
p do p do
text "No projects/tasks found! Create one " + text! "No projects/tasks found! Create one " +
"#{a "here", :href => R(CustomersNTasksNew, customer.id)}." "#{a "here", :href => R(CustomersNTasksNew, customer.id)}."
end end
else else
table.overview do table.overview do
@ -1409,7 +1411,7 @@ module StopTime::Views
# FIXME: This should be done in a nicer way. # FIXME: This should be done in a nicer way.
def time_entries(task_id=nil) def time_entries(task_id=nil)
if task_id.present? if task_id.present?
h2 "Registered #{task.billed? ? "billed" : "unbilled"} time" h2 "Registered #{@task.billed? ? "billed" : "unbilled"} time"
else else
h2 "Timeline" h2 "Timeline"
end end
@ -1499,7 +1501,7 @@ module StopTime::Views
"what you are doing!" "what you are doing!"
end end
end end
form :action => R(*target), :method => :post do form :action => R(*@target), :method => :post do
ol do ol do
li do li do
label "Customer", :for => "customer" label "Customer", :for => "customer"
@ -1537,8 +1539,8 @@ module StopTime::Views
h2 "Customers" h2 "Customers"
if @customers.empty? if @customers.empty?
p do p do
text "None found! You can create one " + text! "None found! You can create one " +
"#{a "here", :href => R(CustomersNew)}." "#{a "here", :href => R(CustomersNew)}."
end end
else else
table.customers do table.customers do
@ -1561,10 +1563,10 @@ module StopTime::Views
td { customer.short_name || ""} td { customer.short_name || ""}
td do td do
if customer.address_street.present? if customer.address_street.present?
text customer.address_street text! customer.address_street
br br
text customer.address_postal_code + " " + text! customer.address_postal_code + " " +
customer.address_city customer.address_city
else else
"" ""
end end
@ -1652,7 +1654,7 @@ module StopTime::Views
p.warn do p.warn do
em "This task is already billed! Only make changes if you know " + em "This task is already billed! Only make changes if you know " +
"what you are doing!" "what you are doing!"
end if task.billed? end if @task.billed?
form :action => R(*@target), :method => :post do form :action => R(*@target), :method => :post do
ol do ol do
li do li do
@ -1674,7 +1676,7 @@ module StopTime::Views
end end
end end
end end
if task.billed? if @task.billed?
li do li do
label "Billed in invoice" label "Billed in invoice"
a @task.invoice.number, a @task.invoice.number,
@ -1698,8 +1700,8 @@ module StopTime::Views
if @invoices.values.flatten.empty? if @invoices.values.flatten.empty?
p do p do
text "Found none! You can create one by " text! "Found none! You can create one by "
"#{a "selecting a customer", :href => R(Customers)}." "#{a "selecting a customer", :href => R(Customers)}."
end end
else else
@invoices.keys.sort.each do |key| @invoices.keys.sort.each do |key|
@ -1761,7 +1763,7 @@ module StopTime::Views
tr do tr do
td do td do
a task.comment_or_name, a task.comment_or_name,
:href => R(CustomersNTasksN, customer.id, task.id) :href => R(CustomersNTasksN, task.customer.id, task.id)
end end
if line[1].blank? if line[1].blank?
# FIXME: information of time spent is available in the summary # FIXME: information of time spent is available in the summary
@ -1987,7 +1989,7 @@ module StopTime::Views
# menu item. # menu item.
def _menu_link(label, ctrl) def _menu_link(label, ctrl)
# FIXME: dirty hack? # FIXME: dirty hack?
if self.helpers.class.to_s.match(/^#{ctrl.to_s}/) if self.class.to_s.match(/^#{ctrl.to_s}/)
li.selected { a label, :href => R(ctrl) } li.selected { a label, :href => R(ctrl) }
else else
li { a label, :href => R(ctrl) } li { a label, :href => R(ctrl) }