{"action":"created","comment":{"url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/comments/32959748","id":32959748,"diff_hunk":"@@ -546,18 +579,62 @@ angular.module('BloomLibraryApp.services', ['restangular'])\n             }\n         };\n \t} ])\n-    .service('tagService', function() {\n-        this.getTags = function () {\n-            return [            \n-                // Replicated from Bloom.Book.RuntimeInformationInjector.AddUISettingsToDom().\n-                // Eventually this will be user-extensible and retrieved using a query on some new table.\n-                \"Agriculture\", \"Animal Stories\", \"Business\", \"Culture\", \"Community Living\", \"Dictionary\", \"Environment\", \"Fiction\", \"Health\", \"How To\", \"Math\", \"Non Fiction\", \"Spiritual\", \"Personal Development\", \"Primer\", \"Science\", \"Story Book\", \"Traditional Story\"\n-            ].sort();\n+    .service('parseAngularService', ['$rootScope', '$q', '$filter', 'errorHandlerService', function($rootScope, $q, $filter, errorHandlerService) {\n+        this.parsePromiseToAngular = function(parsePromise, functionRef) {\n+            // query.find and other queries return a parse.com promise, but it is not quite the same api as\n+            // as an angularjs promise. Instead, translate its find and error functions using the\n+            // angularjs promise.\n+\n+            var defer = $q.defer(); // used to implement angularjs-style promise\n+\n+            parsePromise.then(function(results) {\n+                var objects = new Array(results.length);\n+                for (i = 0; i < results.length; i++) {\n+                    objects[i] = results[i].toJSON();\n+                }\n+                // languageList = objects;\n+                // See the discussion in getFilteredBookRange of why the $apply is used. I haven't tried\n+                // NOT using it in this context.\n+                $rootScope.$apply(function () { defer.resolve(objects); });\n+            },\n+            function (error) {\n+                errorHandlerService.handleParseError(functionRef || 'unspecified', error);\n+                defer.reject(error);\n+            });\n+\n+            return defer.promise;\n         };\n-        this.getDisplayName = function(tagId) {\n-            return tagId;\n+    }])\n+    .service('tagService', ['parseAngularService', function(parseAngularService) {\n+        this.getTags = function (category) {\n+            var tagQuery = new Parse.Query('tag');\n+            tagQuery.descending(\"usageCount\");\n+            tagQuery.limit(1000);\n+\n+            //If a category is specified, only get tags of that category\n+            if(category) {\n+                tagQuery.startsWith('name', category + '.');\n+            }\n+\n+            var parsePromise =  tagQuery.find();\n+            return parseAngularService.parsePromiseToAngular(parsePromise, 'getTags');\n         };\n-    })\n+        //Remove category (i.e. 'category.') and put spaces before camel-case type\n+        this.getDisplayName = function(tag) {\n+            try {\n+                var prefixRegex = /[a-z]+\\./;\n+                var camelRegex = /([a-z])([A-Z])/g;\n+\n+                var ret = tag.replace(prefixRegex, \"\").replace(camelRegex, function (match, p1, p2) {\n+                    return p1 + ' ' + p2;","path":"src/app/modules/common/services.js","position":232,"original_position":232,"commit_id":"46baa176df380657205082351a4d41b8b10b5399","original_commit_id":"0ca83eaf5ecf974d5af477ee224f008ddc9ed7e4","user":{"login":"grant-dennison","id":12715906,"avatar_url":"https://avatars.githubusercontent.com/u/12715906?v=3","gravatar_id":"","url":"https://api.github.com/users/grant-dennison","html_url":"https://github.com/grant-dennison","followers_url":"https://api.github.com/users/grant-dennison/followers","following_url":"https://api.github.com/users/grant-dennison/following{/other_user}","gists_url":"https://api.github.com/users/grant-dennison/gists{/gist_id}","starred_url":"https://api.github.com/users/grant-dennison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grant-dennison/subscriptions","organizations_url":"https://api.github.com/users/grant-dennison/orgs","repos_url":"https://api.github.com/users/grant-dennison/repos","events_url":"https://api.github.com/users/grant-dennison/events{/privacy}","received_events_url":"https://api.github.com/users/grant-dennison/received_events","type":"User","site_admin":false},"body":"I don't know. John Hatton did not specify on that. I guess I assumed that such a tag would have been intentional on the librarian's part.","created_at":"2015-06-22T17:25:48Z","updated_at":"2015-06-22T17:25:48Z","html_url":"https://github.com/BloomBooks/BloomLibrary/pull/205#discussion_r32959748","pull_request_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205","_links":{"self":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/comments/32959748"},"html":{"href":"https://github.com/BloomBooks/BloomLibrary/pull/205#discussion_r32959748"},"pull_request":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205"}}},"pull_request":{"url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205","id":38229346,"html_url":"https://github.com/BloomBooks/BloomLibrary/pull/205","diff_url":"https://github.com/BloomBooks/BloomLibrary/pull/205.diff","patch_url":"https://github.com/BloomBooks/BloomLibrary/pull/205.patch","issue_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/205","number":205,"state":"open","locked":false,"title":"Data Grid","user":{"login":"grant-dennison","id":12715906,"avatar_url":"https://avatars.githubusercontent.com/u/12715906?v=3","gravatar_id":"","url":"https://api.github.com/users/grant-dennison","html_url":"https://github.com/grant-dennison","followers_url":"https://api.github.com/users/grant-dennison/followers","following_url":"https://api.github.com/users/grant-dennison/following{/other_user}","gists_url":"https://api.github.com/users/grant-dennison/gists{/gist_id}","starred_url":"https://api.github.com/users/grant-dennison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grant-dennison/subscriptions","organizations_url":"https://api.github.com/users/grant-dennison/orgs","repos_url":"https://api.github.com/users/grant-dennison/repos","events_url":"https://api.github.com/users/grant-dennison/events{/privacy}","received_events_url":"https://api.github.com/users/grant-dennison/received_events","type":"User","site_admin":false},"body":"Datagrid is working with John Hatton's approval.\r\n\r\n### Filterable datagrid accessible only to administrators. \r\n* Tags, inCirculation, and librarian notes are editable fields therein (only by users with moderator status on parse.com).\r\n* The tags field offers autocomplete.\r\n\r\n### Tag system revamped. \r\n* Books support multiple tags displayed properly in browse, detail, and datagrid view. \r\n* Tags were split into categories (specifically \"Regions\", \"Reading Levels\", and catch-all \"Topics\"). These categories display separately on the browse page.\r\n* Tags support \"category.CamelCase\" format with \"Camel Case\" being the visible tag.\r\n\r\n### Tag and Language counts\r\n* A regular job on parse.com, populateCounts, should be run at least once a day to count the usage of languages and tags for all books.\r\n* The \"Languages\" section of the browse sidebar is split into two groups of top languages and other languages split by a \"n more...\" divider. This division is dictated by the usageCount field.\r\n* Tags likewise support the top/other division, but are currently not using such.","created_at":"2015-06-22T13:06:07Z","updated_at":"2015-06-22T17:25:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2bd665c6f800c9cc2c08ef858e8209f9fedd056","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205/commits","review_comments_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205/comments","review_comment_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/205/comments","statuses_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/statuses/46baa176df380657205082351a4d41b8b10b5399","head":{"label":"grant-dennison:DataGrid","ref":"DataGrid","sha":"46baa176df380657205082351a4d41b8b10b5399","user":{"login":"grant-dennison","id":12715906,"avatar_url":"https://avatars.githubusercontent.com/u/12715906?v=3","gravatar_id":"","url":"https://api.github.com/users/grant-dennison","html_url":"https://github.com/grant-dennison","followers_url":"https://api.github.com/users/grant-dennison/followers","following_url":"https://api.github.com/users/grant-dennison/following{/other_user}","gists_url":"https://api.github.com/users/grant-dennison/gists{/gist_id}","starred_url":"https://api.github.com/users/grant-dennison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grant-dennison/subscriptions","organizations_url":"https://api.github.com/users/grant-dennison/orgs","repos_url":"https://api.github.com/users/grant-dennison/repos","events_url":"https://api.github.com/users/grant-dennison/events{/privacy}","received_events_url":"https://api.github.com/users/grant-dennison/received_events","type":"User","site_admin":false},"repo":{"id":36744486,"name":"BloomLibrary","full_name":"grant-dennison/BloomLibrary","owner":{"login":"grant-dennison","id":12715906,"avatar_url":"https://avatars.githubusercontent.com/u/12715906?v=3","gravatar_id":"","url":"https://api.github.com/users/grant-dennison","html_url":"https://github.com/grant-dennison","followers_url":"https://api.github.com/users/grant-dennison/followers","following_url":"https://api.github.com/users/grant-dennison/following{/other_user}","gists_url":"https://api.github.com/users/grant-dennison/gists{/gist_id}","starred_url":"https://api.github.com/users/grant-dennison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grant-dennison/subscriptions","organizations_url":"https://api.github.com/users/grant-dennison/orgs","repos_url":"https://api.github.com/users/grant-dennison/repos","events_url":"https://api.github.com/users/grant-dennison/events{/privacy}","received_events_url":"https://api.github.com/users/grant-dennison/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grant-dennison/BloomLibrary","description":"Bloom Library Single Page App, using AngularJS & Bootstrap, Parse.com backend.","fork":true,"url":"https://api.github.com/repos/grant-dennison/BloomLibrary","forks_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/forks","keys_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/teams","hooks_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/hooks","issue_events_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/issues/events{/number}","events_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/events","assignees_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/assignees{/user}","branches_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/branches{/branch}","tags_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/tags","blobs_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/git/refs{/sha}","trees_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/statuses/{sha}","languages_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/languages","stargazers_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/stargazers","contributors_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/contributors","subscribers_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/subscribers","subscription_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/subscription","commits_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/commits{/sha}","git_commits_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/git/commits{/sha}","comments_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/comments{/number}","issue_comment_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/issues/comments{/number}","contents_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/contents/{+path}","compare_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/merges","archive_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/downloads","issues_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/issues{/number}","pulls_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/pulls{/number}","milestones_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/milestones{/number}","notifications_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/labels{/name}","releases_url":"https://api.github.com/repos/grant-dennison/BloomLibrary/releases{/id}","created_at":"2015-06-02T15:58:06Z","updated_at":"2015-06-02T15:58:07Z","pushed_at":"2015-06-22T16:07:27Z","git_url":"git://github.com/grant-dennison/BloomLibrary.git","ssh_url":"git@github.com:grant-dennison/BloomLibrary.git","clone_url":"https://github.com/grant-dennison/BloomLibrary.git","svn_url":"https://github.com/grant-dennison/BloomLibrary","homepage":"","size":3976,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"develop"}},"base":{"label":"BloomBooks:develop","ref":"develop","sha":"a72f42291180a74b7a7877adb8fce432817d3e08","user":{"login":"BloomBooks","id":5853716,"avatar_url":"https://avatars.githubusercontent.com/u/5853716?v=3","gravatar_id":"","url":"https://api.github.com/users/BloomBooks","html_url":"https://github.com/BloomBooks","followers_url":"https://api.github.com/users/BloomBooks/followers","following_url":"https://api.github.com/users/BloomBooks/following{/other_user}","gists_url":"https://api.github.com/users/BloomBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/BloomBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BloomBooks/subscriptions","organizations_url":"https://api.github.com/users/BloomBooks/orgs","repos_url":"https://api.github.com/users/BloomBooks/repos","events_url":"https://api.github.com/users/BloomBooks/events{/privacy}","received_events_url":"https://api.github.com/users/BloomBooks/received_events","type":"Organization","site_admin":false},"repo":{"id":14128756,"name":"BloomLibrary","full_name":"BloomBooks/BloomLibrary","owner":{"login":"BloomBooks","id":5853716,"avatar_url":"https://avatars.githubusercontent.com/u/5853716?v=3","gravatar_id":"","url":"https://api.github.com/users/BloomBooks","html_url":"https://github.com/BloomBooks","followers_url":"https://api.github.com/users/BloomBooks/followers","following_url":"https://api.github.com/users/BloomBooks/following{/other_user}","gists_url":"https://api.github.com/users/BloomBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/BloomBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BloomBooks/subscriptions","organizations_url":"https://api.github.com/users/BloomBooks/orgs","repos_url":"https://api.github.com/users/BloomBooks/repos","events_url":"https://api.github.com/users/BloomBooks/events{/privacy}","received_events_url":"https://api.github.com/users/BloomBooks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BloomBooks/BloomLibrary","description":"Bloom Library Single Page App, using AngularJS & Bootstrap, Parse.com backend.","fork":false,"url":"https://api.github.com/repos/BloomBooks/BloomLibrary","forks_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/forks","keys_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/teams","hooks_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/hooks","issue_events_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/events{/number}","events_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/events","assignees_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/assignees{/user}","branches_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/branches{/branch}","tags_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/tags","blobs_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/git/refs{/sha}","trees_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/statuses/{sha}","languages_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/languages","stargazers_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/stargazers","contributors_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/contributors","subscribers_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/subscribers","subscription_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/subscription","commits_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/commits{/sha}","git_commits_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/git/commits{/sha}","comments_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/comments{/number}","issue_comment_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/comments{/number}","contents_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/contents/{+path}","compare_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/merges","archive_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/downloads","issues_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues{/number}","pulls_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls{/number}","milestones_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/milestones{/number}","notifications_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/labels{/name}","releases_url":"https://api.github.com/repos/BloomBooks/BloomLibrary/releases{/id}","created_at":"2013-11-05T01:23:42Z","updated_at":"2015-05-05T21:00:51Z","pushed_at":"2015-06-22T16:07:28Z","git_url":"git://github.com/BloomBooks/BloomLibrary.git","ssh_url":"git@github.com:BloomBooks/BloomLibrary.git","clone_url":"https://github.com/BloomBooks/BloomLibrary.git","svn_url":"https://github.com/BloomBooks/BloomLibrary","homepage":"","size":5157,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":2,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205"},"html":{"href":"https://github.com/BloomBooks/BloomLibrary/pull/205"},"issue":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/205"},"comments":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/issues/205/comments"},"review_comments":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205/comments"},"review_comment":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/pulls/205/commits"},"statuses":{"href":"https://api.github.com/repos/BloomBooks/BloomLibrary/statuses/46baa176df380657205082351a4d41b8b10b5399"}}}}