{"action":"created","comment":{"url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/comments/77836058","id":77836058,"diff_hunk":"@@ -0,0 +1,276 @@\n+namespace ddui {\n+    export interface ListRow {\n+        $selected?: boolean;\n+    }\n+\n+    export interface ListConfig {\n+        url: string;\n+        id?: string;\n+        paging?: boolean;\n+        responseListName?: string;\n+        responseCountName?: string;\n+    }\n+\n+    export class DataList<T extends ListRow> {\n+\n+        id: string;\n+        rows: T[];\n+        url: string;\n+        count: number;\n+        data: any;\n+        filter: any;\n+        paging: boolean;\n+        areFiltersSet: boolean;\n+        forceListUpdate: boolean;\n+        selectedAllPages: boolean;\n+        isLoading: boolean;\n+        responseListName: string;\n+        responseCountName: string;\n+\n+        onListResponseSuccess: any;\n+        onListResponseError: any;\n+\n+        initFilterFunc: Function;\n+\n+        constructor(config: ListConfig, private $http: ng.IHttpService, private $location: ng.ILocationService) {\n+            this.id = config.id;\n+            this.rows = [];\n+            this.count = 0;\n+            this.data = null;   // will be assigned raw last response\n+            this.filter = { skip: 0, limit: 25 };\n+            this.paging = config.paging;\n+            this.areFiltersSet = false;\n+            this.selectedAllPages = false;\n+            this.isLoading = false;\n+            this.url = config.url;\n+            this.responseListName = config.responseListName || 'items';\n+            this.responseCountName = config.responseCountName || 'count';\n+            this.initFilterFunc = () => { return {}; };\n+        }\n+\n+        onSuccess(callback: (list: T[], count: number) => void) {\n+            this.onListResponseSuccess = callback;\n+        }\n+\n+        onError(callback: (data: any) => void) {\n+            this.onListResponseError = callback;\n+        }\n+\n+        setFilter(filterFunc) {\n+            this.initFilterFunc = filterFunc;\n+            var filter = this.initFilterFunc();\n+            if (typeof (filter) !== 'object') {\n+                throw new Error('initFilterFunc should return object with filter properties');\n+            }\n+\n+            angular.extend(this.filter, filter);\n+\n+            this.areFiltersSet = this.loadLocationParams(this.filter) > 0;\n+        }\n+\n+        submitFilter() {\n+            this.setLocationParams(this.filter);\n+            return this.updateList();\n+        }\n+\n+        resetFilter() {\n+            this.filter = this.initFilterFunc();\n+            this.setLocationParams(this.filter);\n+            this.updateList();\n+        }\n+\n+        updateList() {\n+            const self = this;\n+            this.isLoading = true;\n+\n+            if (typeof (this.filter.limit) === 'undefined') {\n+                this.filter.limit = 25;\n+            }\n+\n+            if (typeof (this.filter.skip) === 'undefined') {\n+                this.filter.skip = 0;\n+            }\n+\n+            const config = {\n+                params: this.filter\n+            };\n+\n+            return this.$http.get(this.url, config)\n+                .success(data => {","path":"src/data-list/data-list.service.ts","position":99,"original_position":99,"commit_id":"3c1f8411cbae1e266c77c6423c681fea5d086a0a","original_commit_id":"3c1f8411cbae1e266c77c6423c681fea5d086a0a","user":{"login":"jnorkus","id":5137138,"avatar_url":"https://avatars.githubusercontent.com/u/5137138?v=3","gravatar_id":"","url":"https://api.github.com/users/jnorkus","html_url":"https://github.com/jnorkus","followers_url":"https://api.github.com/users/jnorkus/followers","following_url":"https://api.github.com/users/jnorkus/following{/other_user}","gists_url":"https://api.github.com/users/jnorkus/gists{/gist_id}","starred_url":"https://api.github.com/users/jnorkus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnorkus/subscriptions","organizations_url":"https://api.github.com/users/jnorkus/orgs","repos_url":"https://api.github.com/users/jnorkus/repos","events_url":"https://api.github.com/users/jnorkus/events{/privacy}","received_events_url":"https://api.github.com/users/jnorkus/received_events","type":"User","site_admin":false},"body":"It is much easier to maintain code without these custom $http callbacks. Tests are easier to write with plain `.then`.","created_at":"2016-09-07T14:43:19Z","updated_at":"2016-09-07T14:43:19Z","html_url":"https://github.com/clickataxi/dd-ui/pull/63#discussion_r77836058","pull_request_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/comments/77836058"},"html":{"href":"https://github.com/clickataxi/dd-ui/pull/63#discussion_r77836058"},"pull_request":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63","id":84310151,"html_url":"https://github.com/clickataxi/dd-ui/pull/63","diff_url":"https://github.com/clickataxi/dd-ui/pull/63.diff","patch_url":"https://github.com/clickataxi/dd-ui/pull/63.patch","issue_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/63","number":63,"state":"open","locked":false,"title":"chore(listservice): list service implementation","user":{"login":"Anjmao","id":3028012,"avatar_url":"https://avatars.githubusercontent.com/u/3028012?v=3","gravatar_id":"","url":"https://api.github.com/users/Anjmao","html_url":"https://github.com/Anjmao","followers_url":"https://api.github.com/users/Anjmao/followers","following_url":"https://api.github.com/users/Anjmao/following{/other_user}","gists_url":"https://api.github.com/users/Anjmao/gists{/gist_id}","starred_url":"https://api.github.com/users/Anjmao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anjmao/subscriptions","organizations_url":"https://api.github.com/users/Anjmao/orgs","repos_url":"https://api.github.com/users/Anjmao/repos","events_url":"https://api.github.com/users/Anjmao/events{/privacy}","received_events_url":"https://api.github.com/users/Anjmao/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-07T14:26:34Z","updated_at":"2016-09-07T14:43:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f1c85345258df3e970ed61b93450ffc1f8ad0181","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63/commits","review_comments_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63/comments","review_comment_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/63/comments","statuses_url":"https://api.github.com/repos/clickataxi/dd-ui/statuses/3c1f8411cbae1e266c77c6423c681fea5d086a0a","head":{"label":"clickataxi:list_service","ref":"list_service","sha":"3c1f8411cbae1e266c77c6423c681fea5d086a0a","user":{"login":"clickataxi","id":1058748,"avatar_url":"https://avatars.githubusercontent.com/u/1058748?v=3","gravatar_id":"","url":"https://api.github.com/users/clickataxi","html_url":"https://github.com/clickataxi","followers_url":"https://api.github.com/users/clickataxi/followers","following_url":"https://api.github.com/users/clickataxi/following{/other_user}","gists_url":"https://api.github.com/users/clickataxi/gists{/gist_id}","starred_url":"https://api.github.com/users/clickataxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clickataxi/subscriptions","organizations_url":"https://api.github.com/users/clickataxi/orgs","repos_url":"https://api.github.com/users/clickataxi/repos","events_url":"https://api.github.com/users/clickataxi/events{/privacy}","received_events_url":"https://api.github.com/users/clickataxi/received_events","type":"Organization","site_admin":false},"repo":{"id":23419402,"name":"dd-ui","full_name":"clickataxi/dd-ui","owner":{"login":"clickataxi","id":1058748,"avatar_url":"https://avatars.githubusercontent.com/u/1058748?v=3","gravatar_id":"","url":"https://api.github.com/users/clickataxi","html_url":"https://github.com/clickataxi","followers_url":"https://api.github.com/users/clickataxi/followers","following_url":"https://api.github.com/users/clickataxi/following{/other_user}","gists_url":"https://api.github.com/users/clickataxi/gists{/gist_id}","starred_url":"https://api.github.com/users/clickataxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clickataxi/subscriptions","organizations_url":"https://api.github.com/users/clickataxi/orgs","repos_url":"https://api.github.com/users/clickataxi/repos","events_url":"https://api.github.com/users/clickataxi/events{/privacy}","received_events_url":"https://api.github.com/users/clickataxi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clickataxi/dd-ui","description":"Drivr AngularJS UI modules","fork":false,"url":"https://api.github.com/repos/clickataxi/dd-ui","forks_url":"https://api.github.com/repos/clickataxi/dd-ui/forks","keys_url":"https://api.github.com/repos/clickataxi/dd-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clickataxi/dd-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clickataxi/dd-ui/teams","hooks_url":"https://api.github.com/repos/clickataxi/dd-ui/hooks","issue_events_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/events{/number}","events_url":"https://api.github.com/repos/clickataxi/dd-ui/events","assignees_url":"https://api.github.com/repos/clickataxi/dd-ui/assignees{/user}","branches_url":"https://api.github.com/repos/clickataxi/dd-ui/branches{/branch}","tags_url":"https://api.github.com/repos/clickataxi/dd-ui/tags","blobs_url":"https://api.github.com/repos/clickataxi/dd-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clickataxi/dd-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clickataxi/dd-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/clickataxi/dd-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clickataxi/dd-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/clickataxi/dd-ui/languages","stargazers_url":"https://api.github.com/repos/clickataxi/dd-ui/stargazers","contributors_url":"https://api.github.com/repos/clickataxi/dd-ui/contributors","subscribers_url":"https://api.github.com/repos/clickataxi/dd-ui/subscribers","subscription_url":"https://api.github.com/repos/clickataxi/dd-ui/subscription","commits_url":"https://api.github.com/repos/clickataxi/dd-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/clickataxi/dd-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/clickataxi/dd-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/clickataxi/dd-ui/contents/{+path}","compare_url":"https://api.github.com/repos/clickataxi/dd-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clickataxi/dd-ui/merges","archive_url":"https://api.github.com/repos/clickataxi/dd-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clickataxi/dd-ui/downloads","issues_url":"https://api.github.com/repos/clickataxi/dd-ui/issues{/number}","pulls_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/clickataxi/dd-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/clickataxi/dd-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clickataxi/dd-ui/labels{/name}","releases_url":"https://api.github.com/repos/clickataxi/dd-ui/releases{/id}","deployments_url":"https://api.github.com/repos/clickataxi/dd-ui/deployments","created_at":"2014-08-28T07:35:29Z","updated_at":"2016-02-04T13:27:53Z","pushed_at":"2016-09-07T14:28:20Z","git_url":"git://github.com/clickataxi/dd-ui.git","ssh_url":"git@github.com:clickataxi/dd-ui.git","clone_url":"https://github.com/clickataxi/dd-ui.git","svn_url":"https://github.com/clickataxi/dd-ui","homepage":null,"size":1288,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"clickataxi:master","ref":"master","sha":"269bb11d169131ab651841b6f27783a1b6a95470","user":{"login":"clickataxi","id":1058748,"avatar_url":"https://avatars.githubusercontent.com/u/1058748?v=3","gravatar_id":"","url":"https://api.github.com/users/clickataxi","html_url":"https://github.com/clickataxi","followers_url":"https://api.github.com/users/clickataxi/followers","following_url":"https://api.github.com/users/clickataxi/following{/other_user}","gists_url":"https://api.github.com/users/clickataxi/gists{/gist_id}","starred_url":"https://api.github.com/users/clickataxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clickataxi/subscriptions","organizations_url":"https://api.github.com/users/clickataxi/orgs","repos_url":"https://api.github.com/users/clickataxi/repos","events_url":"https://api.github.com/users/clickataxi/events{/privacy}","received_events_url":"https://api.github.com/users/clickataxi/received_events","type":"Organization","site_admin":false},"repo":{"id":23419402,"name":"dd-ui","full_name":"clickataxi/dd-ui","owner":{"login":"clickataxi","id":1058748,"avatar_url":"https://avatars.githubusercontent.com/u/1058748?v=3","gravatar_id":"","url":"https://api.github.com/users/clickataxi","html_url":"https://github.com/clickataxi","followers_url":"https://api.github.com/users/clickataxi/followers","following_url":"https://api.github.com/users/clickataxi/following{/other_user}","gists_url":"https://api.github.com/users/clickataxi/gists{/gist_id}","starred_url":"https://api.github.com/users/clickataxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clickataxi/subscriptions","organizations_url":"https://api.github.com/users/clickataxi/orgs","repos_url":"https://api.github.com/users/clickataxi/repos","events_url":"https://api.github.com/users/clickataxi/events{/privacy}","received_events_url":"https://api.github.com/users/clickataxi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clickataxi/dd-ui","description":"Drivr AngularJS UI modules","fork":false,"url":"https://api.github.com/repos/clickataxi/dd-ui","forks_url":"https://api.github.com/repos/clickataxi/dd-ui/forks","keys_url":"https://api.github.com/repos/clickataxi/dd-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clickataxi/dd-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clickataxi/dd-ui/teams","hooks_url":"https://api.github.com/repos/clickataxi/dd-ui/hooks","issue_events_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/events{/number}","events_url":"https://api.github.com/repos/clickataxi/dd-ui/events","assignees_url":"https://api.github.com/repos/clickataxi/dd-ui/assignees{/user}","branches_url":"https://api.github.com/repos/clickataxi/dd-ui/branches{/branch}","tags_url":"https://api.github.com/repos/clickataxi/dd-ui/tags","blobs_url":"https://api.github.com/repos/clickataxi/dd-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clickataxi/dd-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clickataxi/dd-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/clickataxi/dd-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clickataxi/dd-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/clickataxi/dd-ui/languages","stargazers_url":"https://api.github.com/repos/clickataxi/dd-ui/stargazers","contributors_url":"https://api.github.com/repos/clickataxi/dd-ui/contributors","subscribers_url":"https://api.github.com/repos/clickataxi/dd-ui/subscribers","subscription_url":"https://api.github.com/repos/clickataxi/dd-ui/subscription","commits_url":"https://api.github.com/repos/clickataxi/dd-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/clickataxi/dd-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/clickataxi/dd-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/clickataxi/dd-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/clickataxi/dd-ui/contents/{+path}","compare_url":"https://api.github.com/repos/clickataxi/dd-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clickataxi/dd-ui/merges","archive_url":"https://api.github.com/repos/clickataxi/dd-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clickataxi/dd-ui/downloads","issues_url":"https://api.github.com/repos/clickataxi/dd-ui/issues{/number}","pulls_url":"https://api.github.com/repos/clickataxi/dd-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/clickataxi/dd-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/clickataxi/dd-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clickataxi/dd-ui/labels{/name}","releases_url":"https://api.github.com/repos/clickataxi/dd-ui/releases{/id}","deployments_url":"https://api.github.com/repos/clickataxi/dd-ui/deployments","created_at":"2014-08-28T07:35:29Z","updated_at":"2016-02-04T13:27:53Z","pushed_at":"2016-09-07T14:28:20Z","git_url":"git://github.com/clickataxi/dd-ui.git","ssh_url":"git@github.com:clickataxi/dd-ui.git","clone_url":"https://github.com/clickataxi/dd-ui.git","svn_url":"https://github.com/clickataxi/dd-ui","homepage":null,"size":1288,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63"},"html":{"href":"https://github.com/clickataxi/dd-ui/pull/63"},"issue":{"href":"https://api.github.com/repos/clickataxi/dd-ui/issues/63"},"comments":{"href":"https://api.github.com/repos/clickataxi/dd-ui/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clickataxi/dd-ui/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/clickataxi/dd-ui/statuses/3c1f8411cbae1e266c77c6423c681fea5d086a0a"}}}}
{"actor":{"display_login":"jnorkus"}}