Editing a smartgroup created through the search builder renders the new block by force
Overview
When you edit an existing smartgroup created with the Search Builder, the new block of record type/operator is always rendering by force. This causes inconvenience (and confusion) to the end user, as they try to 'Search' to see the results but end up with the form rule validation informing them that they need to populate some parameters. In order to bypass this, they need to clear the new line (new block). This behaviour is there since a long time now, we just got complains lately about that.
Reproduction steps
Create a smartgroup through the searchbuilder and save it:
- Search -> Search builder
- Set some basic filters like : Contacts -> Contact type = Individual and do the search
- All x records -> Action: Group: Create smartgroup and give it a temporary name
Now go to find your existing smartgroup:
- Contacts -> Manage groups
- on the 'Find', type your temporary name that you gave and once it's being displayed, go to 'Settings' (right part)
- On the popup page, select the last link: 'Edit smart group criteria'
The '-select record type-' and '-operator-' are rendering by default. In order to search, you need to take them out first.
Current behaviour
The new record type/operator line is now appearing on either an existing smartgroup done via the searchbuilder or on a new searchbuilder form
Expected/suggested behaviour
The new record type + operator line should appear only on the new searchbuilder form
Comments
I believe the easiest way to fix this is to check if we have any ssID value here. If we do have an ssID then this means that we are editing an existing smartgroup and not creating a new one.
for example this:
// Initialize new form
if (!$this->_blockCount) {
$this->_blockCount = 4;
$this->set('newBlock', 1);
}
should be something like this:
// Initialize new form
if (!$this->_blockCount) {
$this->_blockCount = 4;
if (!$this->_ssID) {
$this->set('newBlock', 1);
}
}
Can anyone see a downside on doing this?