{"action":"created","comment":{"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments/143667541","pull_request_review_id":68208603,"id":143667541,"diff_hunk":"@@ -549,5 +561,16 @@ define([\n         $rootScope.$broadcast('ct-spinner-hide');\n       });\n     }\n+\n+    /**\n+     * Executes watchers for changes\n+     */\n+    function watchForChanges () {\n+      // Watches the changes in cached contacts search array\n+      $rootScope.$watch('cache.contact.arrSearch', function (newValue) {\n+        // Update the collected contacts","path":"uk.co.compucorp.civicrm.tasksassignments/js/src/tasks-assignments/controllers/modal/modal-document.controller.js","position":56,"original_position":56,"commit_id":"d1a53840ead50d6d3788881a4d1bb57d41bf18a7","original_commit_id":"d1a53840ead50d6d3788881a4d1bb57d41bf18a7","user":{"login":"AkA84","id":6400898,"avatar_url":"https://avatars0.githubusercontent.com/u/6400898?v=4","gravatar_id":"","url":"https://api.github.com/users/AkA84","html_url":"https://github.com/AkA84","followers_url":"https://api.github.com/users/AkA84/followers","following_url":"https://api.github.com/users/AkA84/following{/other_user}","gists_url":"https://api.github.com/users/AkA84/gists{/gist_id}","starred_url":"https://api.github.com/users/AkA84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AkA84/subscriptions","organizations_url":"https://api.github.com/users/AkA84/orgs","repos_url":"https://api.github.com/users/AkA84/repos","events_url":"https://api.github.com/users/AkA84/events{/privacy}","received_events_url":"https://api.github.com/users/AkA84/received_events","type":"User","site_admin":false},"body":"unnecessary comment, the code is self explanatory","created_at":"2017-10-10T09:00:28Z","updated_at":"2017-10-10T09:01:40Z","html_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/265#discussion_r143667541","pull_request_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments/143667541"},"html":{"href":"https://github.com/compucorp/civihr-tasks-assignments/pull/265#discussion_r143667541"},"pull_request":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265"}}},"pull_request":{"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265","id":145487717,"html_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/265","diff_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/265.diff","patch_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/265.patch","issue_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/265","number":265,"state":"open","locked":false,"title":"PCHR-2457: Document open buttons take very long to load on ssp","user":{"login":"bmnepali","id":6307362,"avatar_url":"https://avatars2.githubusercontent.com/u/6307362?v=4","gravatar_id":"","url":"https://api.github.com/users/bmnepali","html_url":"https://github.com/bmnepali","followers_url":"https://api.github.com/users/bmnepali/followers","following_url":"https://api.github.com/users/bmnepali/following{/other_user}","gists_url":"https://api.github.com/users/bmnepali/gists{/gist_id}","starred_url":"https://api.github.com/users/bmnepali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmnepali/subscriptions","organizations_url":"https://api.github.com/users/bmnepali/orgs","repos_url":"https://api.github.com/users/bmnepali/repos","events_url":"https://api.github.com/users/bmnepali/events{/privacy}","received_events_url":"https://api.github.com/users/bmnepali/received_events","type":"User","site_admin":false},"body":"## Overview\r\nThis PR makes necessary changes in T&A document modal markup and modal controller to make the spinner load in document modal with all correct data in SSP.\r\n\r\n**Note:** \r\nBefore and after sections are describes in https://github.com/compucorp/civihr-employee-portal/pull/358\r\n\r\n## Technical Details\r\n1. Add the `<crm-loading></crm-loading>` directive in document modal markup:\r\n```html\r\n<crm-loading ng-if=“isLoading\"></crm-loading>\r\n<div ng-if=“!isLoading\" class=\"modal-body\" nv-file-drop uploader=\"documentModal.uploader\">\r\n   …\r\n</div>\r\n<div ng-if=“!isLoading\" class=\"modal-footer\">\r\n   …\r\n<div>\r\n```\r\n\r\n2. Use \"common/directives/loading\" in run.module.js in T&A.\r\n```js\r\ndefine[\r\n   ...\r\n   common/directives/loading,\r\n   ...\r\n   function () { \r\n   ...\r\n   }]\r\n```\r\n\r\n3. Separate the code to collect contacts in a new function. The need to separate is that we have to frequently update the contacts bases on the changes in cached contacts array.\r\n \r\n```js\r\nfunction collectContacts () {\r\n   vm.contacts = {\r\n        target: initialContacts('target'),\r\n        assignee: initialContacts('assignee')\r\n   };\r\n}\r\n```\r\n  \r\n4. Watch for the change in contact search array and update the contacts when there is a change in cached contacts. The need to watch the cached contacts is that, when a document modal is opened form SSP, the modal is loaded before the contacts are loaded and cached which makes the collected contacts not up-to-date. So, when the contacts are loaded and cached we are re-collecting the contacts in T&A document modal controller using `collectContacts()` function.\r\n\r\n```js\r\nfunction watchForChanges () {\r\n   // Watches the changes in cached contacts search array\r\n   $rootScope.$watch('cache.contact.arrSearch', function (newValue) {\r\n      // Update the collected contacts\r\n      collectContacts();\r\n   });\r\n}\r\n```\r\n\r\n5. Call function to college and watch contact search array in controller initialize. Also define \"isLoading\" variable in \"$rootscope\" for check if the state is in loading anything in background.\r\n\r\n```js\r\n(function init () {\r\n    $rootScope.isLoading = false;\r\n    ...\r\n    collectContacts();\r\n    watchForChanges();\r\n})();\r\n```\r\n\r\n- [x] Tests Pass\r\n","created_at":"2017-10-09T15:48:24Z","updated_at":"2017-10-10T09:01:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"95ec58eaff64e2396a579e1505bfa323334bea52","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265/commits","review_comments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265/comments","review_comment_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments{/number}","comments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/265/comments","statuses_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/d1a53840ead50d6d3788881a4d1bb57d41bf18a7","head":{"label":"compucorp:PCHR-2457-document-open-buttons-take-very-long-to-load-on-SSP","ref":"PCHR-2457-document-open-buttons-take-very-long-to-load-on-SSP","sha":"d1a53840ead50d6d3788881a4d1bb57d41bf18a7","user":{"login":"compucorp","id":2040164,"avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"repo":{"id":33719821,"name":"civihr-tasks-assignments","full_name":"compucorp/civihr-tasks-assignments","owner":{"login":"compucorp","id":2040164,"avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/compucorp/civihr-tasks-assignments","description":null,"fork":false,"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments","forks_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/forks","keys_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/teams","hooks_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/hooks","issue_events_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/events{/number}","events_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/events","assignees_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/assignees{/user}","branches_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/branches{/branch}","tags_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/tags","blobs_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/refs{/sha}","trees_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/{sha}","languages_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/languages","stargazers_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/stargazers","contributors_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/contributors","subscribers_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/subscribers","subscription_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/subscription","commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/commits{/sha}","git_commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/commits{/sha}","comments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/comments{/number}","issue_comment_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/comments{/number}","contents_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/contents/{+path}","compare_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/merges","archive_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/downloads","issues_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues{/number}","pulls_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls{/number}","milestones_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/milestones{/number}","notifications_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/labels{/name}","releases_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/releases{/id}","deployments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/deployments","created_at":"2015-04-10T09:18:16Z","updated_at":"2017-02-22T10:19:31Z","pushed_at":"2017-10-09T15:48:24Z","git_url":"git://github.com/compucorp/civihr-tasks-assignments.git","ssh_url":"git@github.com:compucorp/civihr-tasks-assignments.git","clone_url":"https://github.com/compucorp/civihr-tasks-assignments.git","svn_url":"https://github.com/compucorp/civihr-tasks-assignments","homepage":null,"size":7683,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"staging"}},"base":{"label":"compucorp:staging","ref":"staging","sha":"bad392b3bc25253c000e55561e12ecb7cdb9c366","user":{"login":"compucorp","id":2040164,"avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"repo":{"id":33719821,"name":"civihr-tasks-assignments","full_name":"compucorp/civihr-tasks-assignments","owner":{"login":"compucorp","id":2040164,"avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/compucorp/civihr-tasks-assignments","description":null,"fork":false,"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments","forks_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/forks","keys_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/teams","hooks_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/hooks","issue_events_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/events{/number}","events_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/events","assignees_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/assignees{/user}","branches_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/branches{/branch}","tags_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/tags","blobs_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/refs{/sha}","trees_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/{sha}","languages_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/languages","stargazers_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/stargazers","contributors_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/contributors","subscribers_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/subscribers","subscription_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/subscription","commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/commits{/sha}","git_commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/git/commits{/sha}","comments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/comments{/number}","issue_comment_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/comments{/number}","contents_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/contents/{+path}","compare_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/merges","archive_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/downloads","issues_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues{/number}","pulls_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls{/number}","milestones_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/milestones{/number}","notifications_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/labels{/name}","releases_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/releases{/id}","deployments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/deployments","created_at":"2015-04-10T09:18:16Z","updated_at":"2017-02-22T10:19:31Z","pushed_at":"2017-10-09T15:48:24Z","git_url":"git://github.com/compucorp/civihr-tasks-assignments.git","ssh_url":"git@github.com:compucorp/civihr-tasks-assignments.git","clone_url":"https://github.com/compucorp/civihr-tasks-assignments.git","svn_url":"https://github.com/compucorp/civihr-tasks-assignments","homepage":null,"size":7683,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265"},"html":{"href":"https://github.com/compucorp/civihr-tasks-assignments/pull/265"},"issue":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/265"},"comments":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/265/comments"},"review_comments":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265/comments"},"review_comment":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/265/commits"},"statuses":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/d1a53840ead50d6d3788881a4d1bb57d41bf18a7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"AkA84"}}