{"action":"created","comment":{"url":"https://api.github.com/repos/gentics/mesh-ui/pulls/comments/172157291","pull_request_review_id":101078522,"id":172157291,"diff_hunk":"@@ -1,11 +1,137 @@\n-import { Component } from '@angular/core';\n+import { Component, ChangeDetectorRef, ViewChild, ContentChild, OnInit, OnDestroy } from '@angular/core';\n+import { ActivatedRoute, Router, ParamMap } from '@angular/router';\n+import { Subscription } from 'rxjs/Subscription';\n+import { Observable } from 'rxjs/Observable';\n+import { combineLatest } from 'rxjs/observable/combineLatest';\n+\n+import { EventEmitter } from 'protractor/node_modules/@types/selenium-webdriver';\n+\n+import { DropdownList } from 'gentics-ui-core';\n+\n+import { ApiService } from '../../../core/providers/api/api.service';\n+import { ListStateActions } from '../../../state/providers/list-state-actions';\n+import { ApplicationStateService } from '../../../state/providers/application-state.service';\n+\n+\n+import { ListEffectsService } from '../../../core/providers/effects/list-effects.service';\n+import { FilterSelection } from '../../../common/models/common.model';\n+import { fuzzyReplace } from '../../../common/util/fuzzy-search';\n+import { EntitiesService } from '../../../state/providers/entities.service';\n+\n+import { stringToColor } from '../../../common/util/util';\n+import { Tag } from '../../../common/models/tag.model';\n+import { NavigationService } from '../../../core/providers/navigation/navigation.service';\n \n @Component({\n-    selector: 'search-bar',\n+    selector: 'app-search-bar',\n     templateUrl: './search-bar.component.html',\n     styleUrls: ['./search-bar.scss']\n })\n \n-export class SearchBarComponent {\n+export class SearchBarComponent implements OnInit, OnDestroy {\n+\n+    private subscription: Subscription =  new Subscription();\n+\n+    private searching = false;\n+\n+    inputValue = '';\n+    searchQuery = '';\n+\n+    searchTags: Tag[] = [];\n+\n+    filteredTags: FilterSelection[];\n+\n+    @ViewChild(DropdownList)\n+    dropDownList: DropdownList;\n+\n+    constructor(\n+        private changeDetectorRef: ChangeDetectorRef,\n+        private api: ApiService,\n+        private listEffects: ListEffectsService,\n+        private state: ApplicationStateService,\n+        private entities: EntitiesService,\n+        private route: ActivatedRoute,\n+        private router: Router,\n+        private navigationService: NavigationService,\n+    ) {}\n+\n+    ngOnInit(): void {\n+        this.subscription.add(combineLatest(this.route.queryParamMap, this.state.select(state => state.entities.tag))\n+            .subscribe(([paramMap, tagUuids]) => {\n+                this.searchParamsChanged(paramMap);\n+            }));\n+    }\n+\n+    private searchParamsChanged(params: ParamMap) {\n+        this.searchQuery = params.get('q') || '';\n+        this.searchTags = (params.get('t') || '').split(',')\n+                                .map(uuid => this.state.now.entities.tag[uuid])\n+                                .filter(tag => !!tag !== false);\n+        this.changeDetectorRef.detectChanges(); // If the browser 'back' was clicked\n+    }\n+\n+    private filterTags(term: string): FilterSelection[] {\n+        if (term.trim() === '') {\n+            return [];\n+        }\n+\n+        const tags = this.state.now.tags.tags\n+                        .map(uuid => this.entities.getTag(uuid))\n+                        .filter(tag => this.searchTags.every(searchTag => searchTag.uuid !== tag.uuid));\n+\n+        const filteredTags = tags.reduce<FilterSelection[]>((filteredTags, tag) => {\n+            const matchedName = fuzzyReplace(term, tag.name);\n+            return (matchedName === null) ? filteredTags : [...filteredTags, { ...matchedName, tag }];\n+        }, []);\n+        return filteredTags;\n+    }\n+\n+    filterTermChanged(): void {\n+        const firstChar = this.inputValue.charAt(0);\n+\n+        if (firstChar === '#') {\n+            this.filteredTags = this.filterTags(this.inputValue.substr(1));\n+            if (!this.dropDownList.isOpen) {\n+                this.dropDownList.openDropdown();\n+            } else {\n+                this.dropDownList.resize();\n+            }\n+\n+        } else {\n+            this.state.actions.list.setFilterTerm(this.inputValue);\n+        }\n+    }\n+\n+    onSearchTagSelected(tag: Tag): void {\n+        this.inputValue = '';\n+        this.updateSearchParams(this.searchQuery, [...this.searchTags, tag]);\n+    }\n+\n+    onTagDeleted(tag: Tag): void {\n+        this.searchTags = this.searchTags.filter(searchTag => searchTag.uuid !== tag.uuid);\n+        this.updateSearchParams(this.searchQuery, this.searchTags.filter(searchTag => searchTag.uuid !== tag.uuid));","path":"src/app/editor/components/search-bar/search-bar.component.ts","position":115,"original_position":115,"commit_id":"45399b148fa7d39da668a7a8f8a436dad80afc3b","original_commit_id":"45399b148fa7d39da668a7a8f8a436dad80afc3b","user":{"login":"michaelbromley","id":6275952,"avatar_url":"https://avatars0.githubusercontent.com/u/6275952?v=4","gravatar_id":"","url":"https://api.github.com/users/michaelbromley","html_url":"https://github.com/michaelbromley","followers_url":"https://api.github.com/users/michaelbromley/followers","following_url":"https://api.github.com/users/michaelbromley/following{/other_user}","gists_url":"https://api.github.com/users/michaelbromley/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelbromley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelbromley/subscriptions","organizations_url":"https://api.github.com/users/michaelbromley/orgs","repos_url":"https://api.github.com/users/michaelbromley/repos","events_url":"https://api.github.com/users/michaelbromley/events{/privacy}","received_events_url":"https://api.github.com/users/michaelbromley/received_events","type":"User","site_admin":false},"body":"duplicated the filter here, just pass this.searchTags","created_at":"2018-03-05T11:26:08Z","updated_at":"2018-03-05T11:35:12Z","html_url":"https://github.com/gentics/mesh-ui/pull/47#discussion_r172157291","pull_request_url":"https://api.github.com/repos/gentics/mesh-ui/pulls/47","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/comments/172157291"},"html":{"href":"https://github.com/gentics/mesh-ui/pull/47#discussion_r172157291"},"pull_request":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/gentics/mesh-ui/pulls/47","id":172802412,"html_url":"https://github.com/gentics/mesh-ui/pull/47","diff_url":"https://github.com/gentics/mesh-ui/pull/47.diff","patch_url":"https://github.com/gentics/mesh-ui/pull/47.patch","issue_url":"https://api.github.com/repos/gentics/mesh-ui/issues/47","number":47,"state":"open","locked":false,"title":"Search bar","user":{"login":"virbas","id":1587403,"avatar_url":"https://avatars1.githubusercontent.com/u/1587403?v=4","gravatar_id":"","url":"https://api.github.com/users/virbas","html_url":"https://github.com/virbas","followers_url":"https://api.github.com/users/virbas/followers","following_url":"https://api.github.com/users/virbas/following{/other_user}","gists_url":"https://api.github.com/users/virbas/gists{/gist_id}","starred_url":"https://api.github.com/users/virbas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virbas/subscriptions","organizations_url":"https://api.github.com/users/virbas/orgs","repos_url":"https://api.github.com/users/virbas/repos","events_url":"https://api.github.com/users/virbas/events{/privacy}","received_events_url":"https://api.github.com/users/virbas/received_events","type":"User","site_admin":false},"body":"- Search bar component\r\n- Search functionality ","created_at":"2018-03-05T08:34:48Z","updated_at":"2018-03-05T11:35:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"879a3b71908dcb932233d704ea52192832402f84","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gentics/mesh-ui/pulls/47/commits","review_comments_url":"https://api.github.com/repos/gentics/mesh-ui/pulls/47/comments","review_comment_url":"https://api.github.com/repos/gentics/mesh-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gentics/mesh-ui/issues/47/comments","statuses_url":"https://api.github.com/repos/gentics/mesh-ui/statuses/45399b148fa7d39da668a7a8f8a436dad80afc3b","head":{"label":"gentics:search-bar","ref":"search-bar","sha":"45399b148fa7d39da668a7a8f8a436dad80afc3b","user":{"login":"gentics","id":233422,"avatar_url":"https://avatars0.githubusercontent.com/u/233422?v=4","gravatar_id":"","url":"https://api.github.com/users/gentics","html_url":"https://github.com/gentics","followers_url":"https://api.github.com/users/gentics/followers","following_url":"https://api.github.com/users/gentics/following{/other_user}","gists_url":"https://api.github.com/users/gentics/gists{/gist_id}","starred_url":"https://api.github.com/users/gentics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentics/subscriptions","organizations_url":"https://api.github.com/users/gentics/orgs","repos_url":"https://api.github.com/users/gentics/repos","events_url":"https://api.github.com/users/gentics/events{/privacy}","received_events_url":"https://api.github.com/users/gentics/received_events","type":"Organization","site_admin":false},"repo":{"id":79355815,"name":"mesh-ui","full_name":"gentics/mesh-ui","owner":{"login":"gentics","id":233422,"avatar_url":"https://avatars0.githubusercontent.com/u/233422?v=4","gravatar_id":"","url":"https://api.github.com/users/gentics","html_url":"https://github.com/gentics","followers_url":"https://api.github.com/users/gentics/followers","following_url":"https://api.github.com/users/gentics/following{/other_user}","gists_url":"https://api.github.com/users/gentics/gists{/gist_id}","starred_url":"https://api.github.com/users/gentics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentics/subscriptions","organizations_url":"https://api.github.com/users/gentics/orgs","repos_url":"https://api.github.com/users/gentics/repos","events_url":"https://api.github.com/users/gentics/events{/privacy}","received_events_url":"https://api.github.com/users/gentics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gentics/mesh-ui","description":"Gentics Mesh UI","fork":false,"url":"https://api.github.com/repos/gentics/mesh-ui","forks_url":"https://api.github.com/repos/gentics/mesh-ui/forks","keys_url":"https://api.github.com/repos/gentics/mesh-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gentics/mesh-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gentics/mesh-ui/teams","hooks_url":"https://api.github.com/repos/gentics/mesh-ui/hooks","issue_events_url":"https://api.github.com/repos/gentics/mesh-ui/issues/events{/number}","events_url":"https://api.github.com/repos/gentics/mesh-ui/events","assignees_url":"https://api.github.com/repos/gentics/mesh-ui/assignees{/user}","branches_url":"https://api.github.com/repos/gentics/mesh-ui/branches{/branch}","tags_url":"https://api.github.com/repos/gentics/mesh-ui/tags","blobs_url":"https://api.github.com/repos/gentics/mesh-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gentics/mesh-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gentics/mesh-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/gentics/mesh-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gentics/mesh-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/gentics/mesh-ui/languages","stargazers_url":"https://api.github.com/repos/gentics/mesh-ui/stargazers","contributors_url":"https://api.github.com/repos/gentics/mesh-ui/contributors","subscribers_url":"https://api.github.com/repos/gentics/mesh-ui/subscribers","subscription_url":"https://api.github.com/repos/gentics/mesh-ui/subscription","commits_url":"https://api.github.com/repos/gentics/mesh-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/gentics/mesh-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/gentics/mesh-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/gentics/mesh-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/gentics/mesh-ui/contents/{+path}","compare_url":"https://api.github.com/repos/gentics/mesh-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gentics/mesh-ui/merges","archive_url":"https://api.github.com/repos/gentics/mesh-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gentics/mesh-ui/downloads","issues_url":"https://api.github.com/repos/gentics/mesh-ui/issues{/number}","pulls_url":"https://api.github.com/repos/gentics/mesh-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/gentics/mesh-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/gentics/mesh-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gentics/mesh-ui/labels{/name}","releases_url":"https://api.github.com/repos/gentics/mesh-ui/releases{/id}","deployments_url":"https://api.github.com/repos/gentics/mesh-ui/deployments","created_at":"2017-01-18T15:51:33Z","updated_at":"2018-02-15T09:32:15Z","pushed_at":"2018-03-05T08:34:49Z","git_url":"git://github.com/gentics/mesh-ui.git","ssh_url":"git@github.com:gentics/mesh-ui.git","clone_url":"https://github.com/gentics/mesh-ui.git","svn_url":"https://github.com/gentics/mesh-ui","homepage":"https://getmesh.io","size":5497,"stargazers_count":5,"watchers_count":5,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":17,"watchers":5,"default_branch":"beta"}},"base":{"label":"gentics:develop","ref":"develop","sha":"21a070df722f240dd2ef854c6f383cd78263a087","user":{"login":"gentics","id":233422,"avatar_url":"https://avatars0.githubusercontent.com/u/233422?v=4","gravatar_id":"","url":"https://api.github.com/users/gentics","html_url":"https://github.com/gentics","followers_url":"https://api.github.com/users/gentics/followers","following_url":"https://api.github.com/users/gentics/following{/other_user}","gists_url":"https://api.github.com/users/gentics/gists{/gist_id}","starred_url":"https://api.github.com/users/gentics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentics/subscriptions","organizations_url":"https://api.github.com/users/gentics/orgs","repos_url":"https://api.github.com/users/gentics/repos","events_url":"https://api.github.com/users/gentics/events{/privacy}","received_events_url":"https://api.github.com/users/gentics/received_events","type":"Organization","site_admin":false},"repo":{"id":79355815,"name":"mesh-ui","full_name":"gentics/mesh-ui","owner":{"login":"gentics","id":233422,"avatar_url":"https://avatars0.githubusercontent.com/u/233422?v=4","gravatar_id":"","url":"https://api.github.com/users/gentics","html_url":"https://github.com/gentics","followers_url":"https://api.github.com/users/gentics/followers","following_url":"https://api.github.com/users/gentics/following{/other_user}","gists_url":"https://api.github.com/users/gentics/gists{/gist_id}","starred_url":"https://api.github.com/users/gentics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentics/subscriptions","organizations_url":"https://api.github.com/users/gentics/orgs","repos_url":"https://api.github.com/users/gentics/repos","events_url":"https://api.github.com/users/gentics/events{/privacy}","received_events_url":"https://api.github.com/users/gentics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gentics/mesh-ui","description":"Gentics Mesh UI","fork":false,"url":"https://api.github.com/repos/gentics/mesh-ui","forks_url":"https://api.github.com/repos/gentics/mesh-ui/forks","keys_url":"https://api.github.com/repos/gentics/mesh-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gentics/mesh-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gentics/mesh-ui/teams","hooks_url":"https://api.github.com/repos/gentics/mesh-ui/hooks","issue_events_url":"https://api.github.com/repos/gentics/mesh-ui/issues/events{/number}","events_url":"https://api.github.com/repos/gentics/mesh-ui/events","assignees_url":"https://api.github.com/repos/gentics/mesh-ui/assignees{/user}","branches_url":"https://api.github.com/repos/gentics/mesh-ui/branches{/branch}","tags_url":"https://api.github.com/repos/gentics/mesh-ui/tags","blobs_url":"https://api.github.com/repos/gentics/mesh-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gentics/mesh-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gentics/mesh-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/gentics/mesh-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gentics/mesh-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/gentics/mesh-ui/languages","stargazers_url":"https://api.github.com/repos/gentics/mesh-ui/stargazers","contributors_url":"https://api.github.com/repos/gentics/mesh-ui/contributors","subscribers_url":"https://api.github.com/repos/gentics/mesh-ui/subscribers","subscription_url":"https://api.github.com/repos/gentics/mesh-ui/subscription","commits_url":"https://api.github.com/repos/gentics/mesh-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/gentics/mesh-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/gentics/mesh-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/gentics/mesh-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/gentics/mesh-ui/contents/{+path}","compare_url":"https://api.github.com/repos/gentics/mesh-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gentics/mesh-ui/merges","archive_url":"https://api.github.com/repos/gentics/mesh-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gentics/mesh-ui/downloads","issues_url":"https://api.github.com/repos/gentics/mesh-ui/issues{/number}","pulls_url":"https://api.github.com/repos/gentics/mesh-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/gentics/mesh-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/gentics/mesh-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gentics/mesh-ui/labels{/name}","releases_url":"https://api.github.com/repos/gentics/mesh-ui/releases{/id}","deployments_url":"https://api.github.com/repos/gentics/mesh-ui/deployments","created_at":"2017-01-18T15:51:33Z","updated_at":"2018-02-15T09:32:15Z","pushed_at":"2018-03-05T08:34:49Z","git_url":"git://github.com/gentics/mesh-ui.git","ssh_url":"git@github.com:gentics/mesh-ui.git","clone_url":"https://github.com/gentics/mesh-ui.git","svn_url":"https://github.com/gentics/mesh-ui","homepage":"https://getmesh.io","size":5497,"stargazers_count":5,"watchers_count":5,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":17,"watchers":5,"default_branch":"beta"}},"_links":{"self":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/47"},"html":{"href":"https://github.com/gentics/mesh-ui/pull/47"},"issue":{"href":"https://api.github.com/repos/gentics/mesh-ui/issues/47"},"comments":{"href":"https://api.github.com/repos/gentics/mesh-ui/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gentics/mesh-ui/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/gentics/mesh-ui/statuses/45399b148fa7d39da668a7a8f8a436dad80afc3b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"michaelbromley"}}