-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from compucorp/develop
Release v1.0.0-alpha3
- Loading branch information
Showing
11 changed files
with
250 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(function (angular, caseStatuses, civicaseextras) { | ||
var module = angular.module('civicase'); | ||
|
||
module.config(function ($provide) { | ||
$provide.decorator('formatCase', formatCaseDecorator); | ||
}); | ||
|
||
function formatCaseDecorator ($delegate) { | ||
var originalFormatCase = $delegate; | ||
|
||
/** | ||
* Enhances the formatCase method so it adds information about overdue dates for the case. | ||
* | ||
* @param {Object} caseItem | ||
* @return {Object} | ||
*/ | ||
return function formatCase (caseItem) { | ||
var overdueNotificationLimit = parseInt(civicaseextras.overdueNotificationLimit, 10); | ||
var isStatusOpen = caseStatuses[caseItem.status_id].grouping === 'Opened'; | ||
var isModifiedDateOverdue = moment().subtract(overdueNotificationLimit, 'days') | ||
.isSameOrAfter(caseItem.modified_date); | ||
caseItem = originalFormatCase(caseItem); | ||
caseItem.overdueDates = { | ||
modified_date: isStatusOpen && isModifiedDateOverdue | ||
}; | ||
|
||
return caseItem; | ||
}; | ||
} | ||
})( | ||
angular, | ||
CRM.civicase.caseStatuses, | ||
CRM.civicaseextras | ||
); |
42 changes: 42 additions & 0 deletions
42
ang/test/civicaseextras/decorators/formatCase.decorator.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-env jasmine */ | ||
|
||
(function (CRM) { | ||
describe('formatCase decorator', function () { | ||
var formatCase, formattedCase, mockCase; | ||
|
||
beforeEach(module('civicase', 'civicaseextras', 'civicase.data')); | ||
|
||
beforeEach(inject(function (CasesData, _formatCase_) { | ||
mockCase = CasesData.get().values[0]; | ||
formatCase = _formatCase_; | ||
})); | ||
|
||
describe('when the case modified date is over the limit', function () { | ||
beforeEach(function () { | ||
CRM.civicaseextras.overdueNotificationLimit = 90; | ||
mockCase.modified_date = moment() | ||
.subtract(90, 'days') | ||
.format('YYYY-MM-DD HH:mm:ss'); | ||
formattedCase = formatCase(mockCase); | ||
}); | ||
|
||
it('marks the modified date as overdue', function () { | ||
expect(formattedCase.overdueDates.modified_date).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('when the case modified date is not over the limit', function () { | ||
beforeEach(function () { | ||
CRM.civicaseextras.overdueNotificationLimit = 160; | ||
mockCase.modified_date = moment() | ||
.subtract(90, 'days') | ||
.format('YYYY-MM-DD HH:mm:ss'); | ||
formattedCase = formatCase(mockCase); | ||
}); | ||
|
||
it('does not mark the modified date as overdue', function () { | ||
expect(formattedCase.overdueDates.modified_date).toBe(false); | ||
}); | ||
}); | ||
}); | ||
})(CRM); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"globals": [ | ||
"CRM", | ||
"angular", | ||
"moment", | ||
"inject" | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
return [ | ||
'civicaseCaseLastUpdatedNotificationLimit' => [ | ||
'group_name' => 'CiviCRM Preferences', | ||
'group' => 'core', | ||
'name' => 'civicaseCaseLastUpdatedNotificationLimit', | ||
'quick_form_type' => 'Element', | ||
'type' => 'Integer', | ||
'default' => 90, | ||
'html_type' => 'text', | ||
'html_attributes' => array( | ||
'size' => 2, | ||
'maxlength' => 4, | ||
), | ||
'add' => '4.7', | ||
'title' => 'Last updated notification after days', | ||
'is_domain' => 1, | ||
'is_contact' => 0, | ||
'description' => 'This adds a visual indicator for cases where there has not been any activity for the selected number of days. This will be visible on the Manage Cases screen on the last updated date.', | ||
'help_text' => '', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<tr class="crm-case-form-block-civicase-overdue-notification-limit"> | ||
<td class="label">{$form.civicaseCaseLastUpdatedNotificationLimit.label}</td> | ||
<td>{$form.civicaseCaseLastUpdatedNotificationLimit.html}<br /> | ||
<span class="description"> | ||
{ts}This adds a visual indicator for cases where there has not been any activity | ||
for the selected number of days. This will be visible on the Manage Cases screen | ||
on the last updated date.{/ts} | ||
</span> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<span ng-if="!item.overdueDates[header.name]"> | ||
{literal} | ||
{{ CRM.utils.formatDate(item[header.name]) }} | ||
{/literal} | ||
</span> | ||
<strong ng-if="item.overdueDates[header.name]" | ||
class="text-danger"> | ||
{literal} | ||
{{ CRM.utils.formatDate(item[header.name]) }} | ||
{/literal} | ||
<i class="material-icons civicase__icon">error</i> | ||
</strong> |