{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/comments/74294455","id":74294455,"diff_hunk":"@@ -10,26 +10,158 @@ export default CpPanelBodyComponent.extend(PreprintFormFieldMixin, {\n     permissionChanges: {},\n     bibliographicChanges: {},\n     valid: Ember.computed.alias('newContributorId'),\n+    permissionToggle: false,\n+    bibliographicToggle: false,\n+    removalToggle: false,\n+    stillAdmin: Ember.computed('isAdmin', function() {\n+        return this.get('isAdmin');\n+    }),\n+    addState: 'emptyView', // There are 3 view states on left side of Authors panel. Default state just shows search bar.\n+    query: null,\n+    // Total contributor search results\n+    totalSearchResults: Ember.computed('searchResults.[]', function() {\n+        let searchResults = this.get('searchResults');\n+        if (searchResults && searchResults.links) {\n+            return Math.ceil(searchResults.links.meta.total);\n+        } else {\n+            return;\n+        }\n+    }),\n+    // Total pages of contributor search results\n+    pages: Ember.computed('totalSearchResults', function() {\n+        let totalSearchResults = this.get('totalSearchResults');\n+        return Math.ceil(totalSearchResults / 10);\n+    }),\n+    // Search results excluding users that are already contributors\n+    newSearchResults: Ember.computed('searchResults.[]', 'contributors.[]', 'addState', function() {\n+        let searchResults = this.get('searchResults');\n+        let contributors = this.get('contributors');\n+        let userIds = contributors.map((contrib) => contrib.id.split('-')[1]);\n+        return searchResults.filter((result) => !Ember.A(userIds).contains(result.id));\n+    }),\n     actions: {\n-        addContributor(userId, permission, isBibliographic) {\n-            this.sendAction('addContributor', userId, permission, isBibliographic);\n+        // Adds contributor then redraws view - addition of contributor may change which update/remove contributor requests are permitted\n+        addContributor(user) {\n+            this.sendAction('addContributor', user.id, 'write', true);\n+            this.toggleProperty('permissionToggle');\n+            this.toggleProperty('bibliographicToggle');\n+            this.toggleProperty('removalToggle');\n+        },\n+        // Adds unregistered contributor, then clears form and switches back to search view.\n+        // Should wait to transition until request has completed.\n+        addUnregisteredContributor(fullName, email) {\n+            let res = this.attrs.addUnregisteredContributor(fullName, email, 'write', true);\n+            var _this = this;\n+            res.then(function() {\n+                _this.toggleProperty('bibliographicToggle');\n+                _this.toggleProperty('permissionToggle');\n+                _this.toggleProperty('removalToggle');\n+            });\n+            this.set('addState', 'searchView');\n+            this.set('fullName', '');\n+            this.set('email', '');\n+        },\n+        updateQuery(value) {\n+            this.set('query', value);\n         },\n+        // Requests a particular page of user results\n+        findContributors(page) {\n+            var query = this.get('query');\n+            var _this = this;\n+            if (query) {\n+                _this.sendAction('findContributors', query, page);\n+                this.set('addState', 'searchView');\n+            }\n+        },\n+        // Removes contributor then redraws contributor list view - removal of contributor may change\n+        // which additional update/remove requests are permitted.\n         removeContributor(contrib) {\n             this.sendAction('removeContributor', contrib);\n+            this.toggleProperty('removalToggle');\n+            this.toggleProperty('permissionToggle');\n+            this.toggleProperty('bibliographicToggle');\n+            this.removedSelfAsAdmin(contrib, contrib.get('permission'));\n+            this.get('contributors').removeObject(contrib);\n         },\n-        permissionChange(contributor, permission) {\n+        // Updates contributor then redraws contributor list view - updating contributor\n+        // permissions may change which additional update/remove requests are permitted.\n+        updatePermissions(contributor, permission) {\n             this.set(`permissionChanges.${contributor.id}`, permission.toLowerCase());\n+            this.sendAction(","path":"app/components/preprint-form-authors.js","position":93,"original_position":93,"commit_id":"a24a41d32ab3e2c90783a9f1cb4998def3bbd178","original_commit_id":"a24a41d32ab3e2c90783a9f1cb4998def3bbd178","user":{"login":"abought","id":2957073,"avatar_url":"https://avatars.githubusercontent.com/u/2957073?v=3","gravatar_id":"","url":"https://api.github.com/users/abought","html_url":"https://github.com/abought","followers_url":"https://api.github.com/users/abought/followers","following_url":"https://api.github.com/users/abought/following{/other_user}","gists_url":"https://api.github.com/users/abought/gists{/gist_id}","starred_url":"https://api.github.com/users/abought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abought/subscriptions","organizations_url":"https://api.github.com/users/abought/orgs","repos_url":"https://api.github.com/users/abought/repos","events_url":"https://api.github.com/users/abought/events{/privacy}","received_events_url":"https://api.github.com/users/abought/received_events","type":"User","site_admin":false},"body":"Closure actions, error handling... you know the drill, but tagging this where noted.","created_at":"2016-08-10T17:48:41Z","updated_at":"2016-08-10T17:48:41Z","html_url":"https://github.com/CenterForOpenScience/ember-preprints/pull/19#discussion_r74294455","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/comments/74294455"},"html":{"href":"https://github.com/CenterForOpenScience/ember-preprints/pull/19#discussion_r74294455"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19","id":80728699,"html_url":"https://github.com/CenterForOpenScience/ember-preprints/pull/19","diff_url":"https://github.com/CenterForOpenScience/ember-preprints/pull/19.diff","patch_url":"https://github.com/CenterForOpenScience/ember-preprints/pull/19.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/19","number":19,"state":"open","locked":false,"title":"[WIP] Feature/Author Management [PREP-81]","user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"body":"<h3> Ticket </h3>\r\nhttps://openscience.atlassian.net/browse/PREP-81\r\n\r\n<h3> Purpose </h3>\r\n\r\nAdds author management for preprints.  \r\n❗ Needs companions ember-osf PR https://github.com/CenterForOpenScience/ember-osf/pull/111, https://github.com/CenterForOpenScience/osf.io/pull/6130, https://github.com/CenterForOpenScience/osf.io/pull/6090\r\n\r\n<h3>  TODO  </h3>\r\n- [x] List contributors\r\n- [x] Add contributors\r\n- [x] Search contributors (currently filtering on v2 users)\r\n- [x] Paginate contributor search results (needs https://github.com/CenterForOpenScience/ember-osf/pull/111)\r\n- [x] Add unregistered contributors\r\n- [x] Update contributors (each modification sends immediate request rather than bulk updates)\r\n- [x] Remove contributors\r\n- [x] Popovers with explanations\r\n- [x] Allow cookie auth to work for creating unregistered contributors https://github.com/CenterForOpenScience/osf.io/pull/6130\r\n- [x] Template logic to minimize requests that will fail (instead of modals informing user that request is not allowed, or allowing request to go through and using growl box).  Disable buttons when clicking will result in failed request.\r\n- [x] Sending emails for unregistered contributors (HOLD - can follow demo)\r\n- [ ] Get rid of hardcoding node in route.\r\n- [ ] Unregistered contributors added here are missing field used to determine permissions checking.  Because this field is missing, if an unregistered contributor is added in the demo, it is possible that some requests may be allowed to go through that would be prevented in the UI otherwise. \r\n- [ ] Drag and drop (API v2 additions pending)\r\n- [ ] Catching API v2 errors\r\n\r\n<h3> Current State</h3>\r\n![screen shot 2016-08-09 at 10 55 19 pm](https://cloud.githubusercontent.com/assets/9755598/17540963/f23ad970-5e88-11e6-9c88-182467fb66ae.png)\r\n","created_at":"2016-08-10T03:20:00Z","updated_at":"2016-08-10T17:48:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84bb47f4ee37d0d430f68aba22e4ca6be11b3ab7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/19/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/statuses/a24a41d32ab3e2c90783a9f1cb4998def3bbd178","head":{"label":"pattisdr:feature/author-management","ref":"feature/author-management","sha":"a24a41d32ab3e2c90783a9f1cb4998def3bbd178","user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"repo":{"id":64675120,"name":"ember-preprints","full_name":"pattisdr/ember-preprints","owner":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pattisdr/ember-preprints","description":null,"fork":true,"url":"https://api.github.com/repos/pattisdr/ember-preprints","forks_url":"https://api.github.com/repos/pattisdr/ember-preprints/forks","keys_url":"https://api.github.com/repos/pattisdr/ember-preprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pattisdr/ember-preprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pattisdr/ember-preprints/teams","hooks_url":"https://api.github.com/repos/pattisdr/ember-preprints/hooks","issue_events_url":"https://api.github.com/repos/pattisdr/ember-preprints/issues/events{/number}","events_url":"https://api.github.com/repos/pattisdr/ember-preprints/events","assignees_url":"https://api.github.com/repos/pattisdr/ember-preprints/assignees{/user}","branches_url":"https://api.github.com/repos/pattisdr/ember-preprints/branches{/branch}","tags_url":"https://api.github.com/repos/pattisdr/ember-preprints/tags","blobs_url":"https://api.github.com/repos/pattisdr/ember-preprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pattisdr/ember-preprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pattisdr/ember-preprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/pattisdr/ember-preprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pattisdr/ember-preprints/statuses/{sha}","languages_url":"https://api.github.com/repos/pattisdr/ember-preprints/languages","stargazers_url":"https://api.github.com/repos/pattisdr/ember-preprints/stargazers","contributors_url":"https://api.github.com/repos/pattisdr/ember-preprints/contributors","subscribers_url":"https://api.github.com/repos/pattisdr/ember-preprints/subscribers","subscription_url":"https://api.github.com/repos/pattisdr/ember-preprints/subscription","commits_url":"https://api.github.com/repos/pattisdr/ember-preprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/pattisdr/ember-preprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/pattisdr/ember-preprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/pattisdr/ember-preprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/pattisdr/ember-preprints/contents/{+path}","compare_url":"https://api.github.com/repos/pattisdr/ember-preprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pattisdr/ember-preprints/merges","archive_url":"https://api.github.com/repos/pattisdr/ember-preprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pattisdr/ember-preprints/downloads","issues_url":"https://api.github.com/repos/pattisdr/ember-preprints/issues{/number}","pulls_url":"https://api.github.com/repos/pattisdr/ember-preprints/pulls{/number}","milestones_url":"https://api.github.com/repos/pattisdr/ember-preprints/milestones{/number}","notifications_url":"https://api.github.com/repos/pattisdr/ember-preprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pattisdr/ember-preprints/labels{/name}","releases_url":"https://api.github.com/repos/pattisdr/ember-preprints/releases{/id}","deployments_url":"https://api.github.com/repos/pattisdr/ember-preprints/deployments","created_at":"2016-08-01T14:45:25Z","updated_at":"2016-08-01T14:45:26Z","pushed_at":"2016-08-10T16:22:56Z","git_url":"git://github.com/pattisdr/ember-preprints.git","ssh_url":"git@github.com:pattisdr/ember-preprints.git","clone_url":"https://github.com/pattisdr/ember-preprints.git","svn_url":"https://github.com/pattisdr/ember-preprints","homepage":null,"size":8571,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"dca3e5e84c6d0565de69623ec62a79e10e01892b","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":63790282,"name":"ember-preprints","full_name":"CenterForOpenScience/ember-preprints","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/ember-preprints","description":null,"fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints","forks_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/deployments","created_at":"2016-07-20T14:56:36Z","updated_at":"2016-07-20T14:58:52Z","pushed_at":"2016-08-10T17:40:26Z","git_url":"git://github.com/CenterForOpenScience/ember-preprints.git","ssh_url":"git@github.com:CenterForOpenScience/ember-preprints.git","clone_url":"https://github.com/CenterForOpenScience/ember-preprints.git","svn_url":"https://github.com/CenterForOpenScience/ember-preprints","homepage":null,"size":9279,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":6,"forks":10,"open_issues":6,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19"},"html":{"href":"https://github.com/CenterForOpenScience/ember-preprints/pull/19"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/19"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/ember-preprints/statuses/a24a41d32ab3e2c90783a9f1cb4998def3bbd178"}}}}
{"actor":{"display_login":"abought"}}