{"action":"created","comment":{"url":"https://api.github.com/repos/18F/C2/pulls/comments/42536357","id":42536357,"diff_hunk":"@@ -1,45 +1,29 @@\n-class Filter\n-  constructor: ($root, @key) ->\n-    @$ = (selector) -> $root.find(selector)\n+class @Filter\n+  constructor: (@$root, @$control) ->\n+    key = @$control.data('filter-control')\n+    val = @$control.val()\n+    @set = new FilterSet(@$root, key, val)\n \n-  addInput: ($el) ->\n-    $el.click () => @filter($el)\n-    # Initial state\n-    if $el.is(\":checked\")\n-      @filter($el)\n+  isSelected: ->\n+    @$control.is(':checked')\n \n-  addRadios: () ->\n-    @$(\"input:radio[data-filter-control=#{ @key }]\").each (idx, control) =>\n-      @addInput($(control))\n+  update: ->\n+    if @isSelected()\n+      @set.show()\n+    else\n+      @set.hide()\n \n-  addChkBoxes: () ->\n-    @$(\"input:checkbox[data-filter-control=#{ @key }]\").each (idx, control) =>\n-      @addInput($(control))\n+  enable: ->\n+    @update()\n+    @$control.change => @update()\n \n-  filter: ($el) ->\n-    value = $el.val()\n-    if !$el.is(\":checked\")\n-      value = \"!\" + value\n-    @$(\"[data-filter-key=#{ @key }]\").each (idx, el) ->\n-      hidden = el.getAttribute(\"data-filter-value\") != value\n-      el.setAttribute(\"aria-hidden\", hidden.toString())\n-\n-  hideAll: () ->\n-    @$(\"[data-filter-key=#{ @key }]\").attr(\"aria-hidden\", true)\n-\n-  this.generateIn = ($scope) ->\n-    filters = {}\n-    $scope.find(\"[data-filter-control]\").each (idx, el) ->\n-      key = el.getAttribute('data-filter-control')\n-      if !filters.hasOwnProperty(key)\n-        filters[key] = new Filter($scope, key)\n-    filters\n+  @generateIn = ($scope) ->\n+    $scope.find('[data-filter-control]').map (idx, control) ->\n+      new Filter($scope, $(control))\n \n $ ->\n   #  @todo - better scope","path":"app/assets/javascripts/filter.js.coffee","position":57,"original_position":57,"commit_id":"7dc27193e3fe7501e59e3cb4fd6273a77c77bf5c","original_commit_id":"7dc27193e3fe7501e59e3cb4fd6273a77c77bf5c","user":{"login":"jessieay","id":601515,"avatar_url":"https://avatars.githubusercontent.com/u/601515?v=3","gravatar_id":"","url":"https://api.github.com/users/jessieay","html_url":"https://github.com/jessieay","followers_url":"https://api.github.com/users/jessieay/followers","following_url":"https://api.github.com/users/jessieay/following{/other_user}","gists_url":"https://api.github.com/users/jessieay/gists{/gist_id}","starred_url":"https://api.github.com/users/jessieay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessieay/subscriptions","organizations_url":"https://api.github.com/users/jessieay/orgs","repos_url":"https://api.github.com/users/jessieay/repos","events_url":"https://api.github.com/users/jessieay/events{/privacy}","received_events_url":"https://api.github.com/users/jessieay/received_events","type":"User","site_admin":false},"body":"remove comment since scope was changed?","created_at":"2015-10-20T18:42:38Z","updated_at":"2015-10-20T18:42:38Z","html_url":"https://github.com/18F/C2/pull/658#discussion_r42536357","pull_request_url":"https://api.github.com/repos/18F/C2/pulls/658","_links":{"self":{"href":"https://api.github.com/repos/18F/C2/pulls/comments/42536357"},"html":{"href":"https://github.com/18F/C2/pull/658#discussion_r42536357"},"pull_request":{"href":"https://api.github.com/repos/18F/C2/pulls/658"}}},"pull_request":{"url":"https://api.github.com/repos/18F/C2/pulls/658","id":46718933,"html_url":"https://github.com/18F/C2/pull/658","diff_url":"https://github.com/18F/C2/pull/658.diff","patch_url":"https://github.com/18F/C2/pull/658.patch","issue_url":"https://api.github.com/repos/18F/C2/issues/658","number":658,"state":"open","locked":false,"title":"[Delivers #98157690] add client-side form validation","user":{"login":"afeld","id":86842,"avatar_url":"https://avatars.githubusercontent.com/u/86842?v=3","gravatar_id":"","url":"https://api.github.com/users/afeld","html_url":"https://github.com/afeld","followers_url":"https://api.github.com/users/afeld/followers","following_url":"https://api.github.com/users/afeld/following{/other_user}","gists_url":"https://api.github.com/users/afeld/gists{/gist_id}","starred_url":"https://api.github.com/users/afeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afeld/subscriptions","organizations_url":"https://api.github.com/users/afeld/orgs","repos_url":"https://api.github.com/users/afeld/repos","events_url":"https://api.github.com/users/afeld/events{/privacy}","received_events_url":"https://api.github.com/users/afeld/received_events","type":"User","site_admin":false},"body":"Depends/builds on #656. The diff:\r\n\r\nhttps://github.com/18f/c2/compare/96851664-simplify-forms...98157690-client-side-validation\r\n\r\n## Changes\r\n\r\n* Enables automatic HTML5 form validation via Simple Form\r\n* Includes a refactoring of the client-side form filtering code\r\n* `disable`s the form fields that are hidden by the filter, so that they:\r\n    * Don't get submitted with the form, e.g. sending the `recurring_interval` value when `recurring` isn't checked\r\n    * Don't trigger client-side validation warnings\r\n* Set up JS testing using [Konacha](https://github.com/jfirebaugh/konacha)\r\n* Add tests around the filtering\r\n\r\nYay for limited-internet time to work on this! :steam_locomotive:\r\n\r\n## Testing notes\r\n\r\n* [ ] Ensure that client-side validation works (or at least doesn't break the form) for the normal fields (ideally, in multiple browsers)\r\n* [ ] Ensure that empty `required` hidden fields (e.g. the BA80 fields when `BA61` is selected) don't block submissions of the form\r\n* [ ] Ensure that values from hidden fields aren't getting sent to the server\r\n* [ ] Ensure that Selectize-d fields (the ones with the fancy dropdowns) aren't broken","created_at":"2015-10-04T04:18:05Z","updated_at":"2015-10-20T18:42:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dac84955313ef7461b4d38b326c03cac3cac7ce4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/18F/C2/pulls/658/commits","review_comments_url":"https://api.github.com/repos/18F/C2/pulls/658/comments","review_comment_url":"https://api.github.com/repos/18F/C2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/C2/issues/658/comments","statuses_url":"https://api.github.com/repos/18F/C2/statuses/7dc27193e3fe7501e59e3cb4fd6273a77c77bf5c","head":{"label":"18F:98157690-client-side-validation","ref":"98157690-client-side-validation","sha":"7dc27193e3fe7501e59e3cb4fd6273a77c77bf5c","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":18201810,"name":"C2","full_name":"18F/C2","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/C2","description":"an approval process automation tool","fork":false,"url":"https://api.github.com/repos/18F/C2","forks_url":"https://api.github.com/repos/18F/C2/forks","keys_url":"https://api.github.com/repos/18F/C2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/C2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/C2/teams","hooks_url":"https://api.github.com/repos/18F/C2/hooks","issue_events_url":"https://api.github.com/repos/18F/C2/issues/events{/number}","events_url":"https://api.github.com/repos/18F/C2/events","assignees_url":"https://api.github.com/repos/18F/C2/assignees{/user}","branches_url":"https://api.github.com/repos/18F/C2/branches{/branch}","tags_url":"https://api.github.com/repos/18F/C2/tags","blobs_url":"https://api.github.com/repos/18F/C2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/C2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/C2/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/C2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/C2/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/C2/languages","stargazers_url":"https://api.github.com/repos/18F/C2/stargazers","contributors_url":"https://api.github.com/repos/18F/C2/contributors","subscribers_url":"https://api.github.com/repos/18F/C2/subscribers","subscription_url":"https://api.github.com/repos/18F/C2/subscription","commits_url":"https://api.github.com/repos/18F/C2/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/C2/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/C2/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/C2/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/C2/contents/{+path}","compare_url":"https://api.github.com/repos/18F/C2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/C2/merges","archive_url":"https://api.github.com/repos/18F/C2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/C2/downloads","issues_url":"https://api.github.com/repos/18F/C2/issues{/number}","pulls_url":"https://api.github.com/repos/18F/C2/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/C2/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/C2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/C2/labels{/name}","releases_url":"https://api.github.com/repos/18F/C2/releases{/id}","created_at":"2014-03-28T05:15:23Z","updated_at":"2015-10-09T18:26:20Z","pushed_at":"2015-10-20T17:24:09Z","git_url":"git://github.com/18F/C2.git","ssh_url":"git@github.com:18F/C2.git","clone_url":"https://github.com/18F/C2.git","svn_url":"https://github.com/18F/C2","homepage":"https://cap.18f.gov","size":88700,"stargazers_count":25,"watchers_count":25,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":34,"forks":14,"open_issues":34,"watchers":25,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"ce509238bcb59d2d78712856cd1866fe1eca717a","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":18201810,"name":"C2","full_name":"18F/C2","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/C2","description":"an approval process automation tool","fork":false,"url":"https://api.github.com/repos/18F/C2","forks_url":"https://api.github.com/repos/18F/C2/forks","keys_url":"https://api.github.com/repos/18F/C2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/C2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/C2/teams","hooks_url":"https://api.github.com/repos/18F/C2/hooks","issue_events_url":"https://api.github.com/repos/18F/C2/issues/events{/number}","events_url":"https://api.github.com/repos/18F/C2/events","assignees_url":"https://api.github.com/repos/18F/C2/assignees{/user}","branches_url":"https://api.github.com/repos/18F/C2/branches{/branch}","tags_url":"https://api.github.com/repos/18F/C2/tags","blobs_url":"https://api.github.com/repos/18F/C2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/C2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/C2/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/C2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/C2/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/C2/languages","stargazers_url":"https://api.github.com/repos/18F/C2/stargazers","contributors_url":"https://api.github.com/repos/18F/C2/contributors","subscribers_url":"https://api.github.com/repos/18F/C2/subscribers","subscription_url":"https://api.github.com/repos/18F/C2/subscription","commits_url":"https://api.github.com/repos/18F/C2/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/C2/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/C2/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/C2/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/C2/contents/{+path}","compare_url":"https://api.github.com/repos/18F/C2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/C2/merges","archive_url":"https://api.github.com/repos/18F/C2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/C2/downloads","issues_url":"https://api.github.com/repos/18F/C2/issues{/number}","pulls_url":"https://api.github.com/repos/18F/C2/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/C2/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/C2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/C2/labels{/name}","releases_url":"https://api.github.com/repos/18F/C2/releases{/id}","created_at":"2014-03-28T05:15:23Z","updated_at":"2015-10-09T18:26:20Z","pushed_at":"2015-10-20T17:24:09Z","git_url":"git://github.com/18F/C2.git","ssh_url":"git@github.com:18F/C2.git","clone_url":"https://github.com/18F/C2.git","svn_url":"https://github.com/18F/C2","homepage":"https://cap.18f.gov","size":88700,"stargazers_count":25,"watchers_count":25,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":34,"forks":14,"open_issues":34,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/C2/pulls/658"},"html":{"href":"https://github.com/18F/C2/pull/658"},"issue":{"href":"https://api.github.com/repos/18F/C2/issues/658"},"comments":{"href":"https://api.github.com/repos/18F/C2/issues/658/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/C2/pulls/658/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/C2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/C2/pulls/658/commits"},"statuses":{"href":"https://api.github.com/repos/18F/C2/statuses/7dc27193e3fe7501e59e3cb4fd6273a77c77bf5c"}}}}