aboutsummaryrefslogtreecommitdiff
path: root/timepollhead.rb
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-12-30 23:53:09 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-12-30 23:53:09 +0100
commitc60d8de4cc1765306f3b2c6d6a87f2a747dce734 (patch)
tree9bfba3c30883568ef648402c18735aee491cf64c /timepollhead.rb
parentf02429c0c406796ab7943d458c4be097b65ebdd2 (diff)
bugfix: add empty column if last concrete one is deleted
Diffstat (limited to '')
-rw-r--r--timepollhead.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/timepollhead.rb b/timepollhead.rb
index de1845f..5922986 100644
--- a/timepollhead.rb
+++ b/timepollhead.rb
@@ -56,21 +56,28 @@ class TimePollHead
ret
end
+ # deletes one concrete column
+ # adds the empty day, if it was the last concrete time of the day
+ # returns true if deletion successful
+ def delete_concrete_column(col)
+ ret = @data.delete(col) != nil
+ @data << TimeString.new(col.date,nil) unless date_included?(col.date)
+ ret
+ end
+
# column is in human readable form
- # returns true if deletion sucessfull
+ # returns true if deletion successful
def delete_column(column)
if $cgi.include?("togglealloff") # delete one time
head_count("%Y-%m-%d",false).each{|day,num|
- @data.delete(TimeString.new(day,column))
+ delete_concrete_column(TimeString.new(day,column))
}
return true
end
col = TimeString.from_s(column)
if col.time
- ret = @data.delete(TimeString.from_s(column)) != nil
- @data << TimeString.new(col.date,nil) unless date_included?(col.date)
- return ret
- else
+ return delete_concrete_column(col)
+ else # delete all concrete times on the given day
deldata = []
@data.each{|ts|
deldata << ts if ts.date == col.date