{"action":"created","comment":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/comments/189020237","pull_request_review_id":121113194,"id":189020237,"diff_hunk":"@@ -95,30 +100,41 @@ define([\n       vm.months = months;\n     }\n \n+    /**\n+     * Returns a month index in the format \"YYYY-<month_number>\"\n+     *\n+     * @param  {Moment} dateMoment\n+     * @return {String}\n+     */\n+    function getMonthIndex (dateMoment) {\n+      return dateMoment.year() + '-' + dateMoment.month();","path":"uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/components/leave-calendar.component.js","position":80,"original_position":80,"commit_id":"47d398c2bcf66ef16fe25b1359bd6be32feb5c7b","original_commit_id":"47d398c2bcf66ef16fe25b1359bd6be32feb5c7b","user":{"login":"reneolivo","id":1642119,"avatar_url":"https://avatars1.githubusercontent.com/u/1642119?v=4","gravatar_id":"","url":"https://api.github.com/users/reneolivo","html_url":"https://github.com/reneolivo","followers_url":"https://api.github.com/users/reneolivo/followers","following_url":"https://api.github.com/users/reneolivo/following{/other_user}","gists_url":"https://api.github.com/users/reneolivo/gists{/gist_id}","starred_url":"https://api.github.com/users/reneolivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reneolivo/subscriptions","organizations_url":"https://api.github.com/users/reneolivo/orgs","repos_url":"https://api.github.com/users/reneolivo/repos","events_url":"https://api.github.com/users/reneolivo/events{/privacy}","received_events_url":"https://api.github.com/users/reneolivo/received_events","type":"User","site_admin":false},"body":"```js\r\nreturn dateMoment.format('YYYY-M');\r\n```","created_at":"2018-05-17T16:22:24Z","updated_at":"2018-05-17T16:53:28Z","html_url":"https://github.com/civicrm/civihr/pull/2613#discussion_r189020237","pull_request_url":"https://api.github.com/repos/civicrm/civihr/pulls/2613","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments/189020237"},"html":{"href":"https://github.com/civicrm/civihr/pull/2613#discussion_r189020237"},"pull_request":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2613"}}},"pull_request":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/2613","id":188766757,"html_url":"https://github.com/civicrm/civihr/pull/2613","diff_url":"https://github.com/civicrm/civihr/pull/2613.diff","patch_url":"https://github.com/civicrm/civihr/pull/2613.patch","issue_url":"https://api.github.com/repos/civicrm/civihr/issues/2613","number":2613,"state":"open","locked":false,"title":"PCHR-3520: Show only one month in leave calendar","user":{"login":"igorpavlov","id":3973243,"avatar_url":"https://avatars1.githubusercontent.com/u/3973243?v=4","gravatar_id":"","url":"https://api.github.com/users/igorpavlov","html_url":"https://github.com/igorpavlov","followers_url":"https://api.github.com/users/igorpavlov/followers","following_url":"https://api.github.com/users/igorpavlov/following{/other_user}","gists_url":"https://api.github.com/users/igorpavlov/gists{/gist_id}","starred_url":"https://api.github.com/users/igorpavlov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorpavlov/subscriptions","organizations_url":"https://api.github.com/users/igorpavlov/orgs","repos_url":"https://api.github.com/users/igorpavlov/repos","events_url":"https://api.github.com/users/igorpavlov/events{/privacy}","received_events_url":"https://api.github.com/users/igorpavlov/received_events","type":"User","site_admin":false},"body":"## Overview\r\n\r\nThis PR augments the Leave Calendar. It now shows only one month at a time and allows to paginate through months. It supports all places where the Leave Calendar is injected and keeps the business logic the same.\r\n\r\nThis PR also fixes the problem when you have an absence period spread to a couple of years, for example, from `2018-01-01` to `2020-12-31`. In this case, selecting, for example, the January month showed multiple January months corresponding to multiple years, which made UI very weird.\r\n\r\nThis PR also applies performance improvements from the PoC that can be seen here https://github.com/civicrm/civihr/pull/2606/files. It parallelises REST requests to avoid unneeded load sequences.\r\n\r\n## Before\r\n\r\n![1](https://user-images.githubusercontent.com/3973243/40188421-cfa4ba8c-59f1-11e8-9bb0-decc5ff53fcf.gif)\r\n\r\n## After\r\n\r\n### Admin\r\n\r\n*This GIF shows how the logic works.*\r\n![2 admin](https://user-images.githubusercontent.com/3973243/40185852-93af3d64-59eb-11e8-9171-8bceedabe1c8.gif)\r\n\r\n### SSP\r\n\r\n*This GIF shows the responsiveness of SSP Leave Calendar.*\r\n![2 ssp](https://user-images.githubusercontent.com/3973243/40185973-e23519ae-59eb-11e8-81c6-e87b72d57572.gif)\r\n\r\n### Performance improvements\r\n\r\n![perf](https://user-images.githubusercontent.com/3973243/40188056-f8dea4f4-59f0-11e8-9f31-4c25afa50417.gif)\r\n\r\n## Technical Details\r\n\r\n### Supporting a single month per view\r\n\r\nThe way of how the month is injected has not been changed to avoid regression issues, however, the months Array was converted to a month String instead. The indexing of months has been changed as well.\r\n\r\n```js\r\nvm.selectedMonth = {}; // was vm.selectedMonth = [{}, {}, {}];\r\n// ...\r\nfunction getMonthIndex (dateMoment) {\r\n  return dateMoment.year() + '-' + dateMoment.month();\r\n}\r\n```\r\n\r\n### Month paginators\r\n\r\nPaginators availability tells UI if you can paginate.\r\n\r\n```js\r\nvm.monthPaginatorsAvailability = {\r\n  previous: true,\r\n  next: true\r\n};\r\n// controlled ^ by setMonthPaginatorsAvailability\r\n\r\nfunction setMonthPaginatorsAvailability () {\r\n  setMonthPaginatorAvailability('previous');\r\n  setMonthPaginatorAvailability('next');\r\n}\r\n\r\nfunction setMonthPaginatorAvailability (direction) {\r\n  var edgeMonthSelector = direction === 'previous' ? 'first' : 'last';\r\n  var edgeMonth = _[edgeMonthSelector](vm.months);\r\n  var edgeMonthMoment = moment().year(edgeMonth.year).month(edgeMonth.month);\r\n\r\n  vm.monthPaginatorsAvailability[direction] =\r\n    !vm.selectedMonth.moment.isSame(edgeMonthMoment, 'month');\r\n}\r\n```\r\n\r\nThe pagination function simply changes the selected month and triggers all necessary functions to refresh the view.\r\n\r\n```js\r\nfunction paginateMonth (direction) {\r\n  var monthAction = direction === 'previous' ? 'subtract' : 'add';\r\n  var dateFromMonth = vm.selectedMonth.moment[monthAction](1, 'month');\r\n\r\n  vm.selectedMonthIndex = getMonthIndex(dateFromMonth);\r\n\r\n  setSelectedMonth();\r\n  setMonthPaginatorsAvailability();\r\n  refresh('month');\r\n}\r\n```\r\n\r\n### HTML templates changes\r\n\r\nThe most major change is moving the month section header from Month template to Calendar template. This is because the header is not related to the month anymore (since we have a single month shown) because it contains the pagination. The change is pretty big code-wise, so it is not shown here.\r\n\r\n----\r\n\r\n✅Manual Tests - passed\r\n✅Jasmine Tests - augmented and passed\r\n✅JS distributive files - included\r\n✅Backstop tests - passed\r\n✅CSS distributive files  - included\r\n⏹PHP Unit Tests - not needed\r\n","created_at":"2018-05-17T14:59:43Z","updated_at":"2018-05-17T16:53:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86ea3ad9b9b6f9432485fc7703390d2c290c506b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/civicrm/civihr/pulls/2613/commits","review_comments_url":"https://api.github.com/repos/civicrm/civihr/pulls/2613/comments","review_comment_url":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/civicrm/civihr/issues/2613/comments","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/47d398c2bcf66ef16fe25b1359bd6be32feb5c7b","head":{"label":"civicrm:PCHR-3520-show-only-one-month-in-leave-calendar","ref":"PCHR-3520-show-only-one-month-in-leave-calendar","sha":"47d398c2bcf66ef16fe25b1359bd6be32feb5c7b","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-05-15T08:46:07Z","pushed_at":"2018-05-17T15:44:16Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":63929,"stargazers_count":27,"watchers_count":27,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":17,"license":null,"forks":39,"open_issues":17,"watchers":27,"default_branch":"staging"}},"base":{"label":"civicrm:PCHR-3512-enhance-leave-calendar","ref":"PCHR-3512-enhance-leave-calendar","sha":"e5b59a7cb78ea5cff1072fc67db50e4c688f8bbb","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-05-15T08:46:07Z","pushed_at":"2018-05-17T15:44:16Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":63929,"stargazers_count":27,"watchers_count":27,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":17,"license":null,"forks":39,"open_issues":17,"watchers":27,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2613"},"html":{"href":"https://github.com/civicrm/civihr/pull/2613"},"issue":{"href":"https://api.github.com/repos/civicrm/civihr/issues/2613"},"comments":{"href":"https://api.github.com/repos/civicrm/civihr/issues/2613/comments"},"review_comments":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2613/comments"},"review_comment":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2613/commits"},"statuses":{"href":"https://api.github.com/repos/civicrm/civihr/statuses/47d398c2bcf66ef16fe25b1359bd6be32feb5c7b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"reneolivo"}}