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

Convert Campaign widgets to entityRef #13491

Merged
merged 4 commits into from
Jan 25, 2019
Merged

Conversation

colemanw
Copy link
Member

Overview

Cleans up the code and UI for selecting a campaign. Instead of a select list with a button to load past campaigns, now the entire list of campaigns is searchable and filterable. New campaigns can be created on-the-fly.

Before

Ugly message when there are no campaigns.
Button to load past campaigns.
No way to create a new campaign without leaving and reloading the page.

screenshot from 2019-01-22 09-52-53

After

New widget can filter out past campaigns and create new ones on-the-fly, so no need for the ugly message or the "show past campaigns" button. The widget also displays the campaign type, status, and dates in the results.

screenshot from 2019-01-21 13-18-52

@civibot
Copy link

civibot bot commented Jan 22, 2019

(Standard links)

@civibot civibot bot added the master label Jan 22, 2019
@colemanw
Copy link
Member Author

@JoeMurray I believe you were involved in creating the "Show past campaigns" button. Can you review this improvement?

@colemanw
Copy link
Member Author

@civicrm-builder retest this please

2 similar comments
@colemanw
Copy link
Member Author

@civicrm-builder retest this please

@colemanw
Copy link
Member Author

@civicrm-builder retest this please

@JoeMurray
Copy link
Contributor

JoeMurray commented Jan 24, 2019

I'd like to review how this runs in browser, eg the Refine search. From what I can see this is an area where there were opportunities to make a nice usability improvement.

Pls remind me what the admin password is on the auto-build test sites? Thx.

@JoeMurray
Copy link
Contributor

I think commit cbb17d3 would be better in its own MR.

@colemanw
Copy link
Member Author

I think commit cbb17d3 would be better in its own MR.

Done. #13503

@JoeMurray
Copy link
Contributor

I don't know the criteria/process for removing 'AJAX' functions from core. With regular functions in core, there is a fair bit of leeway given the main contract is the API layer. But I imagine developers have been treating anything in an 'AJAX.php' file as fair game for them use, like CRM/Campaign/Page/AJAX.php. If so, then removing functions may require some notice time for deprecation. In particular, I would guess there are extensions out there that allow new entities to be associated with Campaigns, so they might use this function allActiveCampaigns(). Comments @eileenmcnaughton ?

@colemanw
Copy link
Member Author

@JoeMurray I appreciate your attitude of caution about removing the ajax callback, but in this case an api does exist to cover the function - any extension developer wishing to fetch past campaigns can simply use the Campaign api, which has existed for many years. In the (IMO very unlikely) event that someone out there has (a) managed to actually find this obscure function and (b) decided to ignore every piece of advice in our documentation which says avoid internal functions and use the api... I'd have to say they've been warned.

@JoeMurray
Copy link
Contributor

@JoeMurray I appreciate your attitude of caution about removing the ajax callback, but in this case an api does exist to cover the function - any extension developer wishing to fetch past campaigns can simply use the Campaign api, which has existed for many years. In the (IMO very unlikely) event that someone out there has (a) managed to actually find this obscure function and (b) decided to ignore every piece of advice in our documentation which says avoid internal functions and use the api... I'd have to say they've been warned.

I'm betraying my ignorance around what functions in AJAX.php are considered 'callable' by extensions. I'll defer to you.

@JoeMurray
Copy link
Contributor

This MR improves the UX. It replaces many lines of code with a small number of more elegant ones that provide a path for similar cleanup elsewhere.

I tested the campaign widget on Add Activity and Edit Activity and Add Contribution and all worked properly. I tested the filtering options and all worked nicely.

The create links for adding new contacts on the Address sharing widget were not properly filtered. As mentioned above I'd prefer to see that moved to a different PR.

If that is fixed or moved out of this MR then I'd say this is ready to merge.

@colemanw
Copy link
Member Author

Thanks Joe. What problem did you run into with the shared address widget?

@JoeMurray
Copy link
Contributor

My comment above is still pending, I think due to them being on a line removed by a force push from Coleman. Here they are repeated.

Removing CiviCRM: add contacts perm from all role, logging in as demo user (as opposed to admin user 1 which has all permissions), then editing a contact, I see
2019-01-24_14-42-58

However, as expected, clicking on the New Individual, New Organization, and New Household links, an error is displayed:
2019-01-24_13-36-23

Could you fix so that the create links are not displayed for users without the correct permissions? It might be appropriate to move this to a different MR.

@colemanw
Copy link
Member Author

Thanks @JoeMurray - I just tested and found the problem is preexisting and not related to this PR. So I'll open up a new PR to solve that issue and merge this based on your review. Thanks!

@colemanw colemanw merged commit 9493687 into civicrm:master Jan 25, 2019
@colemanw colemanw deleted the campaign branch January 25, 2019 14:40
@eileenmcnaughton
Copy link
Contributor

@colemanw I've deployed this & I'm not loving it - I think it was totally broken when I first used it, but then I realised I could find my campaign

I think the issue is the fact there is no pre-population of a list so it seems like none exist - I'm pretty sure there is a param for that that you turn on & off in other entity references to make it feel a bit more like a select when you load it?

@colemanw
Copy link
Member Author

@eileenmcnaughton yes we could enable that mode. However it would make the filters harder to find (they'd only appear if you get no search result).

@eileenmcnaughton
Copy link
Contributor

@colemanw hmm - I guess what people will find more convenient will depend on how many campaigns they have. However, it would be tough to use for our org by anyone other than me - ie. I know what campaign I'm gonna search for but I think others wouldn't have a clue until they see a list.

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