{"action":"created","comment":{"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments/41520575","id":41520575,"diff_hunk":"@@ -0,0 +1,230 @@\n+/*\n+ * Copyright (C) eZ Systems AS. All rights reserved.\n+ * For full copyright and license information view LICENSE file distributed with this source code.\n+ */\n+YUI.add('ez-roleserversideviewservice', function (Y) {\n+    \"use strict\";\n+    /**\n+     * Provides the role server side view service class\n+     *\n+     * @method ez-roleserversideviewservice\n+     */\n+    Y.namespace('eZ');\n+\n+    /**\n+     * The Role Server Side View Service class.\n+     *\n+     * @namespace eZ\n+     * @class RoleServerSideViewService\n+     * @constructor\n+     * @extends eZ.ServerSideViewService\n+     */\n+    Y.eZ.RoleServerSideViewService = Y.Base.create('roleServerSideViewService', Y.eZ.ServerSideViewService, [], {\n+        initializer: function () {\n+            this.on('*:contentDiscover', function (e) {\n+                e.config.contentDiscoveredHandler = Y.bind(this._assignRole, this);\n+            });\n+        },\n+\n+        /**\n+         * Assign the role to the Content items after the user has chosen them in\n+         * the universal discovery widget\n+         *\n+         * @method _assignRole\n+         * @protected\n+         * @param {EventFacade} e\n+         */\n+        _assignRole: function (e) {\n+            var data = e.target.get('data'),\n+                userService = this.get('capi').getUserService(),\n+                discoveryService = this.get('capi').getDiscoveryService(),\n+                service = this;\n+\n+            this._assignRoleNotificationStarted(\n+                data.roleId, data.roleName, e.selection\n+            );\n+\n+            userService.loadRole(data.roleId, function (error, response) {\n+                var role,\n+                    tasks = new Y.Parallel(),\n+                    end = tasks.add(function (err, response) {\n+                        if (err) {\n+                            service._error('tasks.add() failed: ' + err.message);\n+                            return;\n+                        }\n+\n+                        console.log('end'); // TODO just to let us know that it was picked, error handling should be here\n+                    });\n+\n+                if (error) {\n+                    service._error('loadRole failed: ' + error.message);\n+                    return;\n+                }\n+\n+                role = response.document.Role;\n+\n+                Y.Array.each(e.selection, function (struct) {\n+                    // TODO assign with limitation\n+                    var limitation = null;\n+                    //var limitation = { // DUMMY SECTION DATA\n+                    //    \"_identifier\": \"Section\",\n+                    //    \"values\": {\n+                    //        \"ref\": [{\n+                    //            \"_href\": \"/api/ezp/v2/content/sections/1\",\n+                    //            \"_media-type\": \"application/vnd.ez.api.Section+json\"\n+                    //        }, {\n+                    //            \"_href\": \"/api/ezp/v2/content/sections/4\",\n+                    //            \"_media-type\": \"application/vnd.ez.api.Section+json\"\n+                    //        }]\n+                    //    }\n+                    //};\n+                    //var limitation = { // DUMMY SUBTREE DATA\n+                    //    \"_identifier\": \"Subtree\",\n+                    //    \"values\": {\n+                    //        \"ref\": [{\n+                    //            \"_href\": \"/api/ezp/v2/content/locations/1/5/14\",\n+                    //            \"_media-type\": \"application/vnd.ez.api.Location+json\"\n+                    //        }]\n+                    //    }\n+                    //};\n+\n+                    // Convert hrefs to IDs, required by API\n+                    if (limitation) {\n+                        for ( var i = 0; i < limitation.values.ref.length; i++ ) {\n+                            if (limitation._identifier == \"Section\") {\n+                                limitation.values.ref[i]._href = /\\d+$/.exec(limitation.values.ref[i]._href)[0];\n+                            } else if (limitation._identifier == \"Subtree\") {\n+                                limitation.values.ref[i]._href = /(\\/\\d+)+$/.exec(limitation.values.ref[i]._href)[0];\n+                            }\n+                        }\n+                    }\n+\n+                    var roleAssignInputStruct = userService.newRoleAssignInputStruct(role, limitation),\n+                        contentTypeIdentifier = struct.contentType.get('identifier');\n+\n+                    if (contentTypeIdentifier === 'user') {\n+                        discoveryService.getInfoObject('users', function (error, usersInfoObject) {\n+                            if (error) {\n+                                service._error('getInfoObject for \"users\" failed: ' + error.message);\n+                                return;\n+                            }\n+\n+                            // We need a user ID, e.g.: /api/ezp/v2/user/users/10\n+                            var userIdStr = usersInfoObject._href + '/' + struct.content.get('contentId');","path":"Resources/public/js/views/services/ez-roleserversideviewservice.js","position":113,"original_position":113,"commit_id":"2efe7e9f2317cea468aa9c3851a0fed4bc19bfb7","original_commit_id":"2efe7e9f2317cea468aa9c3851a0fed4bc19bfb7","user":{"login":"mhyndle","id":8654481,"avatar_url":"https://avatars.githubusercontent.com/u/8654481?v=3","gravatar_id":"","url":"https://api.github.com/users/mhyndle","html_url":"https://github.com/mhyndle","followers_url":"https://api.github.com/users/mhyndle/followers","following_url":"https://api.github.com/users/mhyndle/following{/other_user}","gists_url":"https://api.github.com/users/mhyndle/gists{/gist_id}","starred_url":"https://api.github.com/users/mhyndle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhyndle/subscriptions","organizations_url":"https://api.github.com/users/mhyndle/orgs","repos_url":"https://api.github.com/users/mhyndle/repos","events_url":"https://api.github.com/users/mhyndle/events{/privacy}","received_events_url":"https://api.github.com/users/mhyndle/received_events","type":"User","site_admin":false},"body":"Should be declared in the beginning of function as indefined variable: `var userIdStr;` and here the value should be just binded: `userIdStr = usersInfoObject._href + '/' + struct.content.get('contentId');`","created_at":"2015-10-08T14:34:14Z","updated_at":"2015-10-08T14:34:14Z","html_url":"https://github.com/ezsystems/PlatformUIBundle/pull/344#discussion_r41520575","pull_request_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344","_links":{"self":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments/41520575"},"html":{"href":"https://github.com/ezsystems/PlatformUIBundle/pull/344#discussion_r41520575"},"pull_request":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344"}}},"pull_request":{"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344","id":45789812,"html_url":"https://github.com/ezsystems/PlatformUIBundle/pull/344","diff_url":"https://github.com/ezsystems/PlatformUIBundle/pull/344.diff","patch_url":"https://github.com/ezsystems/PlatformUIBundle/pull/344.patch","issue_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/344","number":344,"state":"open","locked":false,"title":"Fix EZP-24700: Role assignment CRUD","user":{"login":"glye","id":289744,"avatar_url":"https://avatars.githubusercontent.com/u/289744?v=3","gravatar_id":"","url":"https://api.github.com/users/glye","html_url":"https://github.com/glye","followers_url":"https://api.github.com/users/glye/followers","following_url":"https://api.github.com/users/glye/following{/other_user}","gists_url":"https://api.github.com/users/glye/gists{/gist_id}","starred_url":"https://api.github.com/users/glye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glye/subscriptions","organizations_url":"https://api.github.com/users/glye/orgs","repos_url":"https://api.github.com/users/glye/repos","events_url":"https://api.github.com/users/glye/events{/privacy}","received_events_url":"https://api.github.com/users/glye/received_events","type":"User","site_admin":false},"body":"TODO:\r\n- [x] Assign to user\r\n- [x] Assign to user group\r\n- [x] ~~Update assignment~~ (not really needed)\r\n- [x] Delete assignment\r\n- [x] ~~UDW should filter out anything but users and groups~~ (this isn't currently possible)\r\n- [x] ~~Handle assignment limitations - needs UI mockup. Multiple screens/dialogs.~~ Follow-up: https://jira.ez.no/browse/EZP-24905\r\n\r\nhttps://jira.ez.no/browse/EZP-24700","created_at":"2015-09-23T15:00:01Z","updated_at":"2015-10-08T14:34:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fb285087ce44b85bbe8b3e63a00f38c4c9dd34a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344/commits","review_comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344/comments","review_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/344/comments","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/2efe7e9f2317cea468aa9c3851a0fed4bc19bfb7","head":{"label":"ezsystems:ezp-24700_role_assignment_crud","ref":"ezp-24700_role_assignment_crud","sha":"2efe7e9f2317cea468aa9c3851a0fed4bc19bfb7","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":11221607,"name":"PlatformUIBundle","full_name":"ezsystems/PlatformUIBundle","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/PlatformUIBundle","description":"","fork":false,"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle","forks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/forks","keys_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/teams","hooks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/events","assignees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/tags","blobs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/languages","stargazers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscription","commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/merges","archive_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/downloads","issues_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/releases{/id}","created_at":"2013-07-06T17:21:40Z","updated_at":"2015-09-01T10:58:26Z","pushed_at":"2015-10-08T13:46:20Z","git_url":"git://github.com/ezsystems/PlatformUIBundle.git","ssh_url":"git@github.com:ezsystems/PlatformUIBundle.git","clone_url":"https://github.com/ezsystems/PlatformUIBundle.git","svn_url":"https://github.com/ezsystems/PlatformUIBundle","homepage":"","size":9667,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":16,"forks":20,"open_issues":16,"watchers":23,"default_branch":"master"}},"base":{"label":"ezsystems:master","ref":"master","sha":"b6414cc1c066e285f3a17c40613944801b646d4f","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":11221607,"name":"PlatformUIBundle","full_name":"ezsystems/PlatformUIBundle","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/PlatformUIBundle","description":"","fork":false,"url":"https://api.github.com/repos/ezsystems/PlatformUIBundle","forks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/forks","keys_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/teams","hooks_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/events","assignees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/tags","blobs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/languages","stargazers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/subscription","commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/merges","archive_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/downloads","issues_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/PlatformUIBundle/releases{/id}","created_at":"2013-07-06T17:21:40Z","updated_at":"2015-09-01T10:58:26Z","pushed_at":"2015-10-08T13:46:20Z","git_url":"git://github.com/ezsystems/PlatformUIBundle.git","ssh_url":"git@github.com:ezsystems/PlatformUIBundle.git","clone_url":"https://github.com/ezsystems/PlatformUIBundle.git","svn_url":"https://github.com/ezsystems/PlatformUIBundle","homepage":"","size":9667,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":16,"forks":20,"open_issues":16,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344"},"html":{"href":"https://github.com/ezsystems/PlatformUIBundle/pull/344"},"issue":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/344"},"comments":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/issues/344/comments"},"review_comments":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344/comments"},"review_comment":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/pulls/344/commits"},"statuses":{"href":"https://api.github.com/repos/ezsystems/PlatformUIBundle/statuses/2efe7e9f2317cea468aa9c3851a0fed4bc19bfb7"}}}}