Module: check_mk
Branch: master
Commit: d540962903e299d70b38b5d3322ae993aff9f040
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d540962903e299…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 11 08:41:42 2016 +0100
#3048 FIX It is now possible to add a context filter right after removing it from a view
again
The view editor had a bug which made it impossible to add a context filter again after
removing it from the view when it was already in the view during loading of the view
editor. It could be worked around by saving the view and opening up the editor again
to add the filter again.
---
.werks/3048 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/js/checkmk.js | 18 +++++++++++++++++-
web/htdocs/valuespec.py | 2 +-
web/htdocs/visuals.py | 3 ++-
5 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/.werks/3048 b/.werks/3048
new file mode 100644
index 0000000..0797333
--- /dev/null
+++ b/.werks/3048
@@ -0,0 +1,12 @@
+Title: It is now possible to add a context filter right after removing it from a view
again
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i4
+Date: 1455176396
+Class: fix
+
+The view editor had a bug which made it impossible to add a context filter again after
+removing it from the view when it was already in the view during loading of the view
+editor. It could be worked around by saving the view and opening up the editor again
+to add the filter again.
diff --git a/ChangeLog b/ChangeLog
index 82ca4ab..8497636 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -318,6 +318,7 @@
* 3046 FIX: Acknowledging all incompatible werks when creating new sites
* 2931 FIX: Do not load bookmarks, reports, view, etc. of non-existing users anymore
* 3171 FIX: Logout in one site will log out of all sites sharing the same
auth.secret...
+ * 3048 FIX: It is now possible to add a context filter right after removing it from a
view again...
WATO:
* 2442 WATO remove host: improved cleanup of obsolete host files...
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 2050463..3b82665 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2069,7 +2069,9 @@ function vs_listofmultiple_toggle_fields(root, varprefix, enable) {
function vs_listofmultiple_init(varprefix) {
document.getElementById(varprefix + '_choice').value = '';
- // Mark fields of unused elements as disabled
+ vs_listofmultiple_disable_selected_options(varprefix);
+
+ // Mark input fields of unused elements as disabled
var container = document.getElementById(varprefix + '_table');
var unused = document.getElementsByClassName('unused', container);
for (var i in unused) {
@@ -2077,6 +2079,20 @@ function vs_listofmultiple_init(varprefix) {
}
}
+// The <option> elements in the <select> field of the currently choosen
+// elements need to be disabled.
+function vs_listofmultiple_disable_selected_options(varprefix)
+{
+ var active_choices = document.getElementById(varprefix +
'_active').value.split(";");
+
+ var choice_field = document.getElementById(varprefix + '_choice');
+ for (var i = 0; i < choice_field.childNodes.length; i++) {
+ if (active_choices.indexOf(choice_field.childNodes[i].value) !== -1) {
+ choice_field.childNodes[i].disabled = true;
+ }
+ }
+}
+
//#.
//# .-Help Toggle--------------------------------------------------------.
//# | _ _ _ _____ _ |
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 68090c5..451a918 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1081,7 +1081,7 @@ class ListOfMultiple(ValueSpec):
html.write("</table>")
html.write("<br>")
- choosable = [('', '')] + [ (ident, vs.title()) for ident, vs in
self._choices if ident not in value ]
+ choosable = [('', '')] + [ (ident, vs.title()) for ident, vs in
self._choices ]
attrs = {}
if self._size != None:
attrs["style"] = "width: %dex" % self._size
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 9751459..2b0c763 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1090,7 +1090,7 @@ class VisualFilterList(ListOfMultiple):
self._filters = {}
for info in self._infos:
for fname, filter in filters_allowed_for_info(info).items():
- if fname not in fspecs: # and fname not in ubiquitary_filters:
+ if fname not in fspecs:
fspecs[fname] = VisualFilter(fname,
title = filter.title,
)
@@ -1110,6 +1110,7 @@ class VisualFilterList(ListOfMultiple):
def filter_names(self):
return self._filters.keys()
+
# Realizes a Multisite/visual filter in a valuespec. It can render the filter form, get
# the filled in values and provide the filled in information for persistance.
class VisualFilter(ValueSpec):