Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#785 Differentiate smart group from regular group using icon in select2 field #17927

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Jul 23, 2020

Overview

Currently, there is no way to tell which group is smart or regular group from UI. It would be ideal to use icon against such smart group options to differentiate them from regular ones. This patch appends an icon against smart group option of the select2 widget

https://lab.civicrm.org/dev/core/-/issues/785

Before

Screen Shot 2019-04-04 at 5 54 08 PM

Screen Shot 2019-04-04 at 5 46 34 PM

After

Screen Shot 2019-04-04 at 5 42 38 PM

Screen Shot 2019-04-04 at 5 43 13 PM

Comments

resubmitted PR after fixing the regression encountered in https://lab.civicrm.org/dev/core/-/issues/1888

ping @eileenmcnaughton @demeritcowboy @lcdservices

@civibot
Copy link

civibot bot commented Jul 23, 2020

(Standard links)

@civibot civibot bot added the master label Jul 23, 2020
@demeritcowboy
Copy link
Contributor

Thanks @monishdeb the fatal is gone but it still has the error where it doesn't show the group when editing an existing contact who has a group, e.g. http://core-17927-5hal8.test-1.civicrm.org:8001/civicrm/contact/add?reset=1&action=update&cid=204, with the warning about htmlspecialchars.

@monishdeb
Copy link
Member Author

Thanks @demeritcowboy for pointing that issue. I have updated the PR. Please have a look now.

@demeritcowboy
Copy link
Contributor

  1. One of the errors from before is still there it just takes more work to get to it now. See also https://github.com/civicrm/civicrm-core/pull/17877/files which is where I started on this error before if that helps.
    a. Find or create a contact that has a group assigned.
    b. Edit the contact and in the tags and groups section at the bottom of the form remove all the groups. It doesn't remove the group(s) and you get warnings:

    1. Warning: array_key_exists() expects parameter 2 to be array, string given in CRM_Contact_Form_Contact->postProcess() (line 952 of .../CRM/Contact/Form/Contact.php).
    2. Warning: Invalid argument supplied for foreach() in CRM_Contact_BAO_Contact::create() (line 309 of .../CRM/Contact/BAO/Contact.php).
  2. There's also a line missing but it's my fault because the first revert wasn't clean. You want to put this line back to get the star to appear on the mailing form: https://github.com/civicrm/civicrm-core/pull/13958/files#diff-f295dee2f5355df7c28f695ba8757d00R103

  3. Also can you squash commits?

$hierarchy[$group['id']] = [
'title' => $spaces . $group['title'],
$hierarchy[] = array(
'id' => $group['id'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The array() syntax seems to have come back. While I personally prefer array() the civi standard is now square brackets.

$group = $params['group'] ?? NULL;
if (!empty($group) && is_array($group)) {
$group = CRM_Utils_Array::value('group', $params);
if (!empty($group)) {
Copy link
Contributor

@demeritcowboy demeritcowboy Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRM_Utils_Array::value is being mercilessly removed everywhere in civi. So it should be the original line $group = $params['group'] ?? NULL;

@monishdeb
Copy link
Member Author

@demeritcowboy thanks for your thorough code review. I have fixed all the issues you have raised. Please have a look now.

@@ -102,7 +102,7 @@ public static function buildQuickForm(
}

if ($groupElementType == 'select') {
$groupsOptions[$id] = $group['title'];
$groupsOptions[$id] = $group;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have one more thing: line 109 just below also needs title removed, e.g. if you add Group to a profile.

Copy link
Member Author

@monishdeb monishdeb Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demeritcowboy actually its fine, because its affecting only the group select widget, which now takes the array of information instead of just group title, as now we are supporting select2. The reason why the entire $group array is set, Whereas for advanced checkbox widget, it still needs only the group title as per old behaivour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try adding group to a profile though and then using the profile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops my bad ... updated now

@demeritcowboy
Copy link
Contributor

Ok thanks looks good there's just the title note above.

I think the block in CRM/Contact/Form/Contact.php can be simplified but it works as-is so can leave for some other time.

This reverts commit ba2ad46.
@demeritcowboy
Copy link
Contributor

Looks good. I'm done.

@eileenmcnaughton
Copy link
Contributor

OK thanks for all your review on this @demeritcowboy

@eileenmcnaughton eileenmcnaughton merged commit f9b3598 into civicrm:master Jul 27, 2020
@eileenmcnaughton eileenmcnaughton deleted the core-785 branch July 27, 2020 19:36
@monishdeb
Copy link
Member Author

Thanks a lot, @demeritcowboy for thoroughly reviewing this patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants