{"action":"created","comment":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/comments/96416897","pull_request_review_id":16985036,"id":96416897,"diff_hunk":"@@ -9,12 +10,447 @@ define([\n     templateUrl: ['settings', function (settings) {\n       return settings.pathTpl + 'components/manager-leave-requests.html';\n     }],\n-    controllerAs: 'requests',\n-    controller: ['$log', controller]\n+    controllerAs: 'ctrl',\n+    controller: ['$log', '$q', 'Contact', 'AbsencePeriod', 'AbsenceType', 'LeaveRequest',\n+      'OptionGroup', controller]\n   });\n \n \n-  function controller($log) {\n+  function controller($log, $q, Contact, AbsencePeriod, AbsenceType, LeaveRequest, OptionGroup) {\n     $log.debug('Component: manager-leave-requests');\n+\n+    var vm = Object.create(this),\n+      allStatus = {\n+        name: 'all',\n+        label: 'All'\n+      };\n+\n+    vm.isFilterExpanded = false;\n+    vm.absencePeriods = [];\n+    vm.filteredUsers = [];\n+    vm.absenceTypes = [];\n+    //leaveRequests.table - to handle table data\n+    //leaveRequests.filter - to handle left nav filter data\n+    vm.leaveRequests = {\n+      table: {\n+        list: []\n+      },\n+      filter: {\n+        list: []\n+      }\n+    };\n+    vm.filters = {\n+      contactFilters: {\n+        region: null,\n+        department: null,\n+        level_type: [],\n+        location: null\n+      },\n+      leaveRequestFilters: {\n+        selectedUsers: null,\n+        selectedPeriod: null,\n+        selectedAbsenceTypes: null,\n+        leaveStatus: allStatus,\n+        pending_requests: false\n+      }\n+    };\n+    vm.pagination = {\n+      page: 1,\n+      size: 7\n+    };\n+    vm.loading = {\n+      content: true,\n+      page: true\n+    };\n+\n+    /**\n+     * Labels the given period according to whether it's current or not\n+     *\n+     * @param  {AbsencePeriodInstance} period\n+     * @return {string}\n+     */\n+    vm.labelPeriod = function (period) {\n+      return period.current ? 'Current Period (' + period.title + ')' : period.title;\n+    };\n+\n+    /**\n+     * Returns the label of a Leave request when id is given\n+     *\n+     * @param {string} id - id of the leave request\n+     * @return {string}\n+     */\n+    vm.getLeaveStatusByValue = function (id) {\n+      if (vm.leaveRequestStatuses.length) {\n+        return vm.leaveRequestStatuses.find(function (status) {\n+          return status.value == id;\n+        }).label;\n+      }\n+    };\n+\n+    /**\n+     * Returns the title of a Absence type when id is given\n+     *\n+     * @param {string} id - id of the Absence type\n+     * @return {string}\n+     */\n+    vm.getAbsenceTypesByID = function (id) {\n+      if (vm.absenceTypes && id) {\n+        var type,\n+          i;\n+        for (i in vm.absenceTypes) {\n+          type = vm.absenceTypes[i];\n+          if (type.id == id) {\n+            return type.title;\n+          }\n+        }\n+      }\n+    };\n+\n+    /**\n+     * Filters leave requests by status\n+     *\n+     * @param {Object} status - status object\n+     * @return {array}\n+     */\n+    vm.filterLeaveRequestByStatus = function (status) {\n+      if (status.name === 'all' || status === '') {\n+        return vm.leaveRequests.filter.list;\n+      }\n+\n+      return vm.leaveRequests.filter.list.filter(function (request) {\n+        return request.status_id == status.value;\n+      })\n+    };\n+\n+    /**\n+     * Returns the class name for filter navigation when name is given\n+     *\n+     * @param {string} name - name of the status\n+     * @return {string}\n+     */\n+    vm.getNavBadge = function (name) {\n+      if (name === 'approved') {\n+        return 'badge-success';\n+      } else if (name === 'rejected') {\n+        return 'badge-danger';\n+      } else if (name === 'cancelled' || name === 'all') {\n+        return '';\n+      } else {\n+        return 'badge-primary';\n+      }\n+    };\n+\n+    /**\n+     * Returns an array of a given size\n+     *\n+     * @param {number} n - no of elements in the array\n+     * @return {Array}\n+     */\n+    vm.range = function (n) {\n+      if (n) {\n+        return new Array(n);\n+      }\n+    };\n+\n+    /**\n+     * Calculates the total number of pages for the pagination\n+     *\n+     * @return {number}\n+     */\n+    vm.totalNoOfPages = function () {\n+      return Math.ceil(vm.leaveRequests.table.total / vm.pagination.size);\n+    };\n+\n+    /**\n+     * Loads the next page for pagination element based on current page no\n+     */\n+    vm.nextPage = function () {\n+      if (vm.pagination.page < vm.totalNoOfPages()) {\n+        vm.refresh(++vm.pagination.page);\n+      }\n+    };\n+\n+    /**\n+     * Refreshes the leave request data\n+     *\n+     * @param {string} page - page number of the pagination element\n+     */\n+    vm.refresh = function (page) {\n+      page = page ? page : 1;\n+      loadAllRequests(page);\n+    };\n+\n+    /**\n+     * Refreshes the leave request data and also changes current selected leave status\n+     *\n+     * @param {string} status - status to be selected\n+     */\n+    vm.refreshWithFilter = function (status) {\n+      vm.filters.leaveRequestFilters.leaveStatus = status;\n+      vm.refresh();\n+    };\n+\n+    /**\n+     * Returns the username when id is given\n+     *\n+     * @param {string} id - id of the user\n+     * @return {string}\n+     */\n+    vm.getUserNameByID = function (id) {\n+      var user = vm.filteredUsers.find(function (data) {\n+        return data.contact_id == id;\n+      });\n+      return user ? user.display_name : null;\n+    };\n+\n+    /**\n+     * Clears selected users and refreshes leave requests\n+     */\n+    vm.clearStaffSelection = function () {\n+      vm.filters.leaveRequestFilters.selectedUsers = null;\n+      vm.refresh();\n+    };\n+\n+    (function init() {\n+      $q.all([\n+        loadAbsencePeriods(),\n+        loadAbsenceTypes(),\n+        loadRegions(),\n+        loadDepartments(),\n+        loadLocations(),\n+        loadLevelTypes(),\n+        loadStatuses()\n+      ])\n+        .then(function () {\n+          vm.loading.page = false;\n+          loadAllRequests(1);\n+        })\n+    })();\n+\n+    /**\n+     * Loads the absence periods\n+     *\n+     * @return {Promise}\n+     */\n+    function loadAbsencePeriods() {\n+      return AbsencePeriod.all()\n+        .then(function (absencePeriods) {\n+          vm.absencePeriods = absencePeriods;\n+          vm.filters.leaveRequestFilters.selectedPeriod = _.find(vm.absencePeriods, function (period) {\n+            return period.current === true;\n+          });\n+        });\n+    }\n+\n+    /**\n+     * Loads the absence types\n+     *\n+     * @return {Promise}\n+     */\n+    function loadAbsenceTypes() {\n+      return AbsenceType.all()\n+        .then(function (absenceTypes) {\n+          vm.absenceTypes = absenceTypes;\n+        });\n+    }\n+\n+    /**\n+     * Loads all requests\n+     *","path":"uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/manager-leave/components/manager-leave-requests.js","position":261,"original_position":261,"commit_id":"b44f172cc0197baadbb8760d41af7114d20a5085","original_commit_id":"b44f172cc0197baadbb8760d41af7114d20a5085","user":{"login":"dhavalsharma","id":89973,"avatar_url":"https://avatars.githubusercontent.com/u/89973?v=3","gravatar_id":"","url":"https://api.github.com/users/dhavalsharma","html_url":"https://github.com/dhavalsharma","followers_url":"https://api.github.com/users/dhavalsharma/followers","following_url":"https://api.github.com/users/dhavalsharma/following{/other_user}","gists_url":"https://api.github.com/users/dhavalsharma/gists{/gist_id}","starred_url":"https://api.github.com/users/dhavalsharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhavalsharma/subscriptions","organizations_url":"https://api.github.com/users/dhavalsharma/orgs","repos_url":"https://api.github.com/users/dhavalsharma/repos","events_url":"https://api.github.com/users/dhavalsharma/events{/privacy}","received_events_url":"https://api.github.com/users/dhavalsharma/received_events","type":"User","site_admin":false},"body":"document page","created_at":"2017-01-17T14:03:29Z","updated_at":"2017-01-17T14:11:05Z","html_url":"https://github.com/civicrm/civihr/pull/1346#discussion_r96416897","pull_request_url":"https://api.github.com/repos/civicrm/civihr/pulls/1346","_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments/96416897"},"html":{"href":"https://github.com/civicrm/civihr/pull/1346#discussion_r96416897"},"pull_request":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1346"}}},"pull_request":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/1346","id":101248912,"html_url":"https://github.com/civicrm/civihr/pull/1346","diff_url":"https://github.com/civicrm/civihr/pull/1346.diff","patch_url":"https://github.com/civicrm/civihr/pull/1346.patch","issue_url":"https://api.github.com/repos/civicrm/civihr/issues/1346","number":1346,"state":"open","locked":false,"title":"PCHR-1799: Manager Leave Requests Component","user":{"login":"deb1990","id":5058867,"avatar_url":"https://avatars.githubusercontent.com/u/5058867?v=3","gravatar_id":"","url":"https://api.github.com/users/deb1990","html_url":"https://github.com/deb1990","followers_url":"https://api.github.com/users/deb1990/followers","following_url":"https://api.github.com/users/deb1990/following{/other_user}","gists_url":"https://api.github.com/users/deb1990/gists{/gist_id}","starred_url":"https://api.github.com/users/deb1990/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deb1990/subscriptions","organizations_url":"https://api.github.com/users/deb1990/orgs","repos_url":"https://api.github.com/users/deb1990/repos","events_url":"https://api.github.com/users/deb1990/events{/privacy}","received_events_url":"https://api.github.com/users/deb1990/received_events","type":"User","site_admin":false},"body":"As part of this PR(and https://github.com/compucorp/civihr-employee-portal-theme/pull/132) the Manager Leave Requests Component has been developed with loading data from API.\r\n \r\n**Screengrab**\r\nhttp://recordit.co/T9T5drw0ay\r\n\r\n**Added**\r\n1. `ui.select` for autocomplete and multiselect dropdown\r\n2. `Contact` and `JobRole` API - Previously we were using mocked api which are now replaced.\r\n3. `hrjc_department `, `hrjc_level_type `, `hrjc_region `, `hrjc_location ` mock data added to `option-group-mock-data`\r\n\r\n**Improvements**\r\n1. `manager-leave.min.js` was not getting generated properly as all the injected modules were not getting compiled. Fixed by adding `manager-leave` module to `build.js`.\r\n","created_at":"2017-01-12T12:20:20Z","updated_at":"2017-01-17T14:11:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12859120f35e07fcbdaaa49758922fe7fe10e15a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/civicrm/civihr/pulls/1346/commits","review_comments_url":"https://api.github.com/repos/civicrm/civihr/pulls/1346/comments","review_comment_url":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/civicrm/civihr/issues/1346/comments","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/b44f172cc0197baadbb8760d41af7114d20a5085","head":{"label":"civicrm:PCHR-1799-manager-leave-requests-component","ref":"PCHR-1799-manager-leave-requests-component","sha":"b44f172cc0197baadbb8760d41af7114d20a5085","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","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://avatars.githubusercontent.com/u/136373?v=3","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":"2017-01-16T05:58:39Z","pushed_at":"2017-01-17T13:27:07Z","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":39108,"stargazers_count":6,"watchers_count":6,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":32,"forks":28,"open_issues":32,"watchers":6,"default_branch":"staging"}},"base":{"label":"civicrm:la-milestone-3","ref":"la-milestone-3","sha":"c70530d1d4686fb937fa402cf26f2d773002cead","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars.githubusercontent.com/u/136373?v=3","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://avatars.githubusercontent.com/u/136373?v=3","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":"2017-01-16T05:58:39Z","pushed_at":"2017-01-17T13:27:07Z","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":39108,"stargazers_count":6,"watchers_count":6,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":32,"forks":28,"open_issues":32,"watchers":6,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1346"},"html":{"href":"https://github.com/civicrm/civihr/pull/1346"},"issue":{"href":"https://api.github.com/repos/civicrm/civihr/issues/1346"},"comments":{"href":"https://api.github.com/repos/civicrm/civihr/issues/1346/comments"},"review_comments":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1346/comments"},"review_comment":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/1346/commits"},"statuses":{"href":"https://api.github.com/repos/civicrm/civihr/statuses/b44f172cc0197baadbb8760d41af7114d20a5085"}}}}
{"actor":{"display_login":"dhavalsharma"}}