PropertyModifierRejectOrSelect: usability

This also introduces a new Form helper method -> getSetting

fixes #2228
This commit is contained in:
Thomas Gelf 2020-11-25 02:53:29 +01:00
parent 935f8d6b09
commit b8ab90f135
3 changed files with 44 additions and 10 deletions

View File

@ -102,6 +102,26 @@ class ImportRowModifierForm extends DirectorObjectForm
$this->setButtons(); $this->setButtons();
} }
public function getSetting($name, $default = null)
{
if ($this->hasBeenSent()) {
$value = $this->getSentValue($name);
if ($value !== null) {
return $value;
}
}
if ($this->isNew()) {
$value = $this->getElement($name)->getValue();
if ($value === null) {
return $default;
}
return $value;
}
return $this->object()->getSetting($name, $default);
}
/** /**
* @return ImportSourceHook * @return ImportSourceHook
* @throws ConfigurationError * @throws ConfigurationError

View File

@ -31,6 +31,7 @@ next (will be 1.8.0)
* FEATURE: Property Modifier: skip duplicates (#2215) * FEATURE: Property Modifier: skip duplicates (#2215)
* FEATURE: Property Modifier: trim strings (#1660) * FEATURE: Property Modifier: trim strings (#1660)
* FEATURE: Property Modifier: negate boolean (#2227) * FEATURE: Property Modifier: negate boolean (#2227)
* FEATURE: Property Modifier Reject/Select: improve usability (#2228)
* FEATURE: Import Sources now allows downloading previewed data as JSON (#2096) * FEATURE: Import Sources now allows downloading previewed data as JSON (#2096)
* FEATURE: UTF8 validation for failed imports gives better error message (#2143) * FEATURE: UTF8 validation for failed imports gives better error message (#2143)
* FEATURE: ArrayByElementPosition now allows filtering by key name (#1721) * FEATURE: ArrayByElementPosition now allows filtering by key name (#1721)

View File

@ -37,16 +37,29 @@ class PropertyModifierRejectOrSelect extends PropertyModifierHook
'class' => 'autosubmit', 'class' => 'autosubmit',
]); ]);
$method = $form->getSetting('filter_method');
switch ($method) {
case 'wildcard':
$form->addElement('text', 'filter_string', [ $form->addElement('text', 'filter_string', [
'label' => $form->translate('Filter'), 'label' => $form->translate('Filter'),
'description' => $form->translate( 'description' => $form->translate(
'The string/pattern you want to search for. Depends on the' 'The string/pattern you want to search for, use wildcard'
. ' chosen method, use www.* or *linux* for wildcard matches' . ' matches like www.* or *linux*'
. ' and expression like /^www\d+\./ in case you opted for a'
. ' regular expression'
), ),
'required' => true, 'required' => true,
]); ]);
break;
case 'regex':
$form->addElement('text', 'filter_string', [
'label' => $form->translate('Filter'),
'description' => $form->translate(
'The string/pattern you want to search for, use regular'
. ' expression like /^www\d+\./'
),
'required' => true,
]);
break;
}
$form->addElement('select', 'policy', [ $form->addElement('select', 'policy', [
'label' => $form->translate('Policy'), 'label' => $form->translate('Policy'),