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-21008 - Checkbox to explicitely change employer when doing shared address #12741

Closed
wants to merge 4 commits into from

Conversation

samuelsov
Copy link
Contributor

@samuelsov samuelsov commented Aug 28, 2018

Overview

Following the work done #12574, adding a checkbox on shared addresses so that people can explicitly update the employer instead of assuming it's what the user wants.

Before

When doing a shared address on a individual with an organization address, CiviCRM always update the relationships to disable any current employee/employer relationship and set the shared address organization as the only current relationship.

After

When the checkbox is checked, it does exactly the same as before but if not checked, it won't mess with the current relationships.

Creating a new shared address:
crm-21008 - 28-08-2018 11-15

Updating with or without checking the box:
crm-21008 - 28-08-2018 11-06

Not an organization, no checkbox available:
crm-21008 - 28-08-2018 11-16

Comments

The API has not been updated yet but the default behavior is to not create the relationship if the parameter is not set. I like the explicit behavior better but we might want to discuss this for backward compatibility.


@civibot
Copy link

civibot bot commented Aug 28, 2018

(Standard links)

12739.diff Outdated
@@ -0,0 +1,260 @@
diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php
Copy link
Contributor

Choose a reason for hiding this comment

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

opps

@eileenmcnaughton
Copy link
Contributor

test fail relates

@colemanw
Copy link
Member

I'm +1 on this change and happy to merge it when it's ready.

@samuelsov
Copy link
Contributor Author

@colemanw @eileenmcnaughton It seems that the change is breaking one test which is normal because i have assumed that we now need to be explicit about creating the relationship. Do you agree with that or do you prefer to keep the current behavior: i.e. by default, if no parameter is passed, a relationship is created ?

@@ -1042,11 +1042,21 @@ public static function processSharedAddress($addressId, $params) {
$query = 'SELECT id, contact_id FROM civicrm_address WHERE master_id = %1';
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($addressId, 'Integer')));

// TODO: VALIDATION REQUIRED = was implicit and is now explicit
// should we keep it backward compatible (i.e. no params means creating relationship) ?
// this should only impact API calls
Copy link
Member

Choose a reason for hiding this comment

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

Answer: yes, we need to keep it backwards compatible, so if the param is not set, treat it as if it were passed in TRUE.

@colemanw
Copy link
Member

@samuelsov since this breaks the API, yes. See code comment.

@colemanw
Copy link
Member

@samuelsov -- plese remove the patch and diff files from this PR.

@samuelsov
Copy link
Contributor Author

oups (for the patch) and ok, i will make it backward compatible

@samuelsov
Copy link
Contributor Author

Backward compatibility code is not pretty but it works in the UI and in the API.

The failing build doesn't seems to relate to the code.

@mlutfy
Copy link
Member

mlutfy commented Aug 30, 2018

jenkins, test this please

1 similar comment
@mlutfy
Copy link
Member

mlutfy commented Aug 30, 2018

jenkins, test this please

@mlutfy
Copy link
Member

mlutfy commented Aug 30, 2018

jenkins, test this please

(having issues with the test server)

@samuelsov
Copy link
Contributor Author

@colemanw anything blocking or can we merge ?

@eileenmcnaughton
Copy link
Contributor

@colemanw can we merge this?

@@ -164,6 +164,9 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin
// shared address
$form->addElement('checkbox', "address[$blockId][use_shared_address]", NULL, ts('Use another contact\'s address'));

// do we want to update employer for shared address
$form->addElement('checkbox', "address[$blockId][update_current_employer]", NULL, ts('Set this organization as current employer'));
Copy link
Member

Choose a reason for hiding this comment

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

Switch this to advcheckbox to always get a value back instead of undefined for unchecked.

Copy link
Contributor

Choose a reason for hiding this comment

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

@samuelsov ^^ looks this is currently blocking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colemanw @eileenmcnaughton ok thanks, i was not aware of advcheckbox alternative.

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@samuelsov is this in your court to make a change now?

@eileenmcnaughton
Copy link
Contributor

ps @colemanw there seem to be a few bugs that suggest advCheckbox got broken in the 5.5 security release but I haven't investigated

@samuelsov
Copy link
Contributor Author

@eileenmcnaughton yes it is, thanks for the reminder.

@colemanw
Copy link
Member

colemanw commented Feb 25, 2019

Hang on I think this can all be simplified without adding the extra ajax call to perform logic in php which could be done with js instead.
I'm going to take a stab at a reviewer's cut of this PR. Hang on...

@colemanw
Copy link
Member

@samuelsov see #13700

@colemanw colemanw closed this Feb 25, 2019
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.

5 participants