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

CRM-21100 Convert list of test groups into AJAX based select2 like r… #10898

Merged
merged 3 commits into from
Apr 12, 2018

Conversation

seamuslee001
Copy link
Contributor

…eceipients box

Overview

Previously the Test Group box was generated using a list of groups put into the DOM. Now it works off an AJAX based API call in the same style as the Recipients box

Technical Details

This removes the need to load the groups in through items that are loaded as the Angular initializes to using AJAX based API call to retrieve a list of groups and their titles

Comments

@mlutfy are you able to test this out, You will need to clear caches for this to work

@seamuslee001 seamuslee001 changed the title CRM-201100 Convert list of test groups into AJAX based select2 like r… CRM-21100 Convert list of test groups into AJAX based select2 like r… Aug 24, 2017
@eileenmcnaughton
Copy link
Contributor

@seamuslee001 this feels like a variant of what @totten did for Mosaico the other day - is this still required? Does that mean @totten has his head in this code enough to review this?

@seamuslee001
Copy link
Contributor Author

So this will need a little bit of further work but its an extension of what happened to the recipients group. Tim basically did a hatchet fix for Mosaico to cope with my hatchet fix for test Groups. This is a more permanent and performant fix for test Groups

@eileenmcnaughton
Copy link
Contributor

Perhaps close & re-open once you have done the re-fix? I'm conscious I found this because I was looking at PRs that had slipped into the neglected part of the q

@seamuslee001
Copy link
Contributor Author

I would rather keep the PR open

@eileenmcnaughton
Copy link
Contributor

ok - we can put [wip] in the header

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton changes made just had to back out some changes as they are now required for other parts of the mailing interface. I have retested this locally and confirmed it still works as with the original fix

@seamuslee001
Copy link
Contributor Author

@davejenx are you able to give this one a test, You will probably need to clear cache after applying to make sure it works. What your checking is that you can still find / select a group to send a test mailing to from the new mailing screen. It should load the page slightly faster maybe not heaps but slightly

@eileenmcnaughton
Copy link
Contributor

@davejenx are you going to be able to test this?

@colemanw
Copy link
Member

@seamuslee001 I'm curious to know why there is so much code for this select field. Normally an EntityRef field can be created simply by declaring it. For example:

<input crm-entityref="{entity: 'Group', select: {allowClear:true}}" ng-model="myobj.field" />

@eileenmcnaughton
Copy link
Contributor

@colemanw @davejenx @seamuslee001 how do we progress this?

@colemanw
Copy link
Member

colemanw commented Apr 6, 2018

I'd like to get clarification from @seamuslee001 in response to my last question.

@seamuslee001
Copy link
Contributor Author

thanks @colemanw seems to work ok

…eceipients box

Switch to entity ref as per coleman
var count = 0,
// Fixme: should this be in a template?
CRM.api3('group', 'getsingle', {id: scope.testGroup.gid, return: 'title'}).done(function(group) {
$dialog.dialog('option', 'title', ts('Send to %1', {1: group.title}));
Copy link
Member

Choose a reason for hiding this comment

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

By adding to the github url ?w=1 to filter out whitespace changes I was able to understand this change :)
It looks like you're adding an api call to lookup the group name, but that data hasn't actually been removed from the scope so I don't think changes to this file are necessary.

Copy link
Contributor Author

@seamuslee001 seamuslee001 Apr 9, 2018

Choose a reason for hiding this comment

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

@colemanw yes they are necessary, if you notice in old line 32 we are plucking out the title from an array ids, titles of groups. In this case we are no longer using that array (array is scope.crmMailingConst.testGroupNames so we have to because all we have then at present is the id of the group we have to make the API call to get the title of the group. to set as part of the title of the dialog

Copy link
Member

Choose a reason for hiding this comment

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

My point was that scope.crmMailingConst.testGroupNames hasn't actually been removed by this PR, so it should still be accessible to this function, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The long term goal i see is getting rid of scope.crmMailingConst.testGroupNames eventually to reduce the bloat in the DOM, We started by initially getting agileware to convert the recipients box to be AJAX, now we're fixing the test group stuff here and then need to solve the unsubscribe group. Once all that is done and check that mosaico gets appropriate changes. We can then remove testGroupNames out so that we reduce the amount of data getting pushed into the DOM in the boot. On large sites it has been found the loading of this array and also the message templates slows it down significantly (message template stuff was taken care of in a separate PR)

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Technically that information is in memory and doesn't have to be fetched from the api, because the Select2 element has already retrieved the group title. Let me think about how best to access it to avoid the extra api call.

@colemanw
Copy link
Member

@seamuslee001 I made some additional improvements. See what you think.

@colemanw
Copy link
Member

colemanw commented Apr 10, 2018

@seamuslee001 I've added one more commit to completely remove testGroupNames from the dom by using another dynamic entityRef field. All looks good in my runtime testing. Why don't you try it out too and we'll call this done. (note: to try out the final commit you need to create a mailing from a search)

@seamuslee001
Copy link
Contributor Author

@colemanw your changes look good to me However we may need to retain the testGroupNames just for a little bit or at least make it conditional. The reason is because of https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/blob/f95588b2d1eadde50df51b6247f2049e2683f61b/ang/crmMosaico/BlockMailing.js#L23 https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/blob/f95588b2d1eadde50df51b6247f2049e2683f61b/ang/crmMosaico/BlockPreview.js#L12 and https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/search?utf8=%E2%9C%93&q=groupNames+&type= we would need to patch all of those parts in mosaico before we could be satisfied to completely remove it. We could make the loading of it conditional on if template == mosaico ?

@colemanw
Copy link
Member

colemanw commented Apr 11, 2018

Ok @seamuslee001 I've ammended the commit to not remove the variable. That's probably enough tweaking for one PR.
Let's tackle the Mosaico issue later.

@seamuslee001
Copy link
Contributor Author

I'm happy with your latest changes, @eileenmcnaughton would you be able to test this?

@colemanw
Copy link
Member

She has enough on her plate. I'm happy with our mutual testing.

@colemanw
Copy link
Member

@colemanw colemanw merged commit 7fab76c into civicrm:master Apr 12, 2018
@eileenmcnaughton eileenmcnaughton deleted the CRM-21100 branch April 12, 2018 23:22
@eileenmcnaughton
Copy link
Contributor

thanks guys - agree that the 2 of you are enough testers

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