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

(Smart Group) is being constantly added while editing the smart group title from 'Manage Group' page #20898

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Jul 19, 2021

Overview

Steps to replicate:

  1. Go to 'Manage Group'
  2. Inline edit any smart group title by clicking on the title.

Before

before

After

after

@civibot
Copy link

civibot bot commented Jul 19, 2021

(Standard links)

@@ -164,6 +165,10 @@
.prepend('{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span>{literal}')
.find('div').css({'display': 'inline'});
});
$('tbody tr.crm-smart-group', settings.nTable).each(function () {
$(this).find('td:first')
.append(smartGroupText);
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing is that the parentsOnly var is only set on first page load, not when the table is refreshed by ajax, so changing any of the search filters at the top of the table like Group Type or Visibility then refreshes the table, but doesn't apply this text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @demeritcowboy thanks for your feedback. I have updated my patch and also checked with parent group. Can you please review my patch again?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks it's better, except now it adds "Smart Group" to every child group even if they are not smart kids. Hmm this seems harder than it looks.

@mlutfy
Copy link
Member

mlutfy commented Jul 29, 2021

I have tested the latest patch, and it seems to work well:

  • Tested inline edit of a group
  • Tested searching for a group, then edit
  • Played around with parent/child groups, although not sure what to look for here.

@demeritcowboy
Copy link
Contributor

In my testing even dumb child groups have the smart label added - did that come up for you?

@mlutfy
Copy link
Member

mlutfy commented Jul 29, 2021

@demeritcowboy oh, yes, you're right. Child groups, even if static, still get the label.

}
$('tbody tr.crm-smart-group', settings.nTable).each(function () {
$(this).find('td:first')
.append(smartGroupText);
Copy link
Member

Choose a reason for hiding this comment

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

Could this be simplified to:

$('tbody tr.crm-smart-group > td.crm-group-name', settings.nTable).append(smartGroupText);

(I did a bit of testing, seems to work)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, yep it works for me too. Will update the PR.

@@ -234,15 +239,18 @@
'parent_is_' + parent_id,
'crm-row-child'
];
if (!$.inArray("crm-smart-group", val.row_classes)) {
smartGroupText = '';
}
Copy link
Member

Choose a reason for hiding this comment

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

Try this instead:

                if ('DT_RowClass' in val) {
                  val.row_classes = val.row_classes.concat(val.DT_RowClass.split(' ').filter((item) => val.row_classes.indexOf(item) < 0));

                 // this ->
                  if (val.DT_RowClass.indexOf('crm-smart-group') == -1) {
                    smartGroupText = '';
                  }
                }

because the val.row_classes, set just above, will not have the crm-smart-group class. It gets set from the DT_RowClass in the condition right under.

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thanks for the patch :)

@monishdeb
Copy link
Member Author

Thank you @mlufty and @demeritcowboy for reviewing the patch and mentioning the different use-cases that lead to errors. And I found another issue where if you search for a child group, and then try to edit the child group title, it adds 'childGroup' subtext in it. It seems like a separate issue but will create a separate PR. The intention is to prevent the indicator text to appear on the title field on the inline edit.

@mlutfy
Copy link
Member

mlutfy commented Aug 23, 2021

@demeritcowboy This PR looks good to me now. We've tested it in production and haven't had any complaints. Any thoughts?

@mlutfy mlutfy added the merge ready PR will be merged after a few days if there are no objections label Aug 23, 2021
@demeritcowboy
Copy link
Contributor

Oh did the PR get updated? It looks like it still has the original code?

@mlutfy mlutfy removed the merge ready PR will be merged after a few days if there are no objections label Aug 23, 2021
@mlutfy
Copy link
Member

mlutfy commented Aug 23, 2021

My bad, I need more coffee!

@monishdeb Could you update?

@monishdeb
Copy link
Member Author

@mlutfy @demeritcowboy my apologies for the delay. I have updated the PR and looks ok to me:
before

Also checked with Level > 2 parent group, which contains smart group as child group.

@demeritcowboy
Copy link
Contributor

jenkins retest this please - strange error: mkdir: cannot create directory ‘/home/jenkins/bknix-dfl/build/core-20898-7ccxm’: File exists

@demeritcowboy
Copy link
Contributor

As noted there's some issues when using the filters but they're also wonky before. Looks good.

@demeritcowboy demeritcowboy merged commit ebd125c into civicrm:master Aug 24, 2021
@seamuslee001 seamuslee001 deleted the issue_2701 branch August 25, 2021 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants