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-21520: Implement Search Action to Add Contacts to Case #11371

Merged

Conversation

MiyaNoctem
Copy link
Contributor

@MiyaNoctem MiyaNoctem commented Dec 5, 2017

Overview

From search results, the user can do a set of actions. In this actions menu, we need to add a new option: "Add contacts to Case". Once the user selects this option, they will see a form where they can select a case (an existing case) and also assign a case role to all selected users.

screen shot 2017-12-04 at 12 25 08 1

Before

It was not possible to add contacts to a case in bulk.

After

Added functionality:

  • Added action to search results list of actions.
  • Created Form to show selection combos to choose case and role.
  • Implemented postProcess logic to add contacts to the selected case with the selected role.

Documentation

PR documenting new functionality on user guide:
civicrm/civicrm-user-guide#245


.val('')
.crmEntityRef({create: false});
});
})(cj, CRM);
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for adding a simple textfield from the formbuilder and then javascripting it into an entityref after the fact? Why not just add an entityref from the getgo?

}
return $roleTypes;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand the purpose of breaking these 2 functions into a separate file. What's wrong with doing this in the CRM_Case_Form_AddToCaseAsRole class?

@@ -0,0 +1 @@
{include file="CRM/Caseroles/Form/AddToCaseAsRole.tpl"}
Copy link
Member

Choose a reason for hiding this comment

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

This file seems quite useless. What's the purpose of not putting the contents of templates/CRM/Case/Form/AddToCaseAsRole.tpl here?

@MiyaNoctem MiyaNoctem changed the title CRM-21520: Implement Search Action to Add Contacts to Case CRM-21520: (WIP) Implement Search Action to Add Contacts to Case Dec 5, 2017
Part of the functionality included corresponded to the ability to add a
contact to a case from within the Contact's detail view, via an action.

This functionality is outside of the scope of the current ticket, and thus is
removed.
Now that we're only using one form, we don't need to have the FormBuilder
class. Removed the class and sent the building code to the AddToCaseAsRole
class.
*/
public function buildQuickForm() {

$this->add('text', 'assign_to', ts('Assign to'));
Copy link
Member

@colemanw colemanw Dec 5, 2017

Choose a reason for hiding this comment

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

Your recent changes look good, but I'm still curious to know why the javascript is necessary instead of simply doing

$this->addEntityRef('assign_to', ts('Assign to'), array('api' => array('params' => array('contact_type' => 'Individual'))), TRUE);

Copy link
Contributor Author

@MiyaNoctem MiyaNoctem Dec 6, 2017

Choose a reason for hiding this comment

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

Hi @colemanw,

Thanks for the feedback. I'm working on this, I should be able to commit the change later today.

Thanks again!

Copy link
Member

Choose a reason for hiding this comment

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

Looks good. But it appears you still need to remove this redundant form element.

Copy link
Contributor Author

@MiyaNoctem MiyaNoctem Dec 7, 2017

Choose a reason for hiding this comment

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

@colemanw,

I removed the redundant element, thanks for pointing it out. I also added a PR to the user guide repository documenting the functionality.

'role_type',
ts('Relationship Type'),
array('' => ts('- select type -')) + $roleTypes,
FALSE,
Copy link
Member

Choose a reason for hiding this comment

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

I think $required should be TRUE.

@MiyaNoctem MiyaNoctem changed the title CRM-21520: (WIP) Implement Search Action to Add Contacts to Case CRM-21520: Implement Search Action to Add Contacts to Case Dec 6, 2017
<path>civicrm/case/add-contact</path>
<page_callback>CRM_Case_Form_AddContact</page_callback>
<title>AddContact</title>
<access_arguments>access CiviCRM</access_arguments>
Copy link
Member

Choose a reason for hiding this comment

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

I think access_arguments should be access my cases and activities

Copy link
Member

Choose a reason for hiding this comment

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

Actually, what is this entry? I don't think this class exists. Can this be removed?


$url = CRM_Utils_System::url(
'civicrm/contact/view/case',
sprintf('cid=%d&id=%d', $clients[0], $caseId)
Copy link
Member

Choose a reason for hiding this comment

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

This is missing a few arguments so the redirect doesn't quite work. IMO an array is more readable than sprintf. Recommend changing to:

array(
  'cid' => $clients[0],
  'id' => $caseId,
  'reset' => 1,
  'action' => 'view',
)

@MiyaNoctem
Copy link
Contributor Author

@colemanw,

I've implemented the suggestions you made. Thanks for the input. Do you think this is ready now to be merged?

@colemanw
Copy link
Member

colemanw commented Dec 24, 2017

@colemanw colemanw merged commit e3e59cc into civicrm:master Dec 24, 2017
@MiyaNoctem MiyaNoctem deleted the CRM-21520-action-to-add-contacts-to-case branch December 26, 2017 14:17
sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
…add-contacts-to-case

CRM-21520: Implement Search Action to Add Contacts to Case
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