Author: Lars Michelsen <[email protected]>
Date: Tue Jul 9 14:15:31 2013 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Tue Jul 9 14:15:31 2013 +0200
Slightly more comfortable editing dropdown fields with multiple possible choices
---
share/server/core/classes/CoreModMap.php | 18 +++++++++++++++---
share/server/core/classes/GlobalMapCfg.php | 3 ++-
share/server/core/classes/WuiViewMapAddModify.php | 18 ++++++++++++++----
share/server/core/mapcfg/default.php | 4 ++++
4 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/share/server/core/classes/CoreModMap.php
b/share/server/core/classes/CoreModMap.php
index 5a2c310..3dce522 100644
--- a/share/server/core/classes/CoreModMap.php
+++ b/share/server/core/classes/CoreModMap.php
@@ -442,9 +442,21 @@ class CoreModMap extends CoreModule {
throw new FieldInputError($key, l('The attribute is
deprecated.'));
// The object has a match regex, it can be checked
- if(isset($attrDefs[$key]['match']) &&
!preg_match($attrDefs[$key]['match'], $val))
- throw new FieldInputError($key, l('The attribute has the wrong
format (Regex: [MATCH]).',
- Array('MATCH' => $attrDefs[$key]['match'])));
+ // -> In case of array attributes validate the single parts
+ if(isset($attrDefs[$key]['match'])) {
+ $array = isset($attrDefs[$key]['array']) &&
$attrDefs[$key]['array'];
+ if(!$array)
+ $v = array($val);
+ else
+ $v = explode(',', $val);
+
+ foreach($v as $part) {
+ if(!preg_match($attrDefs[$key]['match'], $part)) {
+ throw new FieldInputError($key, l('The attribute has
the wrong format (Regex: [MATCH]).',
+ Array('MATCH' => $attrDefs[$key]['match'])));
+ }
+ }
+ }
}
}
diff --git a/share/server/core/classes/GlobalMapCfg.php
b/share/server/core/classes/GlobalMapCfg.php
index 4fde810..0a2ce53 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -556,7 +556,8 @@ class GlobalMapCfg {
if(!$only_customized || $_REQUEST[$key] != $this->getValue(0,
$key)) {
// Only get options which differ from the defaults
// Maybe convert the type, if requested
- if(isset(self::$validConfig['global'][$key]['array']) &&
self::$validConfig['global'][$key]['array'] === true)
+ if(isset(self::$validConfig['global'][$key]['array'])
+ && self::$validConfig['global'][$key]['array'] === true)
return explode(',', $_REQUEST[$key]);
else
return $_REQUEST[$key];
diff --git a/share/server/core/classes/WuiViewMapAddModify.php
b/share/server/core/classes/WuiViewMapAddModify.php
index 3728244..5deb3ad 100644
--- a/share/server/core/classes/WuiViewMapAddModify.php
+++ b/share/server/core/classes/WuiViewMapAddModify.php
@@ -204,8 +204,6 @@ class WuiViewMapAddModify {
|| (isset($prop['deprecated']) && $prop['deprecated'] === true))
continue;
- $isArrayValue = isset($prop['array']) && $prop['array'];
-
list($inherited, $value) = $this->getAttr($typeDefaults, $update,
$propname, $prop['must']);
unset($this->hiddenAttrs[$propname]);
@@ -294,6 +292,7 @@ class WuiViewMapAddModify {
$ret .= $this->selectField($propname, $options, $value,
$hideField, $onChange);
break;
case 'dropdown':
+ $array = isset($prop['array']) && $prop['array'];
// If var is backend_id or var is host_name in service
objects submit the form
// to update the depdant lists.
if($onChange == '' && ($propname == 'backend_id'
@@ -325,12 +324,23 @@ class WuiViewMapAddModify {
// Fallback to an input field when the attribute has
an value which is not
// an option in the select field
if($value != '' && !isset($options[$value])) {
- $this->setError(new FieldInputError($propname,
- l('Current value is not a known option -
falling back to input field.')));
+ // In case of multiple selected the single objects
can not be found, this is ok.
+ if (!$array) {
+ $this->setError(new FieldInputError($propname,
+ l('Current value is not a known option -
falling back to input field.')));
+ }
+
+ if ($propname === 'backend_id' && $value ===
'<<<multiple>>>')
+ $value = '';
+
$ret .= $this->inputField($propname, $value,
$hideField);
break;
}
+ if($array) {
+ $options['<<<multiple>>>'] = l('>>> Select
multiple');
+ }
+
$ret .= $this->selectField($propname, $options,
$value, $hideField, $onChange);
} catch(BackendConnectionProblem $e) {
$this->setError(new FieldInputError($propname,
diff --git a/share/server/core/mapcfg/default.php
b/share/server/core/mapcfg/default.php
index e873341..caf8e1c 100644
--- a/share/server/core/mapcfg/default.php
+++ b/share/server/core/mapcfg/default.php
@@ -102,6 +102,10 @@ function getObjectNames($type, $CORE, $MAPCFG, $objId,
$attrs) {
else
$backendIds = $MAPCFG->getValue($objId, 'backend_id');
+ // Return simply nothing when a user just choosen to insert multiple
backends
+ if(isset($attrs['backend_id']) && $attrs['backend_id'] == '<<<multiple>>>')
+ return array();
+
// Initialize the backend
foreach($backendIds as $backendId) {
$_BACKEND->checkBackendExists($backendId, true);
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins