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

Remove inheritance of MembershipConfig form from MembershipStatus form. #12184

Merged
merged 2 commits into from
May 27, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 23, 2018

Overview

Code tidy up on Membership Status form towards the general goal of supporting custom data on a range of forms

Before

MembershipType form & MembershipStatus form share a parent class, but very little of the code on that class is shared

After

MembershipStatus form directly extends CRM_Core_Form and implements the EntityForm trait to get the buttons. There is some minor tidy up in there but I tried to keep it very limited.

Technical Details

I only added 2 fields to the entity form mechanism.

Comments

@colemanw @mattwire this is a cleanup towards further entity form standardisation if one of you can look

@colemanw I realised I also needed to fix the RelationshipForm once & fix label being accidentally set to not required in previous changes - included here

parent::buildQuickForm();

if ($this->_action & CRM_Core_Action::DELETE) {
return;
}

$this->applyFilter('__ALL__', 'trim');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in self::buildQuickEntityForm();

@eileenmcnaughton
Copy link
Contributor Author

test this please

@@ -60,7 +60,8 @@ protected function setEntityFields() {
$this->entityFields = [
'label_a_b' => [
'name' => 'label_a_b',
'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B.")
'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B."),
'required' => TRUE,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

accidentally changed to non-mandatory in previous commit

Copy link
Contributor

Choose a reason for hiding this comment

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

This bit should probably be in it's own PR as it's unrelated to the other changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RIght - it leverages the fact this PR adds the ability to set required. I'm OK to do that - I was just a bit scared that it could get lost - but if you feel the PR is otherwise mergeable I'll take it out

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, leave me to review/test the rest of the PR then first :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattwire Ok - I could pull that part out & do the required bit first & make this depend on that - either way but there is an interdependency

Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed this change is correct. Let's leave it in the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should add 'required' to the docblock above too * - required (Is this field required or not?)

Copy link
Contributor

@mattwire mattwire left a comment

Choose a reason for hiding this comment

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

@eileenmcnaughton Tested and confirmed that everything is working as before. I'd like to see the delete message updated as it's not really reflecting what happens (though I realise it was like that before).

This is a good iterative improvement to the code that will help consistency and maintainability in the future, and subject to the delete message wording is good to merge.

* We do this from the constructor in order to do a translation.
*/
public function setDeleteMessage() {
$this->deleteMessage = ts('WARNING: Deleting this option will result in the loss of all membership records of this status.') . ' ' . ts('This may mean the loss of a substantial amount of data, and the action cannot be undone.') . ' ' . ts('Do you want to continue?');
Copy link
Contributor

Choose a reason for hiding this comment

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

@eileenmcnaughton I realise that this is just a copy of the original message, but it's not clear to me what will happen - does it really mean that actual memberships will be deleted?
In fact, looking in CRM_Member_BAO_MembershipStatus::del() it would seem that a) it's only referring to the membershipstatus, and b) it won't delete anything if there are memberships with this status.

I've just confirmed that to be the case.
Something like:

"You will not be able to delete this membership status if there are existing memberships with this status. You will need to check all your membership status rules afterwards to ensure that a valid status will always be available. Please confirm that you wish to delete this status?"

@@ -60,7 +60,8 @@ protected function setEntityFields() {
$this->entityFields = [
'label_a_b' => [
'name' => 'label_a_b',
'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B.")
'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B."),
'required' => TRUE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed this change is correct. Let's leave it in the PR.

This is part of trying to move towards an entity form (ie. support custom data) for MembershipType.

Currently the 2 forms share a parent class - but really the add buttons is the only shared functionality.

This change uses the EntityTrait to add the buttons as well. There is some minor tidy up in there
but I tried to keep it very limited.

I switched only one field over to being added via addField, the parent mechanism so far
@eileenmcnaughton
Copy link
Contributor Author

changes made per review - merge on pass

@eileenmcnaughton eileenmcnaughton merged commit c932689 into civicrm:master May 27, 2018
@eileenmcnaughton eileenmcnaughton deleted the entity_form branch May 27, 2018 22:23
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.

3 participants