-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UHC Visits count and last visited date contact default sort (#4770)
Adds visit count display in contacts list. Visit count display is conditioned by the same permission as displaying last visited date. Visits are counted based on the calendar month, with each month starting on either the 1st or on a configurable date. Visit counters may be color coded if a specific visit count goal configured. Adds UHC app configuration section. Adds UHC configuration with options to select default sorting contacts lists by last visited date, visit counter settings for monthly count goal and the month reset/start date. #4758 #4752
- Loading branch information
1 parent
37c6816
commit 4f41601
Showing
16 changed files
with
940 additions
and
51 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
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
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,70 @@ | ||
var moment = require('moment'); | ||
|
||
(function () { | ||
|
||
'use strict'; | ||
'ngInject'; | ||
|
||
var inboxServices = angular.module('inboxServices'); | ||
|
||
inboxServices.factory('CalendarInterval', function() { | ||
var normalizeStartDate = function(intervalStartDate) { | ||
intervalStartDate = parseInt(intervalStartDate); | ||
|
||
if (isNaN(intervalStartDate) || intervalStartDate <= 0 || intervalStartDate > 31) { | ||
intervalStartDate = 1; | ||
} | ||
|
||
return intervalStartDate; | ||
}; | ||
|
||
var getMinimumStartDate = function(intervalStartDate, relativeDate) { | ||
return moment | ||
.min( | ||
moment(relativeDate).subtract(1, 'month').date(intervalStartDate).startOf('day'), | ||
moment(relativeDate).startOf('month') | ||
) | ||
.valueOf(); | ||
}; | ||
|
||
var getMinimumEndDate = function(intervalStartDate, nextMonth, relativeDate) { | ||
return moment | ||
.min( | ||
moment(relativeDate).add(nextMonth ? 1 : 0, 'month').date(intervalStartDate - 1).endOf('day'), | ||
moment(relativeDate).add(nextMonth ? 1 : 0, 'month').endOf('month') | ||
) | ||
.valueOf(); | ||
}; | ||
|
||
return { | ||
// Returns the timestamps of the start and end of the current calendar interval | ||
// @param {Number} [intervalStartDate=1] - day of month when interval starts (1 - 31) | ||
// | ||
// if `intervalStartDate` exceeds month's day count, the start/end of following/current month is returned | ||
// f.e. `intervalStartDate` === 31 would generate next intervals : | ||
// [12-31 -> 01-30], [01-31 -> 02-[28|29]], [03-01 -> 03-30], [03-31 -> 04-30], [05-01 -> 05-30], [05-31 - 06-30] | ||
getCurrent: function(intervalStartDate) { | ||
intervalStartDate = normalizeStartDate(intervalStartDate); | ||
|
||
if (intervalStartDate === 1) { | ||
return { | ||
start: moment().startOf('month').valueOf(), | ||
end: moment().endOf('month').valueOf() | ||
}; | ||
} | ||
|
||
if (intervalStartDate <= moment().date()) { | ||
return { | ||
start: moment().date(intervalStartDate).startOf('day').valueOf(), | ||
end: getMinimumEndDate(intervalStartDate, true) | ||
}; | ||
} | ||
|
||
return { | ||
start: getMinimumStartDate(intervalStartDate), | ||
end: getMinimumEndDate(intervalStartDate) | ||
}; | ||
} | ||
}; | ||
}); | ||
}()); |
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
Oops, something went wrong.