Skip to content

Commit

Permalink
Merge pull request #419 from compucorp/RSE-1053-fix-create-activity
Browse files Browse the repository at this point in the history
RSE-1053: Fix create activity
  • Loading branch information
deb1990 authored Apr 1, 2020
2 parents bbf722a + b91fccb commit f6238ca
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
10 changes: 10 additions & 0 deletions ang/civicase-base/providers/case-type.provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
this.$get = $get;
this.getAll = getAll;
this.getByCategory = getByCategory;
this.getById = getById;
this.getTitlesForNames = getTitlesForNames;

/**
Expand All @@ -24,6 +25,7 @@
return {
getAll: getAll,
getByCategory: getByCategory,
getById: getById,
getItemsForCaseType: getItemsForCaseType,
getTitlesForNames: getTitlesForNames
};
Expand Down Expand Up @@ -58,6 +60,14 @@
});
}

/**
* @param {number} caseTypeId the id for the case type.
* @returns {object} the case type for the given ID.
*/
function getById (caseTypeId) {
return caseTypes[caseTypeId];
}

/**
* Returns a list of case type titles for the given names.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
* @returns {string} url
*/
$scope.newActivityUrl = function (actType) {
var caseQueryParams = JSON.stringify(getCaseQueryParams({ caseId: $scope.case.id }));
var caseType = CaseType.getById($scope.case.case_type_id);
var caseQueryParams = JSON.stringify(getCaseQueryParams({
caseId: $scope.case.id,
caseTypeCategory: caseType.case_type_category
}));
var newActivity = {
activity_type_id: actType.id,
case_id: $scope.case.id,
Expand Down
18 changes: 16 additions & 2 deletions ang/test/civicase-base/services/case-type.service.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env jasmine */

(() => {
((_) => {
describe('Case Type', () => {
let CaseType, CaseTypesData;

Expand Down Expand Up @@ -40,5 +40,19 @@
]);
});
});

describe('when getting a case type by id', () => {
let expectedCaseType, returnedCaseType;

beforeEach(() => {
const caseTypeId = _.chain(CaseTypesData).keys().sample().value();
expectedCaseType = CaseTypesData[caseTypeId];
returnedCaseType = CaseType.getById(caseTypeId);
});

it('returns the matching case type', () => {
expect(returnedCaseType).toEqual(expectedCaseType);
});
});
});
})();
})(CRM._);

0 comments on commit f6238ca

Please sign in to comment.