Added TimelineNew router; synced CustomerNew stuff.
This commit is contained in:
parent
06a4cafe02
commit
a2de4fa6fd
43
stoptime.rb
43
stoptime.rb
|
@ -299,6 +299,8 @@ module StopTime::Controllers
|
||||||
@customer.save
|
@customer.save
|
||||||
if @customer.invalid?
|
if @customer.invalid?
|
||||||
@errors = @customer.errors
|
@errors = @customer.errors
|
||||||
|
@target = [Customer]
|
||||||
|
@button = "create"
|
||||||
return render :customer_form
|
return render :customer_form
|
||||||
end
|
end
|
||||||
redirect R(Customers)
|
redirect R(Customers)
|
||||||
|
@ -309,7 +311,10 @@ module StopTime::Controllers
|
||||||
def get
|
def get
|
||||||
# FIXME: set other defaults?
|
# FIXME: set other defaults?
|
||||||
@customer = Customer.new(:hourly_rate => HourlyRate)
|
@customer = Customer.new(:hourly_rate => HourlyRate)
|
||||||
|
@input = @customer.attributes
|
||||||
|
|
||||||
@target = [Customers]
|
@target = [Customers]
|
||||||
|
@button = "create"
|
||||||
render :customer_form
|
render :customer_form
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -321,6 +326,7 @@ module StopTime::Controllers
|
||||||
@input = @customer.attributes
|
@input = @customer.attributes
|
||||||
|
|
||||||
@target = [CustomersN, @customer.id]
|
@target = [CustomersN, @customer.id]
|
||||||
|
@button = "update"
|
||||||
@edit_task = true
|
@edit_task = true
|
||||||
render :customer_form
|
render :customer_form
|
||||||
end
|
end
|
||||||
|
@ -566,8 +572,8 @@ module StopTime::Controllers
|
||||||
def get
|
def get
|
||||||
@time_entries = TimeEntry.all(:order => "start DESC")
|
@time_entries = TimeEntry.all(:order => "start DESC")
|
||||||
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
||||||
@task_list = Task.all(:conditions => ['invoice_id IS NULL']).map do
|
@task_list = Task.all.reject { |t| t.billed? }.map do |t|
|
||||||
|t| [t.id, t.name]
|
[t.id, t.name]
|
||||||
end
|
end
|
||||||
@input["bill"] = true # Bill by default.
|
@input["bill"] = true # Bill by default.
|
||||||
render :time_entries
|
render :time_entries
|
||||||
|
@ -585,14 +591,24 @@ module StopTime::Controllers
|
||||||
if @time_entry.invalid?
|
if @time_entry.invalid?
|
||||||
@errors = @time_entry.errors
|
@errors = @time_entry.errors
|
||||||
end
|
end
|
||||||
elsif @input.has_key? "delete"
|
|
||||||
end
|
end
|
||||||
|
redirect R(Timeline)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@time_entries = TimeEntry.all(:order => "start DESC")
|
class TimelineNew
|
||||||
|
def get
|
||||||
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
||||||
@task_list = Task.all.map { |t| [t.id, t.name] }
|
@task_list = Task.all.reject { |t| t.billed? }.map do |t|
|
||||||
@input["bill"] = true # Bill by default.
|
[t.id, t.name]
|
||||||
render :time_entries
|
end
|
||||||
|
@input["bill"] = true
|
||||||
|
@input["start"] = DateTime.now.to_formatted_s
|
||||||
|
@input["end"] = DateTime.now.to_date.to_formatted_s + " "
|
||||||
|
|
||||||
|
@target = [Timeline]
|
||||||
|
@button = "enter"
|
||||||
|
render :time_entry_form
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -603,7 +619,12 @@ module StopTime::Controllers
|
||||||
@input["customer"] = @time_entry.task.customer.id
|
@input["customer"] = @time_entry.task.customer.id
|
||||||
@input["task"] = @time_entry.task.id
|
@input["task"] = @time_entry.task.id
|
||||||
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
@customer_list = Customer.all.map { |c| [c.id, c.short_name] }
|
||||||
@task_list = Task.all.map { |t| [t.id, t.name] }
|
@task_list = Task.all.reject { |t| t.billed? }.map do |t|
|
||||||
|
[t.id, t.name]
|
||||||
|
end
|
||||||
|
|
||||||
|
@target = [TimelineN, entry_id]
|
||||||
|
@button = "update"
|
||||||
render :time_entry_form
|
render :time_entry_form
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -820,7 +841,7 @@ module StopTime::Views
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_entry_form
|
def time_entry_form
|
||||||
form :action => R(TimelineN, @time_entry.id), :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"
|
||||||
|
@ -839,7 +860,7 @@ module StopTime::Views
|
||||||
end
|
end
|
||||||
# FIXME: link to invoice if any
|
# FIXME: link to invoice if any
|
||||||
end
|
end
|
||||||
input :type => "submit", :name => "update", :value => "Update"
|
input :type => "submit", :name => @button, :value => @button.capitalize
|
||||||
input :type => "submit", :name => "cancel", :value => "Cancel"
|
input :type => "submit", :name => "cancel", :value => "Cancel"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -888,7 +909,7 @@ module StopTime::Views
|
||||||
li { _form_input_with_label("Phone number", "phone", :text) }
|
li { _form_input_with_label("Phone number", "phone", :text) }
|
||||||
li { _form_input_with_label("Hourly rate", "hourly_rate", :text) }
|
li { _form_input_with_label("Hourly rate", "hourly_rate", :text) }
|
||||||
end
|
end
|
||||||
input :type => "submit", :name => "update", :value => "Update"
|
input :type => "submit", :name => @button, :value => @button.capitalize
|
||||||
input :type => "submit", :name => "cancel", :value => "Cancel"
|
input :type => "submit", :name => "cancel", :value => "Cancel"
|
||||||
end
|
end
|
||||||
if @edit_task
|
if @edit_task
|
||||||
|
|
Loading…
Reference in New Issue