{"action":"created","comment":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments/57810151","id":57810151,"diff_hunk":"@@ -6,30 +6,64 @@ AccountService.$inject = ['$http', 'util'];\n /**\n * Account Service\n *\n-* A service wrapper for the /accounts HTTP endpoint.  \n+* A service wrapper for the /accounts HTTP endpoint.\n */\n function AccountService($http, util) {\n   var service = this;\n-  var baseUrl = '/accounts';\n+  var baseUrl = '/accounts/';\n \n+  service.read = read;\n+  service.label = label;\n+\n+  /** @deprecated */\n   service.list = list;\n+\n   service.getBalance = getBalance;\n   service.getChildren = getChildren;\n+\n   service.flatten = flatten;\n   service.order = order;\n \n+  /**\n+   * The read() method loads data from the api endpoint. If an id is provided,\n+   * the $http promise is resolved with a single JSON object, otherwise an array\n+   * of objects should be expected.\n+   *\n+   * @param {Number} id - the id of the account to fetch (optional).\n+   * @param {Object} options - options to be passed as query strings (optional).\n+   * @return {Promise} promise - resolves to either a JSON (if id provided) or\n+   *   an array of JSONs.\n+   */\n+  function read(id, options) {\n+    var url = baseUrl.concat(id || '');\n+    return $http.get(url, { params : options })\n+      .then(util.unwrapHttpResponse)\n+      .then(function (accounts) {\n+\n+        // label the accounts with a nice human readable label\n+        if (!id) {","path":"client/src/js/services/AccountService.js","position":41,"original_position":41,"commit_id":"ef79fbf73b1d73d5e4eff1f34d5f125c3adbeac4","original_commit_id":"ef79fbf73b1d73d5e4eff1f34d5f125c3adbeac4","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"body":"Thanks for your feedback.  I agree that `Angular.isArray` is clearer to read, and probably safer.  An id of 0 shouldn't ever exist in our database...but I'll refactor this for clarity's sake.","created_at":"2016-03-29T22:14:39Z","updated_at":"2016-03-29T22:14:39Z","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225#discussion_r57810151","pull_request_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225","_links":{"self":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments/57810151"},"html":{"href":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225#discussion_r57810151"},"pull_request":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225"}}},"pull_request":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225","id":64442638,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225","diff_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225.diff","patch_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225.patch","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/225","number":225,"state":"open","locked":false,"title":"feat(billing services): implement billing services client-side","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"body":"This pull requests implements the billing services client.  While doing this, we demonstrate the power and usefulness of UI-Router.\r\n\r\n#### Screenshots\r\n**Empty Billing Services Grid**\r\n![billingservicesempty](https://cloud.githubusercontent.com/assets/896472/14104188/afd97ae2-f59b-11e5-9bc6-c640f6103aa4.png)\r\n\r\n**Creating a Billing Service**\r\n![billingservicescreate](https://cloud.githubusercontent.com/assets/896472/14104191/b0206df8-f59b-11e5-917e-9fb636861052.png)\r\n\r\n**Updating A Billing Service**\r\n![billingservicesupdate](https://cloud.githubusercontent.com/assets/896472/14104187/afca0aa8-f59b-11e5-9828-3cf3a68d7903.png)\r\n\r\n**Deleting A Billing Service**\r\n![billingservicesdelete](https://cloud.githubusercontent.com/assets/896472/14104189/aff0893a-f59b-11e5-89ec-b09a0c7eb02a.png)\r\n\r\n**Billing Service Grid Populated**\r\n![billingservicescreated](https://cloud.githubusercontent.com/assets/896472/14104190/b0027ad2-f59b-11e5-8a13-7f71cb46d008.png)\r\n\r\n#### Summary\r\nThe billing services module went through many transformations (see the commits) before settling on the best practices of using modals + ui-router.  This is a pattern that I believe is robust for simple modules (e.g. projects, enterprises, debtor groups).  However, it will not be scalable or appropriate to larger modules.\r\n\r\nThis PR demonstrates some significant advantages of ui-router.  Here are some highlights:\r\n 1. We can \"deep-link\" complex states.  For example, by going to the URL `/biling_services/:id/update`, from anywhere in the application, you will automatically arrive at a \"update\" (modal) form for the billing service of that id.  Clicking the \"back\" button on the form will take you to the billing services module _without reloading the view_.  This is an incredibly powerful feature.\r\n 2. The controllers are cleanly separated into `update`, `create`, and `delete`.  There is no longer any need to implement a check like\r\n ```js\r\n  var promise = (action === 'create') ? BillingServices.create(data) : BillingServices.update(id, data);\r\n```\r\n These states are no longer entangled.  The `UpdateController` does nothing but think about what is necessary to update.  The `CreateController` only thinks about creating.  They can both use the same form to accomplish this task, but the logic is cleanly separated.\r\n 3. We can now selectively refresh only part of the view, using `<ui-view>`.  While this isn't well demonstrated in this PR, it will help more complex modules.\r\n\r\nThere are still some significant issues with the billing services UI.  See https://github.com/IMA-WorldHealth/bhima-2.X/commit/bb1c575dd58ed312f7bffe56bac3713dddcef945 for a discussion of them.  I will be making a review issue to track changes to the UI.\r\n\r\nCloses #51.","created_at":"2016-03-29T10:16:55Z","updated_at":"2016-03-29T22:14:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"633f9d81ff51575970b094243ed6a34ddef689ea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225/commits","review_comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225/comments","review_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/225/comments","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/ef79fbf73b1d73d5e4eff1f34d5f125c3adbeac4","head":{"label":"jniles:feature-billing-services","ref":"feature-billing-services","sha":"ef79fbf73b1d73d5e4eff1f34d5f125c3adbeac4","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"repo":{"id":49059888,"name":"bhima-2.X","full_name":"jniles/bhima-2.X","owner":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jniles/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":true,"url":"https://api.github.com/repos/jniles/bhima-2.X","forks_url":"https://api.github.com/repos/jniles/bhima-2.X/forks","keys_url":"https://api.github.com/repos/jniles/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jniles/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jniles/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/jniles/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/jniles/bhima-2.X/events","assignees_url":"https://api.github.com/repos/jniles/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/jniles/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/jniles/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jniles/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/jniles/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jniles/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/jniles/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/jniles/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/jniles/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/jniles/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/jniles/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/jniles/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/jniles/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/jniles/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/jniles/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/jniles/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jniles/bhima-2.X/merges","archive_url":"https://api.github.com/repos/jniles/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jniles/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/jniles/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/jniles/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/jniles/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/jniles/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jniles/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/jniles/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/jniles/bhima-2.X/deployments","created_at":"2016-01-05T10:44:42Z","updated_at":"2016-01-05T10:44:44Z","pushed_at":"2016-03-29T22:13:40Z","git_url":"git://github.com/jniles/bhima-2.X.git","ssh_url":"git@github.com:jniles/bhima-2.X.git","clone_url":"https://github.com/jniles/bhima-2.X.git","svn_url":"https://github.com/jniles/bhima-2.X","homepage":null,"size":2754,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"IMA-WorldHealth:master","ref":"master","sha":"e7b1a84302ecc5f45cff936b2f4299d76c3deb96","user":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"repo":{"id":49052669,"name":"bhima-2.X","full_name":"IMA-WorldHealth/bhima-2.X","owner":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":false,"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X","forks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/forks","keys_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/events","assignees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/merges","archive_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/deployments","created_at":"2016-01-05T08:30:30Z","updated_at":"2016-02-27T20:42:18Z","pushed_at":"2016-03-29T21:56:51Z","git_url":"git://github.com/IMA-WorldHealth/bhima-2.X.git","ssh_url":"git@github.com:IMA-WorldHealth/bhima-2.X.git","clone_url":"https://github.com/IMA-WorldHealth/bhima-2.X.git","svn_url":"https://github.com/IMA-WorldHealth/bhima-2.X","homepage":null,"size":3149,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":75,"forks":5,"open_issues":75,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225"},"html":{"href":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/225"},"issue":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/225"},"comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/225/comments"},"review_comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225/comments"},"review_comment":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/225/commits"},"statuses":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/ef79fbf73b1d73d5e4eff1f34d5f125c3adbeac4"}}}}