{"action":"created","comment":{"url":"https://api.github.com/repos/windup/windup-web/pulls/comments/104846889","pull_request_review_id":25700231,"id":104846889,"diff_hunk":"@@ -24,168 +22,72 @@ export class CheckboxesComponent implements OnInit, OnChanges\n      */\n     @Input()\n     valueCallback: (item: any) => string\n-        = app => { throw new Error(\"valueCallback not yet defined.\" +\n-                \" This means Angular didn't keep the order of setting @Inputs.\"); };\n+        = app => { throw new Error(\"valueCallback not yet defined.\") };\n \n     @Input()\n     labelCallback: (item: ItemType) => string;\n \n     @Input()\n-    equalsCallback: (item1: ItemType, item2: ItemType) => boolean;\n+    equalsCallback: (item1: ItemType, item2: ItemType) => boolean = (item1, item2) => {\n+        return this.valueCallback(item1) == this.valueCallback(item2);\n+    };\n \n     /**\n      * All available options.\n      */\n     @Input()\n     set options(options: ItemType[]){\n         this._options = options;\n-        console.log(\"set options()\", options);\n+        //console.log(\"set options()\", options);\n         if (!options)\n             return; // May be loaded async.\n         if (!Array.isArray(options))\n             throw new Error(\"Invalid @Input value for options: \" + JSON.stringify(options));\n-\n-        options.forEach(\n-            option => this.valueToOptionMap.set(this.valueCallback(option), option)\n-        );\n     }\n     get options(): ItemType[]{\n         return this._options;\n     }\n     _options: ItemType[];\n \n-    // For faster lookup of what option was clicked\n-    private valueToOptionMap: Map<string, ItemType> = new Map<string, ItemType>();\n-\n-\n     /**\n      * This can be either the values or a subset of options.\n      */\n-    @Input() //@Output()\n-    checkedOptions: string[] | ItemType[] = [];\n+    @Input()\n+    checkedOptions: ItemType[] = [];\n \n     @Output()\n-    checkedOptionsChange = new EventEmitter<string[] | ItemType[]>();\n+    checkedOptionsChange = new EventEmitter<ItemType[]>();\n \n     shouldBeChecked(option: ItemType): boolean {\n         console.log(\"shouldBeChecked() called.\", option, this.checkedOptions);\n-        let res = (() => {\n-            if (!this.checkedOptions)\n-                return false;\n-\n-            //if ((<ItemType[]>this.checkedOptions).indexOf(option) != -1)\n-            if ((<ItemType[]>this.checkedOptions).some(checkedOption => this.equalsCallback(option, checkedOption)))\n-                return true;\n-\n-            if ((<string[]>this.checkedOptions).indexOf(this.valueCallback(option)) != -1)\n-                return true;\n \n+        if (!this.checkedOptions)\n             return false;\n-        })();\n-        console.log(\"shouldBeChecked() says \" + res);\n-        return res;\n-    }\n \n-    /**\n-     * Determines whether the checked options are returned as string values only (see valueCallback),\n-     * or as a subset of options (object references).\n-     * This is useful when checkedOptions is empty and we don't know which of these to set.\n-     */\n-    @Input()\n-    checkedOptionsAreValuesOnly: boolean | null = null;\n+        if ((<ItemType[]>this.checkedOptions).some(checkedOption => this.equalsCallback(option, checkedOption)))\n+            return true;\n \n-    private initCheckedOptionsAreValuesOnly() {\n-        if (!this.checkedOptions || this.checkedOptions.length == 0)\n-            return; // Leave as is.\n-\n-        this.checkedOptionsAreValuesOnly = isString(this.checkedOptions[0]);\n+        return false;\n     }\n \n-    /// Does this duplicate checkedOptionsChange?\n-    //@Output()\n-    //onCheckedChange = new EventEmitter<string[] | ItemType[]>();\n-\n-\n-\n     private component: CheckboxesComponent;\n     private rootElement;\n \n-    public constructor(element: ElementRef, private _zone: NgZone) {\n+    public constructor(element: ElementRef) {\n         this.component = this;\n         this.rootElement = element.nativeElement;\n     }\n \n-    public ngOnChanges(changes: {[options: string]: SimpleChange}): any {\n-        console.warn(\"onChanges\", changes['options']);\n-\n-        /* /// This is handled by the setter?\n-        if (changes.hasOwnProperty('options')) {\n-            let newOptions: CheckboxData[] = changes['options'].currentValue;\n-            this.options = newOptions;\n-        }\n-        */\n-\n-        if (changes.hasOwnProperty('checkedOptions')) {\n-            this.checkedOptions = changes['checkedOptions'].currentValue;\n-        }\n-\n-        ///this.setChangeHandlersToCheckboxes();\n-    }\n-\n-    public ngOnInit() {\n-        //this.setChangeHandersToCheckboxes();\n-    }\n-\n-    private setChangeHandlersToCheckboxes() {\n-        console.log(\"setChangeHandersToCheckboxes() called\");\n-        /*setTimeout(() => {\n-            $(this.rootElement).find(\":checkbox\")\n-                .off()\n-                .change((event, data) => this.updateCheckedValues(event, data));\n-        }, 2000);*/\n-    }\n-\n     handleCheckboxChange(option: ItemType, $event)  {\n-        console.log(\"handleCheckboxChange() called\", option, $event);\n-        //$event.target.checked;\n-        this.updateCheckedValues();\n+        let checked = $event.target ? $event.target.checked : false;\n+        let index = this.checkedOptions.findIndex((checkedOption) => this.equalsCallback(checkedOption, option));\n+        //console.log(\"Index: \" + index);\n+\n+        //console.log(\"handleCheckboxChange() called\", this.labelCallback(option), checked);\n+        if (!checked && index != -1)\n+            this.checkedOptions.splice(index, 1);\n+        else\n+            this.checkedOptions.push(option);\n+        this.checkedOptionsChange.emit(this.checkedOptions);\n     }\n-\n-    private updateCheckedValues(): void {\n-        //this._zone.run(() => {\n-            this.checkedOptions = this.getCheckedValues();\n-            this.checkedOptionsChange.emit(this.checkedOptions);\n-            //this.onCheckedChange.emit(this.checkedOptions);\n-        //});\n-        console.log(\"updateCheckedValues() done\", this.checkedOptions);\n-    }\n-\n-    private getCheckedValues(): string[] | ItemType[] {\n-        let component = this;\n-        let values = $(this.rootElement).find(\":checkbox:checked\").map(\n-            function (i, domElement): string {\n-                if (!domElement['checked'])\n-                    return null;\n-                let val = domElement[\"value\"];\n-\n-                if (component.checkedOptionsAreValuesOnly)\n-                    return val;\n-\n-                let clickedOption = component.valueToOptionMap.get(val);\n-                if (!clickedOption)\n-                    return console.warn(\"Unknown option clicked\", val), null;\n-                else\n-                    return clickedOption;","path":"ui/src/main/webapp/src/app/shared/checkboxes.component.ts","position":202,"original_position":202,"commit_id":"491031fcd2580d3bf428dedd9291ff0fe751ad47","original_commit_id":"491031fcd2580d3bf428dedd9291ff0fe751ad47","user":{"login":"OndraZizka","id":644904,"avatar_url":"https://avatars2.githubusercontent.com/u/644904?v=3","gravatar_id":"","url":"https://api.github.com/users/OndraZizka","html_url":"https://github.com/OndraZizka","followers_url":"https://api.github.com/users/OndraZizka/followers","following_url":"https://api.github.com/users/OndraZizka/following{/other_user}","gists_url":"https://api.github.com/users/OndraZizka/gists{/gist_id}","starred_url":"https://api.github.com/users/OndraZizka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OndraZizka/subscriptions","organizations_url":"https://api.github.com/users/OndraZizka/orgs","repos_url":"https://api.github.com/users/OndraZizka/repos","events_url":"https://api.github.com/users/OndraZizka/events{/privacy}","received_events_url":"https://api.github.com/users/OndraZizka/received_events","type":"User","site_admin":false},"body":"Right, this was a bit overengineered. But with angular I tend to expect things changing at any moment without knowing why :)","created_at":"2017-03-08T05:30:35Z","updated_at":"2017-03-08T05:30:57Z","html_url":"https://github.com/windup/windup-web/pull/254#discussion_r104846889","pull_request_url":"https://api.github.com/repos/windup/windup-web/pulls/254","_links":{"self":{"href":"https://api.github.com/repos/windup/windup-web/pulls/comments/104846889"},"html":{"href":"https://github.com/windup/windup-web/pull/254#discussion_r104846889"},"pull_request":{"href":"https://api.github.com/repos/windup/windup-web/pulls/254"}}},"pull_request":{"url":"https://api.github.com/repos/windup/windup-web/pulls/254","id":109589040,"html_url":"https://github.com/windup/windup-web/pull/254","diff_url":"https://github.com/windup/windup-web/pull/254.diff","patch_url":"https://github.com/windup/windup-web/pull/254.patch","issue_url":"https://api.github.com/repos/windup/windup-web/issues/254","number":254,"state":"open","locked":false,"title":"Task 572: Save & Run and Fixes to App Selection","user":{"login":"jsight","id":1181549,"avatar_url":"https://avatars0.githubusercontent.com/u/1181549?v=3","gravatar_id":"","url":"https://api.github.com/users/jsight","html_url":"https://github.com/jsight","followers_url":"https://api.github.com/users/jsight/followers","following_url":"https://api.github.com/users/jsight/following{/other_user}","gists_url":"https://api.github.com/users/jsight/gists{/gist_id}","starred_url":"https://api.github.com/users/jsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsight/subscriptions","organizations_url":"https://api.github.com/users/jsight/orgs","repos_url":"https://api.github.com/users/jsight/repos","events_url":"https://api.github.com/users/jsight/events{/privacy}","received_events_url":"https://api.github.com/users/jsight/received_events","type":"User","site_admin":false},"body":"I have marked this as ready for review, but really this will likely change once your group removal work is complete.\r\n\r\nI was just wondering if you could review the checkboxes stuff in the mean time, though.","created_at":"2017-03-07T22:45:01Z","updated_at":"2017-03-08T05:30:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe66919ff45dc4e70cb465d23965631b2cbdeb34","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/windup/windup-web/pulls/254/commits","review_comments_url":"https://api.github.com/repos/windup/windup-web/pulls/254/comments","review_comment_url":"https://api.github.com/repos/windup/windup-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/windup/windup-web/issues/254/comments","statuses_url":"https://api.github.com/repos/windup/windup-web/statuses/491031fcd2580d3bf428dedd9291ff0fe751ad47","head":{"label":"jsight:task_572_configuration_page","ref":"task_572_configuration_page","sha":"491031fcd2580d3bf428dedd9291ff0fe751ad47","user":{"login":"jsight","id":1181549,"avatar_url":"https://avatars0.githubusercontent.com/u/1181549?v=3","gravatar_id":"","url":"https://api.github.com/users/jsight","html_url":"https://github.com/jsight","followers_url":"https://api.github.com/users/jsight/followers","following_url":"https://api.github.com/users/jsight/following{/other_user}","gists_url":"https://api.github.com/users/jsight/gists{/gist_id}","starred_url":"https://api.github.com/users/jsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsight/subscriptions","organizations_url":"https://api.github.com/users/jsight/orgs","repos_url":"https://api.github.com/users/jsight/repos","events_url":"https://api.github.com/users/jsight/events{/privacy}","received_events_url":"https://api.github.com/users/jsight/received_events","type":"User","site_admin":false},"repo":{"id":52311849,"name":"windup-web","full_name":"jsight/windup-web","owner":{"login":"jsight","id":1181549,"avatar_url":"https://avatars0.githubusercontent.com/u/1181549?v=3","gravatar_id":"","url":"https://api.github.com/users/jsight","html_url":"https://github.com/jsight","followers_url":"https://api.github.com/users/jsight/followers","following_url":"https://api.github.com/users/jsight/following{/other_user}","gists_url":"https://api.github.com/users/jsight/gists{/gist_id}","starred_url":"https://api.github.com/users/jsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsight/subscriptions","organizations_url":"https://api.github.com/users/jsight/orgs","repos_url":"https://api.github.com/users/jsight/repos","events_url":"https://api.github.com/users/jsight/events{/privacy}","received_events_url":"https://api.github.com/users/jsight/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jsight/windup-web","description":"Windup as a Web Service","fork":true,"url":"https://api.github.com/repos/jsight/windup-web","forks_url":"https://api.github.com/repos/jsight/windup-web/forks","keys_url":"https://api.github.com/repos/jsight/windup-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jsight/windup-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jsight/windup-web/teams","hooks_url":"https://api.github.com/repos/jsight/windup-web/hooks","issue_events_url":"https://api.github.com/repos/jsight/windup-web/issues/events{/number}","events_url":"https://api.github.com/repos/jsight/windup-web/events","assignees_url":"https://api.github.com/repos/jsight/windup-web/assignees{/user}","branches_url":"https://api.github.com/repos/jsight/windup-web/branches{/branch}","tags_url":"https://api.github.com/repos/jsight/windup-web/tags","blobs_url":"https://api.github.com/repos/jsight/windup-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jsight/windup-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jsight/windup-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/jsight/windup-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jsight/windup-web/statuses/{sha}","languages_url":"https://api.github.com/repos/jsight/windup-web/languages","stargazers_url":"https://api.github.com/repos/jsight/windup-web/stargazers","contributors_url":"https://api.github.com/repos/jsight/windup-web/contributors","subscribers_url":"https://api.github.com/repos/jsight/windup-web/subscribers","subscription_url":"https://api.github.com/repos/jsight/windup-web/subscription","commits_url":"https://api.github.com/repos/jsight/windup-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/jsight/windup-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/jsight/windup-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/jsight/windup-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/jsight/windup-web/contents/{+path}","compare_url":"https://api.github.com/repos/jsight/windup-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jsight/windup-web/merges","archive_url":"https://api.github.com/repos/jsight/windup-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jsight/windup-web/downloads","issues_url":"https://api.github.com/repos/jsight/windup-web/issues{/number}","pulls_url":"https://api.github.com/repos/jsight/windup-web/pulls{/number}","milestones_url":"https://api.github.com/repos/jsight/windup-web/milestones{/number}","notifications_url":"https://api.github.com/repos/jsight/windup-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jsight/windup-web/labels{/name}","releases_url":"https://api.github.com/repos/jsight/windup-web/releases{/id}","deployments_url":"https://api.github.com/repos/jsight/windup-web/deployments","created_at":"2016-02-22T22:46:57Z","updated_at":"2016-02-22T22:46:58Z","pushed_at":"2017-03-07T22:44:21Z","git_url":"git://github.com/jsight/windup-web.git","ssh_url":"git@github.com:jsight/windup-web.git","clone_url":"https://github.com/jsight/windup-web.git","svn_url":"https://github.com/jsight/windup-web","homepage":null,"size":6069,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"windup:master","ref":"master","sha":"dbfc00874f237c0bba73968b2fbfd88d6ed699c8","user":{"login":"windup","id":4266383,"avatar_url":"https://avatars2.githubusercontent.com/u/4266383?v=3","gravatar_id":"","url":"https://api.github.com/users/windup","html_url":"https://github.com/windup","followers_url":"https://api.github.com/users/windup/followers","following_url":"https://api.github.com/users/windup/following{/other_user}","gists_url":"https://api.github.com/users/windup/gists{/gist_id}","starred_url":"https://api.github.com/users/windup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windup/subscriptions","organizations_url":"https://api.github.com/users/windup/orgs","repos_url":"https://api.github.com/users/windup/repos","events_url":"https://api.github.com/users/windup/events{/privacy}","received_events_url":"https://api.github.com/users/windup/received_events","type":"Organization","site_admin":false},"repo":{"id":31555668,"name":"windup-web","full_name":"windup/windup-web","owner":{"login":"windup","id":4266383,"avatar_url":"https://avatars2.githubusercontent.com/u/4266383?v=3","gravatar_id":"","url":"https://api.github.com/users/windup","html_url":"https://github.com/windup","followers_url":"https://api.github.com/users/windup/followers","following_url":"https://api.github.com/users/windup/following{/other_user}","gists_url":"https://api.github.com/users/windup/gists{/gist_id}","starred_url":"https://api.github.com/users/windup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windup/subscriptions","organizations_url":"https://api.github.com/users/windup/orgs","repos_url":"https://api.github.com/users/windup/repos","events_url":"https://api.github.com/users/windup/events{/privacy}","received_events_url":"https://api.github.com/users/windup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/windup/windup-web","description":"Windup as a Web Service","fork":false,"url":"https://api.github.com/repos/windup/windup-web","forks_url":"https://api.github.com/repos/windup/windup-web/forks","keys_url":"https://api.github.com/repos/windup/windup-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/windup/windup-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/windup/windup-web/teams","hooks_url":"https://api.github.com/repos/windup/windup-web/hooks","issue_events_url":"https://api.github.com/repos/windup/windup-web/issues/events{/number}","events_url":"https://api.github.com/repos/windup/windup-web/events","assignees_url":"https://api.github.com/repos/windup/windup-web/assignees{/user}","branches_url":"https://api.github.com/repos/windup/windup-web/branches{/branch}","tags_url":"https://api.github.com/repos/windup/windup-web/tags","blobs_url":"https://api.github.com/repos/windup/windup-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/windup/windup-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/windup/windup-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/windup/windup-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/windup/windup-web/statuses/{sha}","languages_url":"https://api.github.com/repos/windup/windup-web/languages","stargazers_url":"https://api.github.com/repos/windup/windup-web/stargazers","contributors_url":"https://api.github.com/repos/windup/windup-web/contributors","subscribers_url":"https://api.github.com/repos/windup/windup-web/subscribers","subscription_url":"https://api.github.com/repos/windup/windup-web/subscription","commits_url":"https://api.github.com/repos/windup/windup-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/windup/windup-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/windup/windup-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/windup/windup-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/windup/windup-web/contents/{+path}","compare_url":"https://api.github.com/repos/windup/windup-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/windup/windup-web/merges","archive_url":"https://api.github.com/repos/windup/windup-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/windup/windup-web/downloads","issues_url":"https://api.github.com/repos/windup/windup-web/issues{/number}","pulls_url":"https://api.github.com/repos/windup/windup-web/pulls{/number}","milestones_url":"https://api.github.com/repos/windup/windup-web/milestones{/number}","notifications_url":"https://api.github.com/repos/windup/windup-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/windup/windup-web/labels{/name}","releases_url":"https://api.github.com/repos/windup/windup-web/releases{/id}","deployments_url":"https://api.github.com/repos/windup/windup-web/deployments","created_at":"2015-03-02T18:26:53Z","updated_at":"2017-03-02T21:06:13Z","pushed_at":"2017-03-07T22:45:01Z","git_url":"git://github.com/windup/windup-web.git","ssh_url":"git@github.com:windup/windup-web.git","clone_url":"https://github.com/windup/windup-web.git","svn_url":"https://github.com/windup/windup-web","homepage":null,"size":2533,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/windup/windup-web/pulls/254"},"html":{"href":"https://github.com/windup/windup-web/pull/254"},"issue":{"href":"https://api.github.com/repos/windup/windup-web/issues/254"},"comments":{"href":"https://api.github.com/repos/windup/windup-web/issues/254/comments"},"review_comments":{"href":"https://api.github.com/repos/windup/windup-web/pulls/254/comments"},"review_comment":{"href":"https://api.github.com/repos/windup/windup-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/windup/windup-web/pulls/254/commits"},"statuses":{"href":"https://api.github.com/repos/windup/windup-web/statuses/491031fcd2580d3bf428dedd9291ff0fe751ad47"}}}}
{"actor":{"display_login":"OndraZizka"}}