{"action":"created","comment":{"url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/comments/59009805","id":59009805,"diff_hunk":"@@ -0,0 +1,166 @@\n+var TaskManager = function (holder_id, task_type) {\n+\n+    var self = this;\n+    this.last_load_url = \"/task/tasks/\" + task_type;\n+\n+    this.success_notification = function(text) {\n+        noty({text: text,\n+            theme: 'bootstrapTheme',\n+            layout: 'bottomRight',\n+            type: 'success'});\n+    };\n+    this.error_notification = function(text) {\n+        noty({text: text,\n+            theme: 'bootstrapTheme',\n+            layout: 'bottomRight',\n+            type: 'error'});\n+    };\n+\n+    this.load_assign_modal = function (event) {\n+        console.log(\"load_assign_modal\");\n+        var task_id = $(this).data(\"task-id\");\n+        $(\"#task_assign_select\").select2({\n+            placeholder: \"Select the user\",\n+            ajax: {\n+                url: \"/task/\" + task_id + \"/list_owners\",\n+                dataType: 'json',\n+                type: \"GET\",\n+                delay: 250,\n+                data: function (term, page) {\n+                    return {\n+                        q: term, // search term\n+                        col: 'vdn'\n+                    };\n+                },\n+                dropdownAutoWidth : true,\n+                cache: true\n+            }\n+        });\n+        $('#task_assign_select').closest('form').attr('action','/task/' + task_id + '/assign');\n+        $('#assignTaskModal_button').data('location',self.holder_id);\n+    };\n+\n+    this.load_tasks_from_url = function(url) {\n+        $(\"#\" + this.holder_id).html(\"Page is loading...\");\n+        self.last_load_url = url;\n+        $.ajax({type: 'GET',\n+            url: url,\n+            data: {},\n+            timeout: 5000,\n+            success: function (data){\n+                $(\"#\" + self.holder_id).html(data);\n+                self.init();\n+            },\n+            error: function (xhrObj, status, exception) {\n+                self.error_notification(xhrObj.responseJSON['message']);\n+            }\n+        });\n+    };\n+    this.refresh_tasks = function () {\n+        self.load_tasks_from_url(self.last_load_url);\n+    };\n+    this.load_tasks = function() {\n+        self.load_tasks_from_url(this.href);\n+        return false;\n+    };\n+\n+    this.wip_task = function(event) {\n+        event.preventDefault();\n+        var url = $(this).data(\"url\");\n+        $.ajax({type: 'PATCH',\n+            url: url,\n+            data: {},\n+            timeout: 5000,\n+            success: function (){\n+                self.success_notification('Work on the task started');\n+                self.refresh_tasks();\n+            },\n+            error: function (xhrObj, status, exception) {\n+                self.error_notification(xhrObj.responseJSON['message']);\n+            }\n+        });\n+    };\n+    this.done_task = function() {\n+        var url = $(this).data(\"url\");\n+        $.ajax({type: 'PATCH',\n+            url: url,\n+            data: {},\n+            timeout: 5000,\n+            success: function (){\n+                self.success_notification('Work on the task is done');\n+                self.refresh_tasks();\n+            },\n+            error: function (xhrObj, status, exception) {\n+                self.error_notification(xhrObj.responseJSON['message']);\n+            }\n+        });\n+        return false;\n+    };\n+    this.holder_id = holder_id;\n+\n+    this.init = function() {\n+        $(\"#\" + self.holder_id).find(\".assign_button\").click(self.load_assign_modal);\n+        $(\"#\" + self.holder_id).find(\".wip_button\").click(self.wip_task);\n+        $(\"#\" + self.holder_id).find(\".done_button\").click(self.done_task);\n+        $(\"#\" + self.holder_id).find(\".pagination a\").click(self.load_tasks);\n+    };\n+    this.init();\n+};\n+\n+\n+var __TaskManagerHolder = {};\n+var TaskManagerHolder = function(holder_id, task_type) {\n+    if(!__TaskManagerHolder.hasOwnProperty(holder_id)){\n+        __TaskManagerHolder[holder_id] = new TaskManager(holder_id, task_type);\n+    }\n+    return __TaskManagerHolder[holder_id];\n+};\n+\n+var TaskModal = {\n+  setup: function() {\n+      $('#assignTaskModal').on('shown.bs.modal', function (e) {\n+          $('#assignTaskModal_button').click( function() {\n+              if ($(\"#task_assign_select\").val() === null) {\n+                  return;\n+              }\n+              var url = $('#task_assign_select').closest('form').attr('action');\n+              var post_data = {to: $(\"#task_assign_select\").val()};\n+              $.ajax({\n+                  type: 'PATCH',\n+                  url: url,\n+                  data: post_data,\n+                  timeout: 5000,\n+                  success: function () {\n+                      noty({\n+                          text: 'Task assigned',\n+                          theme: 'bootstrapTheme',\n+                          layout: 'bottomRight',\n+                          type: 'success'\n+                      });\n+                      TaskManagerHolder($('#assignTaskModal_button').data('location'), \"\").refresh_tasks();\n+                      $(\"#assignTaskModal\").modal('hide');\n+                  },\n+                  error: function (xhrObj, status, exception) {\n+                      noty({\n+                          text: xhrObj['message'],\n+                          theme: 'bootstrapTheme',\n+                          layout: 'bottomRight',\n+                          type: 'error'\n+                      });\n+                  }","path":"app/assets/javascripts/task.js","position":150,"original_position":150,"commit_id":"07674191f19e0bebd0084b9bc37af951822ee3c3","original_commit_id":"d603a7dde653ea5f339396ffd16eda2120b5c78b","user":{"login":"patmbolger","id":9968213,"avatar_url":"https://avatars.githubusercontent.com/u/9968213?v=3","gravatar_id":"","url":"https://api.github.com/users/patmbolger","html_url":"https://github.com/patmbolger","followers_url":"https://api.github.com/users/patmbolger/followers","following_url":"https://api.github.com/users/patmbolger/following{/other_user}","gists_url":"https://api.github.com/users/patmbolger/gists{/gist_id}","starred_url":"https://api.github.com/users/patmbolger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patmbolger/subscriptions","organizations_url":"https://api.github.com/users/patmbolger/orgs","repos_url":"https://api.github.com/users/patmbolger/repos","events_url":"https://api.github.com/users/patmbolger/events{/privacy}","received_events_url":"https://api.github.com/users/patmbolger/received_events","type":"User","site_admin":false},"body":"There is an opportunity to extract out the 'noty' functions into one utility function.  (that could also be used in pusher.js.erb)","created_at":"2016-04-08T11:05:44Z","updated_at":"2016-04-08T11:05:44Z","html_url":"https://github.com/AgileVentures/MetPlus_PETS/pull/218#discussion_r59009805","pull_request_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218","_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/comments/59009805"},"html":{"href":"https://github.com/AgileVentures/MetPlus_PETS/pull/218#discussion_r59009805"},"pull_request":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218"}}},"pull_request":{"url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218","id":65641414,"html_url":"https://github.com/AgileVentures/MetPlus_PETS/pull/218","diff_url":"https://github.com/AgileVentures/MetPlus_PETS/pull/218.diff","patch_url":"https://github.com/AgileVentures/MetPlus_PETS/pull/218.patch","issue_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/218","number":218,"state":"open","locked":false,"title":"Connects to AgileVentures/MetPlus_tracker#232 (WIP)","user":{"login":"joaopapereira","id":1826130,"avatar_url":"https://avatars.githubusercontent.com/u/1826130?v=3","gravatar_id":"","url":"https://api.github.com/users/joaopapereira","html_url":"https://github.com/joaopapereira","followers_url":"https://api.github.com/users/joaopapereira/followers","following_url":"https://api.github.com/users/joaopapereira/following{/other_user}","gists_url":"https://api.github.com/users/joaopapereira/gists{/gist_id}","starred_url":"https://api.github.com/users/joaopapereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaopapereira/subscriptions","organizations_url":"https://api.github.com/users/joaopapereira/orgs","repos_url":"https://api.github.com/users/joaopapereira/repos","events_url":"https://api.github.com/users/joaopapereira/events{/privacy}","received_events_url":"https://api.github.com/users/joaopapereira/received_events","type":"User","site_admin":false},"body":"WIP to have a look into the implementation of the tasks.\r\nLong PR because a bunch of templates and files needed to be created","created_at":"2016-04-07T14:40:28Z","updated_at":"2016-04-08T11:05:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"842433cca5d395a33700633307ec8a0e2dd81da4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218/commits","review_comments_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218/comments","review_comment_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/218/comments","statuses_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/statuses/07674191f19e0bebd0084b9bc37af951822ee3c3","head":{"label":"joaopapereira:feature/232","ref":"feature/232","sha":"07674191f19e0bebd0084b9bc37af951822ee3c3","user":{"login":"joaopapereira","id":1826130,"avatar_url":"https://avatars.githubusercontent.com/u/1826130?v=3","gravatar_id":"","url":"https://api.github.com/users/joaopapereira","html_url":"https://github.com/joaopapereira","followers_url":"https://api.github.com/users/joaopapereira/followers","following_url":"https://api.github.com/users/joaopapereira/following{/other_user}","gists_url":"https://api.github.com/users/joaopapereira/gists{/gist_id}","starred_url":"https://api.github.com/users/joaopapereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaopapereira/subscriptions","organizations_url":"https://api.github.com/users/joaopapereira/orgs","repos_url":"https://api.github.com/users/joaopapereira/repos","events_url":"https://api.github.com/users/joaopapereira/events{/privacy}","received_events_url":"https://api.github.com/users/joaopapereira/received_events","type":"User","site_admin":false},"repo":{"id":44603772,"name":"MetPlus_PETS","full_name":"joaopapereira/MetPlus_PETS","owner":{"login":"joaopapereira","id":1826130,"avatar_url":"https://avatars.githubusercontent.com/u/1826130?v=3","gravatar_id":"","url":"https://api.github.com/users/joaopapereira","html_url":"https://github.com/joaopapereira","followers_url":"https://api.github.com/users/joaopapereira/followers","following_url":"https://api.github.com/users/joaopapereira/following{/other_user}","gists_url":"https://api.github.com/users/joaopapereira/gists{/gist_id}","starred_url":"https://api.github.com/users/joaopapereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaopapereira/subscriptions","organizations_url":"https://api.github.com/users/joaopapereira/orgs","repos_url":"https://api.github.com/users/joaopapereira/repos","events_url":"https://api.github.com/users/joaopapereira/events{/privacy}","received_events_url":"https://api.github.com/users/joaopapereira/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joaopapereira/MetPlus_PETS","description":"Front End for the MetPlus project","fork":true,"url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS","forks_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/forks","keys_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/teams","hooks_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/hooks","issue_events_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/issues/events{/number}","events_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/events","assignees_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/assignees{/user}","branches_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/branches{/branch}","tags_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/tags","blobs_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/git/refs{/sha}","trees_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/statuses/{sha}","languages_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/languages","stargazers_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/stargazers","contributors_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/contributors","subscribers_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/subscribers","subscription_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/subscription","commits_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/commits{/sha}","git_commits_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/git/commits{/sha}","comments_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/comments{/number}","issue_comment_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/issues/comments{/number}","contents_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/contents/{+path}","compare_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/merges","archive_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/downloads","issues_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/issues{/number}","pulls_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/pulls{/number}","milestones_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/milestones{/number}","notifications_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/labels{/name}","releases_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/releases{/id}","deployments_url":"https://api.github.com/repos/joaopapereira/MetPlus_PETS/deployments","created_at":"2015-10-20T12:09:26Z","updated_at":"2016-03-23T19:17:04Z","pushed_at":"2016-04-07T22:26:49Z","git_url":"git://github.com/joaopapereira/MetPlus_PETS.git","ssh_url":"git@github.com:joaopapereira/MetPlus_PETS.git","clone_url":"https://github.com/joaopapereira/MetPlus_PETS.git","svn_url":"https://github.com/joaopapereira/MetPlus_PETS","homepage":null,"size":1057,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"master"}},"base":{"label":"AgileVentures:development","ref":"development","sha":"5d78e74ac58fee428f2ab58d9eaddbec26b5478c","user":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"repo":{"id":41921394,"name":"MetPlus_PETS","full_name":"AgileVentures/MetPlus_PETS","owner":{"login":"AgileVentures","id":5116968,"avatar_url":"https://avatars.githubusercontent.com/u/5116968?v=3","gravatar_id":"","url":"https://api.github.com/users/AgileVentures","html_url":"https://github.com/AgileVentures","followers_url":"https://api.github.com/users/AgileVentures/followers","following_url":"https://api.github.com/users/AgileVentures/following{/other_user}","gists_url":"https://api.github.com/users/AgileVentures/gists{/gist_id}","starred_url":"https://api.github.com/users/AgileVentures/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgileVentures/subscriptions","organizations_url":"https://api.github.com/users/AgileVentures/orgs","repos_url":"https://api.github.com/users/AgileVentures/repos","events_url":"https://api.github.com/users/AgileVentures/events{/privacy}","received_events_url":"https://api.github.com/users/AgileVentures/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AgileVentures/MetPlus_PETS","description":"Front End for the MetPlus project","fork":false,"url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS","forks_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/forks","keys_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/teams","hooks_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/hooks","issue_events_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/events{/number}","events_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/events","assignees_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/assignees{/user}","branches_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/branches{/branch}","tags_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/tags","blobs_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/git/refs{/sha}","trees_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/statuses/{sha}","languages_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/languages","stargazers_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/stargazers","contributors_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/contributors","subscribers_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/subscribers","subscription_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/subscription","commits_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/commits{/sha}","git_commits_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/git/commits{/sha}","comments_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/comments{/number}","issue_comment_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/comments{/number}","contents_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/contents/{+path}","compare_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/merges","archive_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/downloads","issues_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues{/number}","pulls_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls{/number}","milestones_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/milestones{/number}","notifications_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/labels{/name}","releases_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/releases{/id}","deployments_url":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/deployments","created_at":"2015-09-04T14:51:35Z","updated_at":"2016-03-24T00:59:29Z","pushed_at":"2016-04-08T03:08:45Z","git_url":"git://github.com/AgileVentures/MetPlus_PETS.git","ssh_url":"git@github.com:AgileVentures/MetPlus_PETS.git","clone_url":"https://github.com/AgileVentures/MetPlus_PETS.git","svn_url":"https://github.com/AgileVentures/MetPlus_PETS","homepage":null,"size":1275,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":4,"forks":13,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218"},"html":{"href":"https://github.com/AgileVentures/MetPlus_PETS/pull/218"},"issue":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/218"},"comments":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/issues/218/comments"},"review_comments":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218/comments"},"review_comment":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/pulls/218/commits"},"statuses":{"href":"https://api.github.com/repos/AgileVentures/MetPlus_PETS/statuses/07674191f19e0bebd0084b9bc37af951822ee3c3"}}}}