{"action":"created","comment":{"url":"https://api.github.com/repos/google/ggrc-core/pulls/comments/55505130","id":55505130,"diff_hunk":"@@ -0,0 +1,143 @@\n+/*!\n+    Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n+    Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n+    Created By: ivan@reciprocitylabs.com\n+    Maintained By: ivan@reciprocitylabs.com\n+*/\n+\n+(function (can, $) {\n+  /*\n+   * Assessment template main component\n+   *\n+   * It collects fields data and it transforms them into appropriate\n+   * format for saving\n+   */\n+  can.Component.extend({\n+    tag: 'assessment-template-attributes',\n+    template: '<content></content>',\n+    scope: {\n+      fields: new can.List()\n+    }\n+  });\n+\n+  /*\n+   * Template field\n+   *\n+   * Represents each `field` passed from assessment-template-attributes `fields`\n+   */\n+  can.Component.extend({\n+    tag: 'template-filed',\n+    template: can.view(GGRC.mustache_path +\n+      '/assessment_templates/attribute_field.mustache'),\n+    scope: {\n+      /*\n+       * Removes `field` from `fileds`\n+       */\n+      removeField: function (scope, el, ev) {\n+        var fileds = scope.attr('fields');\n+        var field = scope.attr('field');\n+        var index = _.findIndex(fileds, function (item) {\n+          return item.type === field.type && item.title === field.title;\n+        });\n+\n+        ev.preventDefault();\n+        if (index !== -1) {\n+          fileds.splice(index, 1);\n+        }\n+      },\n+      /*\n+       * Split field values\n+       *\n+       * @return {Array} attrs - Returns split values as an array\n+       */\n+      attrs: function () {\n+        return _.splitTrim(this.attr('field.values'), {\n+          compact: true\n+        });\n+      }\n+    }\n+  });\n+  can.Component.extend({\n+    tag: 'add-template-filed',\n+    template: can.view(GGRC.mustache_path +\n+      '/assessment_templates/attribute_add_field.mustache'),\n+    scope: {\n+      selected: new can.Map(),\n+      types: [{\n+        type: 'Dropdown',\n+        text: 'Type values separated by comma'\n+      }, {\n+        type: 'Checkbox',\n+        text: 'Type label'\n+      }, {\n+        type: 'Radio',\n+        text: 'Type values separated by comma'\n+      }, {\n+        type: 'Text',\n+        text: 'Type description'\n+      }],\n+      /*\n+       * Create new field\n+       *\n+       * Field must contain value title, type, values and opts.\n+       * Opts are populated, once we start changing checkbox values\n+       *\n+       * @param {Object} scope - current (add-template-field) scope\n+       * @param {jQuery.Object} el - clicked element\n+       * @param {Object} ev - click event handler\n+       */\n+      addField: function (scope, el, ev) {\n+        var fields = this.attr('fields');\n+        var selected = this.attr('selected');\n+        var title = _.trim(selected.title);\n+        var type = _.trim(selected.type);\n+        var values = _.splitTrim(selected.values, {","path":"src/ggrc/assets/javascripts/components/assessment_attributes.js","position":94,"original_position":94,"commit_id":"38c982f6ec65025594a2e5df548495692af97886","original_commit_id":"38c982f6ec65025594a2e5df548495692af97886","user":{"login":"Smotko","id":513444,"avatar_url":"https://avatars.githubusercontent.com/u/513444?v=3","gravatar_id":"","url":"https://api.github.com/users/Smotko","html_url":"https://github.com/Smotko","followers_url":"https://api.github.com/users/Smotko/followers","following_url":"https://api.github.com/users/Smotko/following{/other_user}","gists_url":"https://api.github.com/users/Smotko/gists{/gist_id}","starred_url":"https://api.github.com/users/Smotko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Smotko/subscriptions","organizations_url":"https://api.github.com/users/Smotko/orgs","repos_url":"https://api.github.com/users/Smotko/repos","events_url":"https://api.github.com/users/Smotko/events{/privacy}","received_events_url":"https://api.github.com/users/Smotko/received_events","type":"User","site_admin":false},"body":"if selected.values are undefined, this will throw a script error.","created_at":"2016-03-09T11:26:16Z","updated_at":"2016-03-09T11:26:16Z","html_url":"https://github.com/google/ggrc-core/pull/3621#discussion_r55505130","pull_request_url":"https://api.github.com/repos/google/ggrc-core/pulls/3621","_links":{"self":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/comments/55505130"},"html":{"href":"https://github.com/google/ggrc-core/pull/3621#discussion_r55505130"},"pull_request":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3621"}}},"pull_request":{"url":"https://api.github.com/repos/google/ggrc-core/pulls/3621","id":60692271,"html_url":"https://github.com/google/ggrc-core/pull/3621","diff_url":"https://github.com/google/ggrc-core/pull/3621.diff","patch_url":"https://github.com/google/ggrc-core/pull/3621.patch","issue_url":"https://api.github.com/repos/google/ggrc-core/issues/3621","number":3621,"state":"open","locked":false,"title":"CORE-3154 Add AssessmentTemplate entity","user":{"login":"plamut","id":1235663,"avatar_url":"https://avatars.githubusercontent.com/u/1235663?v=3","gravatar_id":"","url":"https://api.github.com/users/plamut","html_url":"https://github.com/plamut","followers_url":"https://api.github.com/users/plamut/followers","following_url":"https://api.github.com/users/plamut/following{/other_user}","gists_url":"https://api.github.com/users/plamut/gists{/gist_id}","starred_url":"https://api.github.com/users/plamut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamut/subscriptions","organizations_url":"https://api.github.com/users/plamut/orgs","repos_url":"https://api.github.com/users/plamut/repos","events_url":"https://api.github.com/users/plamut/events{/privacy}","received_events_url":"https://api.github.com/users/plamut/received_events","type":"User","site_admin":false},"body":"This is the first working version of the PR. It is now possible to open an AssessmentTemplate modal (from the Audit's info pane only) and create a new AssessmentTemplate.\r\n\r\nIt probably needs more polishing, e.g. conditionally enabling/disabling form fields based on their values. \r\n\r\nWe probably also need a way to edit an existing Audit's AssessmentTemplate, but to my knowledge we don't have UI mockups to see how an Audit's existing (if any) AssessmentTemplate should be shown. Might be better to resolve this under a separate ticket...\r\n\r\nI am also not sure about the status of the custom attributes functionality, please ping @hyperNURb for that.\r\n\r\n**Update:** It seems that there are a lot of failed and erroneous Selenium/integration tests, lots of timeout errors in the Jenkins build log. Not sure whether this PR has caused them, or if there is some \"external\" cause...","created_at":"2016-02-25T15:06:22Z","updated_at":"2016-03-09T11:26:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"000f553d1d0b956dec5908b0ebf13f812237cf5d","assignee":null,"milestone":{"url":"https://api.github.com/repos/google/ggrc-core/milestones/16","html_url":"https://github.com/google/ggrc-core/milestones/0.9.6-Plum%20Jelly","labels_url":"https://api.github.com/repos/google/ggrc-core/milestones/16/labels","id":1058061,"number":16,"title":"0.9.6-Plum Jelly","description":"","creator":{"login":"Smotko","id":513444,"avatar_url":"https://avatars.githubusercontent.com/u/513444?v=3","gravatar_id":"","url":"https://api.github.com/users/Smotko","html_url":"https://github.com/Smotko","followers_url":"https://api.github.com/users/Smotko/followers","following_url":"https://api.github.com/users/Smotko/following{/other_user}","gists_url":"https://api.github.com/users/Smotko/gists{/gist_id}","starred_url":"https://api.github.com/users/Smotko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Smotko/subscriptions","organizations_url":"https://api.github.com/users/Smotko/orgs","repos_url":"https://api.github.com/users/Smotko/repos","events_url":"https://api.github.com/users/Smotko/events{/privacy}","received_events_url":"https://api.github.com/users/Smotko/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":195,"state":"open","created_at":"2015-04-08T11:38:13Z","updated_at":"2016-03-09T10:31:35Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/google/ggrc-core/pulls/3621/commits","review_comments_url":"https://api.github.com/repos/google/ggrc-core/pulls/3621/comments","review_comment_url":"https://api.github.com/repos/google/ggrc-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/ggrc-core/issues/3621/comments","statuses_url":"https://api.github.com/repos/google/ggrc-core/statuses/38c982f6ec65025594a2e5df548495692af97886","head":{"label":"plamut:feature/core-3154","ref":"feature/core-3154","sha":"38c982f6ec65025594a2e5df548495692af97886","user":{"login":"plamut","id":1235663,"avatar_url":"https://avatars.githubusercontent.com/u/1235663?v=3","gravatar_id":"","url":"https://api.github.com/users/plamut","html_url":"https://github.com/plamut","followers_url":"https://api.github.com/users/plamut/followers","following_url":"https://api.github.com/users/plamut/following{/other_user}","gists_url":"https://api.github.com/users/plamut/gists{/gist_id}","starred_url":"https://api.github.com/users/plamut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamut/subscriptions","organizations_url":"https://api.github.com/users/plamut/orgs","repos_url":"https://api.github.com/users/plamut/repos","events_url":"https://api.github.com/users/plamut/events{/privacy}","received_events_url":"https://api.github.com/users/plamut/received_events","type":"User","site_admin":false},"repo":{"id":46784845,"name":"ggrc-core","full_name":"plamut/ggrc-core","owner":{"login":"plamut","id":1235663,"avatar_url":"https://avatars.githubusercontent.com/u/1235663?v=3","gravatar_id":"","url":"https://api.github.com/users/plamut","html_url":"https://github.com/plamut","followers_url":"https://api.github.com/users/plamut/followers","following_url":"https://api.github.com/users/plamut/following{/other_user}","gists_url":"https://api.github.com/users/plamut/gists{/gist_id}","starred_url":"https://api.github.com/users/plamut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamut/subscriptions","organizations_url":"https://api.github.com/users/plamut/orgs","repos_url":"https://api.github.com/users/plamut/repos","events_url":"https://api.github.com/users/plamut/events{/privacy}","received_events_url":"https://api.github.com/users/plamut/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/plamut/ggrc-core","description":"GGRC Core","fork":true,"url":"https://api.github.com/repos/plamut/ggrc-core","forks_url":"https://api.github.com/repos/plamut/ggrc-core/forks","keys_url":"https://api.github.com/repos/plamut/ggrc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plamut/ggrc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plamut/ggrc-core/teams","hooks_url":"https://api.github.com/repos/plamut/ggrc-core/hooks","issue_events_url":"https://api.github.com/repos/plamut/ggrc-core/issues/events{/number}","events_url":"https://api.github.com/repos/plamut/ggrc-core/events","assignees_url":"https://api.github.com/repos/plamut/ggrc-core/assignees{/user}","branches_url":"https://api.github.com/repos/plamut/ggrc-core/branches{/branch}","tags_url":"https://api.github.com/repos/plamut/ggrc-core/tags","blobs_url":"https://api.github.com/repos/plamut/ggrc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plamut/ggrc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plamut/ggrc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/plamut/ggrc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plamut/ggrc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/plamut/ggrc-core/languages","stargazers_url":"https://api.github.com/repos/plamut/ggrc-core/stargazers","contributors_url":"https://api.github.com/repos/plamut/ggrc-core/contributors","subscribers_url":"https://api.github.com/repos/plamut/ggrc-core/subscribers","subscription_url":"https://api.github.com/repos/plamut/ggrc-core/subscription","commits_url":"https://api.github.com/repos/plamut/ggrc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/plamut/ggrc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/plamut/ggrc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/plamut/ggrc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/plamut/ggrc-core/contents/{+path}","compare_url":"https://api.github.com/repos/plamut/ggrc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plamut/ggrc-core/merges","archive_url":"https://api.github.com/repos/plamut/ggrc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plamut/ggrc-core/downloads","issues_url":"https://api.github.com/repos/plamut/ggrc-core/issues{/number}","pulls_url":"https://api.github.com/repos/plamut/ggrc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/plamut/ggrc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/plamut/ggrc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plamut/ggrc-core/labels{/name}","releases_url":"https://api.github.com/repos/plamut/ggrc-core/releases{/id}","deployments_url":"https://api.github.com/repos/plamut/ggrc-core/deployments","created_at":"2015-11-24T10:37:33Z","updated_at":"2016-02-05T19:04:35Z","pushed_at":"2016-03-08T15:23:49Z","git_url":"git://github.com/plamut/ggrc-core.git","ssh_url":"git@github.com:plamut/ggrc-core.git","clone_url":"https://github.com/plamut/ggrc-core.git","svn_url":"https://github.com/plamut/ggrc-core","homepage":null,"size":50159,"stargazers_count":1,"watchers_count":1,"language":"Python","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":1,"default_branch":"develop"}},"base":{"label":"google:develop","ref":"develop","sha":"125faec8980e06baee59cc61fef9d7607b693c18","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":9304637,"name":"ggrc-core","full_name":"google/ggrc-core","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/ggrc-core","description":"GGRC Core","fork":false,"url":"https://api.github.com/repos/google/ggrc-core","forks_url":"https://api.github.com/repos/google/ggrc-core/forks","keys_url":"https://api.github.com/repos/google/ggrc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/ggrc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/ggrc-core/teams","hooks_url":"https://api.github.com/repos/google/ggrc-core/hooks","issue_events_url":"https://api.github.com/repos/google/ggrc-core/issues/events{/number}","events_url":"https://api.github.com/repos/google/ggrc-core/events","assignees_url":"https://api.github.com/repos/google/ggrc-core/assignees{/user}","branches_url":"https://api.github.com/repos/google/ggrc-core/branches{/branch}","tags_url":"https://api.github.com/repos/google/ggrc-core/tags","blobs_url":"https://api.github.com/repos/google/ggrc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/ggrc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/ggrc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/ggrc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/ggrc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/google/ggrc-core/languages","stargazers_url":"https://api.github.com/repos/google/ggrc-core/stargazers","contributors_url":"https://api.github.com/repos/google/ggrc-core/contributors","subscribers_url":"https://api.github.com/repos/google/ggrc-core/subscribers","subscription_url":"https://api.github.com/repos/google/ggrc-core/subscription","commits_url":"https://api.github.com/repos/google/ggrc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/ggrc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/ggrc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/ggrc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/ggrc-core/contents/{+path}","compare_url":"https://api.github.com/repos/google/ggrc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/ggrc-core/merges","archive_url":"https://api.github.com/repos/google/ggrc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/ggrc-core/downloads","issues_url":"https://api.github.com/repos/google/ggrc-core/issues{/number}","pulls_url":"https://api.github.com/repos/google/ggrc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/google/ggrc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/google/ggrc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/ggrc-core/labels{/name}","releases_url":"https://api.github.com/repos/google/ggrc-core/releases{/id}","deployments_url":"https://api.github.com/repos/google/ggrc-core/deployments","created_at":"2013-04-08T19:16:28Z","updated_at":"2016-03-08T00:33:04Z","pushed_at":"2016-03-09T11:24:43Z","git_url":"git://github.com/google/ggrc-core.git","ssh_url":"git@github.com:google/ggrc-core.git","clone_url":"https://github.com/google/ggrc-core.git","svn_url":"https://github.com/google/ggrc-core","homepage":null,"size":56987,"stargazers_count":73,"watchers_count":73,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":10,"forks":47,"open_issues":10,"watchers":73,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3621"},"html":{"href":"https://github.com/google/ggrc-core/pull/3621"},"issue":{"href":"https://api.github.com/repos/google/ggrc-core/issues/3621"},"comments":{"href":"https://api.github.com/repos/google/ggrc-core/issues/3621/comments"},"review_comments":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3621/comments"},"review_comment":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/ggrc-core/pulls/3621/commits"},"statuses":{"href":"https://api.github.com/repos/google/ggrc-core/statuses/38c982f6ec65025594a2e5df548495692af97886"}}}}