Module: check_mk
Branch: master
Commit: 8d18825445e677d91d5002b49156b269cae51d36
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8d18825445e677…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 6 13:41:58 2014 +0100
#1491 FIX Fixed bug in dynamic lists where removing an item was not always possible
We use the so called valuespec ListOf() in several places where a dynamic amount
of elements can be added to a list of things, for example the number of exceptions
of a timeperiod in the timeperiod edit dialog.
Now, when you created a new timeperiod, added one exception and imediately removed
it, you had no chance to save this timeperiod without adding another exception to
the list. This has been fixed now.
---
.werks/1491 | 16 ++++++++++++++++
ChangeLog | 1 +
web/htdocs/valuespec.py | 10 +++++++---
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/.werks/1491 b/.werks/1491
new file mode 100644
index 0000000..ae33d74
--- /dev/null
+++ b/.werks/1491
@@ -0,0 +1,16 @@
+Title: Fixed bug in dynamic lists where removing an item was not always possible
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.5i7
+Date: 1415277372
+
+We use the so called valuespec ListOf() in several places where a dynamic amount
+of elements can be added to a list of things, for example the number of exceptions
+of a timeperiod in the timeperiod edit dialog.
+
+Now, when you created a new timeperiod, added one exception and imediately removed
+it, you had no chance to save this timeperiod without adding another exception to
+the list. This has been fixed now.
diff --git a/ChangeLog b/ChangeLog
index 55d95d7..a2b9d9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@
* 1489 Added iCalendar import for generating timeperiods e.g. for holidays...
* 1165 FIX: Fixed exception in service discovery of logwatch event console forwarding
checks...
* 1490 FIX: Timperiod excludes can now even be configured when creating a
timeperiod...
+ * 1491 FIX: Fixed bug in dynamic lists where removing an item was not always
possible...
Notifications:
* 1168 FIX: HTML mails can now be configured to display graphs among each other...
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index b8e1695..3ab26c8 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -845,7 +845,7 @@ class ListOf(ValueSpec):
# original 'value' but take the value from the HTML variables.
if html.has_var("%s_count" % varprefix):
filled_in = True
- count = int(html.var("%s_count" % varprefix))
+ count = len(self.get_indexes(varprefix))
value = [None] * count # dummy for the loop
else:
filled_in = False
@@ -892,16 +892,20 @@ class ListOf(ValueSpec):
s += '<tr><td>%s</td></tr>' %
self._valuespec.value_to_text(v)
return s + '</table>'
- def from_html_vars(self, varprefix):
+ def get_indexes(self, varprefix):
count = int(html.var(varprefix + "_count"))
n = 1
indexes = {}
while n <= count:
indexof = html.var(varprefix + "_indexof_%d" % n)
- if indexof != None: # deleted entry
+ # for deleted entries, we have removed the whole row, therefore indexof is
None
+ if indexof != None:
indexes[int(indexof)] = n
n += 1
+ return indexes
+ def from_html_vars(self, varprefix):
+ indexes = self.get_indexes(varprefix)
value = []
k = indexes.keys()
k.sort()