src/app/modules/workspace/components/collaboration-content-filter/collaboration-content-filter.component.ts
selector | app-collaboration-content-filter |
styles |
>>> .ui.dropdown:not(.button)>.default.text {
display: none;
}
.ui.inline.dropdown.search-dropdown {
margin-left: 5px;
box-sizing: border-box;
}
.popup-content{
width: 850px !important;
}
|
templateUrl | collaboration-content-filter.component.html |
constructor(resourceService: any, config: any, activatedRoute: ActivatedRoute, route: Router)
|
Constructor to create injected service(s) object
Parameters :
|
Public handleSearch |
handleSearch()
|
Returns:
void
|
keyup |
keyup(event: any)
|
Returns:
void
|
applySorting |
applySorting(sortByOption: any)
|
Returns:
void
|
removeFilterSelection |
removeFilterSelection(filterType: any, value: any)
|
Returns:
void
|
Private activatedRoute |
activatedRoute: |
To send activatedRoute.snapshot to router navigation |
Public config |
config: |
To get url, app configs |
filterIntractEdata |
filterIntractEdata: |
Telemetry filterIntractEdata |
Public filterType |
filterType: |
type of filter |
label |
label: |
label for filter selected |
modelChanged |
modelChanged: |
position |
position: |
position for the popup |
query |
query: |
value typed |
queryParams |
queryParams: |
queryParams |
Public resourceService |
resourceService: |
To call resource service which helps to use language constant |
route |
route: |
To navigate to other pages |
sortByOption |
sortByOption: |
sortIcon |
sortIcon: |
Default value: true
|
To show / hide sortIcon |
sortingOptions |
sortingOptions: |
SortingOptions |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import { Component, OnInit, EventEmitter, Output } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, ConfigService } from '@sunbird/shared';
import { ISelectFilter } from '../../interfaces/selectfilter';
import * as _ from 'lodash-es';
import { Subject , Observable, of} from 'rxjs';
import { debounceTime, distinctUntilChanged, delay, flatMap } from 'rxjs/operators';
import { IInteractEventEdata } from '@sunbird/telemetry';
@Component({
selector: 'app-collaboration-content-filter',
templateUrl: './collaboration-content-filter.component.html',
styles: [`
>>> .ui.dropdown:not(.button)>.default.text {
display: none;
}
.ui.inline.dropdown.search-dropdown {
margin-left: 5px;
box-sizing: border-box;
}
.popup-content{
width: 850px !important;
}
`]
})
export class CollaborationContentFilterComponent implements OnInit {
modelChanged: Subject<string> = new Subject<string>();
/**
* To navigate to other pages
*/
route: Router;
/**
* To send activatedRoute.snapshot to router navigation
* service for redirection to collaboration component
*/
private activatedRoute: ActivatedRoute;
/**
* value typed
*/
query: string;
/**
* SortingOptions
*/
sortingOptions: Array<string>;
/**
* To show / hide sortIcon
*/
sortIcon = true;
/**
* position for the popup
*/
position: string;
/**
* To call resource service which helps to use language constant
*/
public resourceService: ResourceService;
/**
* To get url, app configs
*/
public config: ConfigService;
sortByOption: string;
/**
* type of filter
*/
public filterType: any;
/**
* label for filter selected
*/
label: Array<string>;
/**
* queryParams
*/
queryParams: any;
/**
* Telemetry filterIntractEdata
*/
filterIntractEdata: IInteractEventEdata;
/**
* Constructor to create injected service(s) object
Default method of Draft Component class
* @param {SearchService} SearchService Reference of SearchService
* @param {UserService} UserService Reference of UserService
* @param {Router} route Reference of Router
* @param {PaginationService} paginationService Reference of PaginationService
* @param {ActivatedRoute} activatedRoute Reference of ActivatedRoute
* @param {ConfigService} config Reference of ConfigService
*/
constructor(resourceService: ResourceService, config: ConfigService,
activatedRoute: ActivatedRoute,
route: Router) {
this.route = route;
this.activatedRoute = activatedRoute;
this.resourceService = resourceService;
this.config = config;
this.position = 'bottom right';
this.route.onSameUrlNavigation = 'reload';
this.label = this.config.dropDownConfig.FILTER.WORKSPACE.label;
this.sortingOptions = this.config.dropDownConfig.FILTER.RESOURCES.collaboratingOnSortingOptions;
}
ngOnInit() {
this.filterType = this.config.appConfig.collaboration.filterType;
this.activatedRoute.queryParams
.subscribe(params => {
this.queryParams = { ...params };
this.query = this.queryParams['query'];
this.sortByOption = this.queryParams['sort_by'];
_.forIn(params, (value, key) => {
if (typeof value === 'string' && key !== 'query') {
this.queryParams[key] = [value];
}
});
});
this.modelChanged.pipe(debounceTime(1000),
distinctUntilChanged(),
flatMap(search => of(search).pipe(delay(500)))
).
subscribe(query => {
this.query = query;
this.handleSearch();
});
this.filterIntractEdata = {
id: 'filter',
type: 'click',
pageid: 'collaboration-content-page'
};
}
public handleSearch() {
if (this.query.length > 0) {
this.queryParams['query'] = this.query;
} else {
delete this.queryParams['query'];
}
this.route.navigate(['workspace/content/collaborating-on', 1], { queryParams: this.queryParams });
}
keyup(event) {
this.query = event;
this.modelChanged.next(this.query);
}
applySorting(sortByOption) {
this.sortIcon = !this.sortIcon;
this.queryParams['sortType'] = this.sortIcon ? 'desc' : 'asc';
this.queryParams['sort_by'] = sortByOption;
this.route.navigate(['workspace/content/collaborating-on', 1], { queryParams: this.queryParams });
}
removeFilterSelection(filterType, value) {
const itemIndex = this.queryParams[filterType].indexOf(value);
if (itemIndex !== -1) {
this.queryParams[filterType].splice(itemIndex, 1);
}
this.route.navigate(['workspace/content/collaborating-on', 1], { queryParams: this.queryParams });
}
}