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

Case type management fixes #12647

Merged
merged 1 commit into from
Jan 24, 2019
Merged

Conversation

reneolivo
Copy link
Contributor

@reneolivo reneolivo commented Aug 12, 2018

Overview

This PR fixes the following issues with case type management:

  • When selecting default assignees by relationships, it will only display active relationship types.
  • It handles the absence of activity types that have been deleted. Without taking this into consideration, the screen would break if it encounters a missing activity type.

Active relationship types

To reproduce the issue:

  1. disable a relationship type
  2. edit a case type and select a timeline
  3. select any activity, change the default assignee option, and choose "By relationship to case client"
  4. search for the relationship type that was disabled.

The relationship type is shown, but it should not.

Before

relationship-type-before

After

pr-relationship-types-before

Technical details

The issue is present because when constructing the list of relationship types for default assignees, the list does not take into consideration the is_active field. To fix this, the request that brings relationship types was amended:

reqs.relTypes = ['RelationshipType', 'get', {
  sequential: 1,
  is_active: 1,
  options: {
    sort: CRM.crmCaseType.REL_TYPE_CNAME,
    limit: 0
  }
}];

Deleted activity types

How to reproduce the issue:

  1. Find an activity type that is included in one of the case types's timelines.
  2. Delete the activity type.
  3. Try to edit the case type where the activity type was included.

A broken AngularJS screen is shown and it should not.

Before

missing-activity-before

After

missing-activity-after

Technical details

The issue happens because the list of all activity types is stored in a $scope.activityTypes indexed by activity name, but when one of the activities defined in a timeline references a deleted activity type, it breaks:

// before
type.label = $scope.activityTypes[type.name].label;

// after
var typeDefinition = $scope.activityTypes[type.name];
type.label = (typeDefinition && typeDefinition.label) || type.name;

The fix checks if the activity type exists, if not, it will use the type name as label as a fall back.


Comments

Tests could not be added because running karma start yields the following error:

ERROR [config]: Invalid config file!
  TypeError: Cannot read property 'replace' of undefined
    at escape (/vagrant/hr17-9000/sites/all/modules/civicrm/node_modules/civicrm-cv/civicrm-cv.js:5:20)
    at serializeArgs (/vagrant/hr17-9000/sites/all/modules/civicrm/node_modules/civicrm-cv/civicrm-cv.js:11:22)
    at /vagrant/hr17-9000/sites/all/modules/civicrm/node_modules/civicrm-cv/civicrm-cv.js:42:20
    at Object.<anonymous> (/vagrant/hr17-9000/sites/all/modules/civicrm/karma.conf.js:17:23)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)

I'm guessing this is an issue with the civicrm-cv package.

@civibot
Copy link

civibot bot commented Aug 12, 2018

(Standard links)

@colemanw
Copy link
Member

Hmm, a simpler fix would be to add is_active: 1 on line 78. Any reason not to do it that way?

@reneolivo
Copy link
Contributor Author

@colemanw, the relType object that is returned by the API is also used here:

$scope.relationshipTypeOptions = _.map(apiCalls.relTypes.values, function(type) {
return {id: type[REL_TYPE_CNAME], text: type.label_b_a};
});

And I'm not sure if the relationshipTypeOptions needs all relationship types.

Do you think it's safe to use is_active: 1 ? I could change it.

@colemanw
Copy link
Member

I think that would be safe, as it's more user-facing options; hiding disabled types should be a plus.

@eileenmcnaughton
Copy link
Contributor

@reneolivo is this pending an update from you now?

* When selecting default assignees by relationships, it will only display active relationship types.
* It also handles activity types that have been deleted. Without taking this into consideration,
the screen would break if it encounters a missing activity type.
@reneolivo
Copy link
Contributor Author

@eileenmcnaughton @colemanw I updated the PR with the suggested change. Sorry for the delay, I don't normally get mentions notifications but will active them for civicrm.

@eileenmcnaughton
Copy link
Contributor

test this please

1 similar comment
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@colemanw looks like you have reviewed this - is it good to merge?

Also - when are we going to Stop fixing the old civicase code & use the new extension instead?

@colemanw colemanw merged commit 7481d51 into civicrm:master Jan 24, 2019
@colemanw
Copy link
Member

Yep. Good to merge.
FYI This part of the CiviCase UI isn't replaced by the new extension.

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.

4 participants