{"action":"created","comment":{"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments/131149080","pull_request_review_id":54101430,"id":131149080,"diff_hunk":"@@ -53,13 +53,13 @@ define([\n       });\n \n       it('sets the role as admin by default', function () {\n-        expect($scope.role).toBe('admin');\n+        expect(ctrl.role).toBe('admin');","path":"uk.co.compucorp.civicrm.tasksassignments/js/test/controllers/modal/modal-document.spec.js","position":77,"original_position":77,"commit_id":"3ac4e8643779cd133ee47e711c320672cafbde09","original_commit_id":"3ac4e8643779cd133ee47e711c320672cafbde09","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":"Right! will fix it.","created_at":"2017-08-03T13:59:02Z","updated_at":"2017-08-03T13:59:02Z","html_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/239#discussion_r131149080","pull_request_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239","_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/comments/131149080"},"html":{"href":"https://github.com/compucorp/civihr-tasks-assignments/pull/239#discussion_r131149080"},"pull_request":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239"}}},"pull_request":{"url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239","id":133938965,"html_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/239","diff_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/239.diff","patch_url":"https://github.com/compucorp/civihr-tasks-assignments/pull/239.patch","issue_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/239","number":239,"state":"open","locked":false,"title":"PCHR-2378: Open files to preview in browser from documents modal","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\nCurrently, in the document modal. When there are attachments and when clicked in one of them they instantly get downloaded. Whereas the documents like pdf and images should open in new tab. This PR fixes to open the documents like pdf, images in new tab.\r\n\r\n## Before\r\n- The documents directly gets downloaded.\r\n![before-2378-min](https://user-images.githubusercontent.com/6307362/28923145-b9c2047e-787c-11e7-8d18-320b4b6f7b75.gif)\r\n\r\n## After\r\n- The documents like pdf and images are opened in new tab:\r\n![poc-iloveimg-compressed 1](https://user-images.githubusercontent.com/6307362/28922660-c9fbac8e-787a-11e7-8d6e-454c33a98bea.gif)\r\n\r\n## Technical Details\r\n1. A service is created in `reqangular` extension called `fileService`. The `openFile` funtion of the service creates a blob of the given file and opens in the new tab with the appropriate document type. Reference PR for the service https://github.com/civicrm/civihr/pull/2040\r\n\r\n2. Create a function named 'viewFile` in 'modal-document.js` widh displays the spinner till the file is not loaded using `openFile` of the `fileService` and finally hides the spinner once the file is displayed.\r\n```js\r\n...\r\n/**\r\n * Open the given file and display the file in new tab\r\n * @param  {object} file\r\n */\r\n vm.viewFile = function (file) {\r\n    $rootScope.$broadcast('ct-spinner-show');\r\n    fileService.openFile(file).then(function (blobFile) {\r\n        $rootScope.$broadcast('ct-spinner-hide');\r\n    });\r\n};\r\n...\r\n```\r\n3. The `viewFile` function is called when clicked on each of the attachment in document modal in file `uk.co.compucorp.civicrm.tasksassignments/views/modal/document.html`.\r\n```html\r\n...\r\n<td><a href=\"javascript:void(0)\" ng-click=\"documentModal.viewFile(file)\">{{file.name}}</a></td>\r\n...\r\n```\r\n4. Added test cases for the added function `viewFile` in file ` uk.co.compucorp.civicrm.tasksassignments/js/test/controllers/modal/modal-document.spec.js`\r\n\r\n**Additional Changes** \r\nApart from the solution, this PR also adopts the new angularjs guidlines to write angular apps. So, this PR also include couple of more things:\r\n-  Remane test files to ne naming convention  defined in angularjs guide wiki page.\r\n-  Uses ControllerAs Syntax for modal-document.js controller and the modal document template.\r\n-  Refactoring of code in both test and fix files\r\n\r\n- [x] Tests Pass\r\n","created_at":"2017-08-03T13:03:41Z","updated_at":"2017-08-03T13:59:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"473643289ac8ccd0a68e429457a756533603b9ee","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239/commits","review_comments_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239/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/239/comments","statuses_url":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/3ac4e8643779cd133ee47e711c320672cafbde09","head":{"label":"compucorp:PCHR-2378-open-files-to-preview-in-browser-from-documents-modal","ref":"PCHR-2378-open-files-to-preview-in-browser-from-documents-modal","sha":"3ac4e8643779cd133ee47e711c320672cafbde09","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-08-03T13:11:36Z","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":7496,"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":7,"forks":0,"open_issues":7,"watchers":1,"default_branch":"staging"}},"base":{"label":"compucorp:staging","ref":"staging","sha":"b5816f5fe7830955287b6ea28c7b3278bbc5183f","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-08-03T13:11:36Z","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":7496,"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":7,"forks":0,"open_issues":7,"watchers":1,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239"},"html":{"href":"https://github.com/compucorp/civihr-tasks-assignments/pull/239"},"issue":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/239"},"comments":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/pulls/239/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/239/commits"},"statuses":{"href":"https://api.github.com/repos/compucorp/civihr-tasks-assignments/statuses/3ac4e8643779cd133ee47e711c320672cafbde09"}}}}
{"actor":{"display_login":"bmnepali"}}