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 #13958

Merged
merged 3 commits into from
Jul 14, 2020

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Apr 4, 2019

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

ping @colemanw @lcdservices

@civibot civibot bot added the master label Apr 4, 2019
@civibot
Copy link

civibot bot commented Apr 4, 2019

(Standard links)

@mattwire
Copy link
Contributor

mattwire commented Apr 4, 2019

@monishdeb +1 on concept. I see there are some change relating to how select2 is added to the form in this PR. I think it might be easier to extract and merge those changes first (separately) to the new icon "feature".

@monishdeb
Copy link
Member Author

monishdeb commented Apr 4, 2019

Thanks for your feedback. Will move out the select2 element type changes to addField(...) in a separate PR.

@eileenmcnaughton
Copy link
Contributor

test fail relates

@monishdeb
Copy link
Member Author

@mattwire I have submitted a separate PR #14416 that only contain the new addField('select2', ....) feature. Can you please check now?

@monishdeb monishdeb force-pushed the core-785 branch 2 times, most recently from 3a93b06 to a5ca0fa Compare June 3, 2019 09:50
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

test fail relates

@colemanw are you +1 on concept / general code approach?

@monishdeb monishdeb force-pushed the core-785 branch 6 times, most recently from 14c448c to c8184c8 Compare September 3, 2019 11:36
@monishdeb
Copy link
Member Author

Jenkins test this please

@eileenmcnaughton
Copy link
Contributor

@colemanw there is still a related test fail here but can you confirm that you have no concerns on this pr

@colemanw
Copy link
Member

Yes I approve this concept, actually the lightbulb was my bright idea, just got lost in some other thread when we were discussing this proposal.

@civicrm-builder retest this please

@eileenmcnaughton
Copy link
Contributor

oh the test is failing

@lcdservices
Copy link
Contributor

That looks to me like an unrelated issue with the test, not a problem with this PR.

@lcdservices
Copy link
Contributor

Ignore that last comment. It's an issue with the test included with this PR and should be fixed.

@eileenmcnaughton
Copy link
Contributor

lol - I thought that when I first saw your comment - so you were snapped

@monishdeb
Copy link
Member Author

Jenkins test this please.

@monishdeb
Copy link
Member Author

@eileenmcnaughton @colemanw the test build passed. Can we merge this PR?

@lcdservices
Copy link
Contributor

@monishdeb this looks good. Edit form/groups issue is fixed.
@colemanw can we get this merged? I think it's good to go.

@@ -1119,11 +1120,12 @@ private static function buildGroupHierarchy(&$hierarchy, $group, $tree, $titleOn
$hierarchy[$group['id']] = $spaces . $group['title'];
}
else {
$hierarchy[$group['id']] = [
'title' => $spaces . $group['title'],
$hierarchy[] = array(
Copy link
Contributor

Choose a reason for hiding this comment

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

@monishdeb is there a reason why we are changing the array key here? also shouldn't this use the short array syntax?

Copy link
Member Author

Choose a reason for hiding this comment

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

@seamuslee001 the answer lies in here where we are now relying on select2 widget, which expects the array keys to be sequential and not hardcoded group ID. And better coverage for tests

Copy link
Member

Choose a reason for hiding this comment

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

Could you update for the short array syntax?

@colemanw
Copy link
Member

@monishdeb can you check the review comment from Seamus above?

Also I would +1 the suggestion from BGM that we move the asterisk to after the group name as

  1. it doesn't mess up alignment
  2. that's normally where asterisks go

@francescbassas
Copy link
Contributor

francescbassas commented Feb 24, 2020

-1 to move the asterisk after the group name. For long group names the asterisk would either be lost at the end of the line or it would simply disappear. Maybe adding a CSS solution, padding-left and aligning all elements and putting an "asterisk" only on smart groups might be the best solution.

@lcdservices
Copy link
Contributor

I don't think there's a perfect solution for the asterisk location. I'd lean toward the beginning, as it ensures the best visibility.

@ray-wright
Copy link
Contributor

I would agree that a symbol (whether or not it is an asterisk) at the end of a group name is problematic. We use smart groups heavily and some of our names are a bit long. I also agree that adding the asterisk at the front messes up the left alignment. Is the solution that @francescbassas suggested - have the symbol off to the left with padding on the elements that don't have the symbol to keep the text alignment consistent - not entertainable?

@monishdeb
Copy link
Member Author

@lcdservices @colemanw @francescbassas @ray-wright if you all agree, should I keep asterisk only on smart group to the left (at start) of label and with some padding-left adjustment is the best solution here?

@lcdservices
Copy link
Contributor

I'm fine with that. I don't think there's a perfect solution, but this solution would address the most concerns/issues.

@mattwire
Copy link
Contributor

mattwire commented Jun 6, 2020

@monishdeb Needs rebase

@mattwire mattwire added the needs-work-not-review-ready Submitter required to take action, will be closed after 1-2 weeks in this state label Jun 6, 2020
@monishdeb
Copy link
Member Author

I have rebased the PR and made the changes to show asterisk on left of smart group label.

@mattwire mattwire added ready for review and removed needs-work-not-review-ready Submitter required to take action, will be closed after 1-2 weeks in this state labels Jun 9, 2020
@@ -73,7 +73,7 @@ public function buildQuickForm() {
if ($onlyPublicGroups && $group['visibility'] == 'User and User Admin Only') {
continue;
}
$allGroups[$id] = $group;
$allGroups[$group['id']] = $group;
Copy link
Member

Choose a reason for hiding this comment

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

Could you discard the as $id from the foreach loop above? It will avoid someone accidentally changing it back to what it was before.

@mlutfy
Copy link
Member

mlutfy commented Jun 16, 2020

Code seems OK, and I'll rally to the majority of placing an asterisk before.

I'm slightly concerned about changing the signature of CRM_Contact_BAO_Group::getGroupsHierarchy, since it could potentially break extensions?

For example, the Contact Layout Summary Editor does this:

      $groups = CRM_Contact_BAO_Group::getGroupsHierarchy(CRM_Core_PseudoConstant::group(), NULL, '  ', TRUE);
      $groupElement = $this->add('select', 'group', $label, $groups, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE]);

And these might need a bit more testing, for example, on the search forms:

$ grep -r getGroupsHierarchy
[..]
CRM_Contact_BAO_Group::getGroupsHierarchy($params, NULL, '  ', TRUE);
CRM/Contact/BAO/GroupContact.php: $options = CRM_Contact_BAO_Group::getGroupsHierarchy($options, NULL, '- ', TRUE);
[..]
CRM/Contact/Form/Search/Basic.php: $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ', TRUE);
CRM/Contact/Form/Search/Criteria.php: $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '  ', TRUE);
CRM/Contact/Form/Edit/TagsAndGroups.php: $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
CRM/Contact/Form/GroupContact.php: $heirGroups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
CRM/Contact/Form/GroupContact.php: $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, '  ', TRUE);
CRM/Core/PseudoConstant.php: return CRM_Contact_BAO_Group::getGroupsHierarchy($groups, NULL, '  ', TRUE);

@eileenmcnaughton
Copy link
Contributor

@mlutfy the last comment on this (which seems blocking) is from you

"I'm slightly concerned about changing the signature of CRM_Contact_BAO_Group::getGroupsHierarchy, since it could potentially break extensions?"

  • I don't see a change to that signature - although the title is 'tweaked'

Can you comment & maybe merge if you see no remaining blockers

@mlutfy
Copy link
Member

mlutfy commented Jul 14, 2020

hmm indeed, seems all fine. merging!

@eileenmcnaughton
Copy link
Contributor

Unfortunately this caused fatal errors - see #17888 - for now it is reverted as I think revert & redo is a sensible policy when the alternative is not obvious

@francescbassas
Copy link
Contributor

I think instead of putting the asterisk directly in the name of the smart groups it would be better to add a class to be able to define the visual variations at CSS level.

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.

9 participants