File

src/app/modules/workspace/components/collaboration-content-filter/collaboration-content-filter.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs

Constructor

constructor(resourceService: ResourceService, config: ConfigService, activatedRoute: ActivatedRoute, route: Router, telemetryService: TelemetryService)

Constructor to create injected service(s) object Default method of Draft Component class

Parameters :
Name Type Optional Description
resourceService ResourceService No
config ConfigService No

Reference of ConfigService

activatedRoute ActivatedRoute No

Reference of ActivatedRoute

route Router No

Reference of Router

telemetryService TelemetryService No

Inputs

telemetryInteractCdata
Type : Array<literal type>
telemetryInteractContext
Type : any
telemetryInteractObject
Type : IInteractEventObject
telemetryInteractPdata
Type : IProducerData

Methods

applySorting
applySorting(sortByOption)
Parameters :
Name Optional
sortByOption No
Returns : void
Public handleSearch
handleSearch()
Returns : void
keyup
keyup(event)
Parameters :
Name Optional
event No
Returns : void
ngOnInit
ngOnInit()
Returns : void
removeFilterSelection
removeFilterSelection(filterType, value)
Parameters :
Name Optional
filterType No
value No
Returns : void
setCollabartionContentSearchInteractEdata
setCollabartionContentSearchInteractEdata()
Returns : void

Properties

Private activatedRoute
Type : ActivatedRoute

To send activatedRoute.snapshot to router navigation service for redirection to collaboration component

appTelemetryInteractData
Type : IInteractEventInput
Public config
Type : ConfigService

To get url, app configs

filterIntractEdata
Type : IInteractEventEdata

Telemetry filterIntractEdata

Public filterType
Type : any

type of filter

label
Type : Array<string>

label for filter selected

modelChanged
Type : Subject<string>
Default value : new Subject<string>()
position
Type : string

position for the popup

query
Type : string

value typed

queryParams
Type : any

queryParams

Public resourceService
Type : ResourceService

To call resource service which helps to use language constant

route
Type : Router

To navigate to other pages

sortByOption
Type : string
sortIcon
Default value : true

To show / hide sortIcon

sortingOptions
Type : Array<string>

SortingOptions

telemetryInteractEdata
Type : any
Public telemetryService
Type : TelemetryService
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, ConfigService } from '@sunbird/shared';
import * as _ from 'lodash-es';
import { Subject, of} from 'rxjs';
import { debounceTime, distinctUntilChanged, delay, flatMap } from 'rxjs/operators';
import { IInteractEventEdata, IInteractEventInput, IInteractEventObject, IProducerData, TelemetryService } from '@sunbird/telemetry';
@Component({
  selector: 'app-collaboration-content-filter',
  templateUrl: './collaboration-content-filter.component.html',
  styleUrls: ['./collaboration-content-filter.component.scss']
})
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;
  telemetryInteractEdata: any;
  appTelemetryInteractData: IInteractEventInput;

  public telemetryService: TelemetryService;

  @Input() telemetryInteractContext;
  @Input() telemetryInteractCdata: Array<{}>;
  @Input() telemetryInteractObject: IInteractEventObject;
  @Input() telemetryInteractPdata: IProducerData;

  /**
   * 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, telemetryService: TelemetryService) {
    this.telemetryService = telemetryService;
    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 = _.isArray(this.queryParams['sort_by']) ? this.queryParams['sort_by'][0] : 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.setCollabartionContentSearchInteractEdata();
    this.route.navigate(['workspace/content/collaborating-on', 1], { queryParams: this.queryParams });
  }
  keyup(event) {
    this.query = event;
    this.modelChanged.next(this.query);
  }
  setCollabartionContentSearchInteractEdata() {
    const searchInteractEdata = {
      id: 'search-collabaration-content',
      type: 'click',
      pageid: 'collabratingon'
    };
    if (this.query) {
      searchInteractEdata['extra'] = {
        query: this.query
      };
    }
      this.appTelemetryInteractData = {
       context: {
          env: _.get(this.telemetryInteractContext, 'env') || _.get(this.activatedRoute, 'snapshot.root.firstChild.data.telemetry.env') ||
          _.get(this.activatedRoute, 'snapshot.data.telemetry.env'),
          cdata: this.telemetryInteractCdata || [],
        },
        edata: searchInteractEdata
      };
      this.telemetryService.interact(this.appTelemetryInteractData);
  }

  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  });
  }
}
<div class="sbt-page-gap">
  <div class="ui grid padded">
    <div class="seven wide column pt-0 pl-0">
      <div class="ui fluid icon input left action" id="search-input-container">
        <div class="searchfilterinput ui search">
          <div class="searchicon ui icon input ">
            <input class="upForReviewSearchBox" type="text" name="filter_search" 
              [(ngModel)]="query" (keyup)="keyup(query)"
              placeholder="{{resourceService?.frmelmnts?.prmpt?.searchContent}}"
              title="Search" autocomplete="off" spellcheck="false" dir="auto" />
            <i class="circular search link icon"></i>
          </div>
        </div>
      </div>
    </div>
    <div class="two wide column pt-10" id="showFilterButton">
      <span class="browse item cursor-pointer" suiPopup [popupPlacement]="position" [popupTemplate]="popupTemplate" popupTrigger="outsideClick">
        {{resourceService?.frmelmnts?.lbl?.showFilters}}
        <i class="dropdown icon"  appTelemetryInteract [telemetryInteractEdata]="filterIntractEdata"></i>
      </span>
    </div>
    <div class="three wide column pt-5">
      <div class="twelve wide column">
        <div class="field">
          <div class="content dropdown-content">
           <span class="ShowFilterSubTitle">{{resourceService?.frmelmnts?.lbl?.sortby}}:&nbsp;</span>
            <div class="ui inline dropdown search-dropdown content-filter-sort" id="sortByDropDown">
              <sui-select class="inline" (selectedOptionChange)= "applySorting($event)" [(ngModel)]="sortByOption" [options]="sortingOptions"
              valueField="field"
          labelField="name"  #selectSort>
                <sui-select-option *ngFor="let option of selectSort.filteredOptions" [value]="option" >
                </sui-select-option>
              </sui-select>
            </div>
            <i *ngIf="sortByOption && sortByOption.length > 0" [ngClass]=" sortIcon === false ? 'sort content ascending icon' : 'sort content descending icon' "
              class="link" tabindex="0" (click)="applySorting(sortByOption)">
            </i>
          </div>
        </div>
      </div>
    </div>
  </div>
  
</div>
  <ng-template let-popup #popupTemplate>
    <div class="popup-content">
        <app-data-driven-filter [pageId]="'all-my-content-page'"[ignoreQuery]="['key','sortType','sort_by','query']" *ngIf="filterType" [filterEnv]="filterType"
        [accordionDefaultOpen]=true [isShowFilterLabel]=false [showSearchedParam]=false></app-data-driven-filter>
      </div>
  </ng-template>
  <div class="ui grid">
      <div class="twelve wide column content" *ngIf='queryParams != undefined'>
          <span *ngFor="let value of label">
            <span class="padded chip pr-5" *ngIf='queryParams[value.id] && queryParams[value.id].length > 0'>
              {{value.name}}:
              <span *ngFor="let item of queryParams[value.id] ">
                <a class="ui label mt-5 mr-5">
                  {{item}}
                  <i class="delete icon" tabindex="0" (click)="removeFilterSelection(value.id,item)"></i>
                </a>
              </span>
            </span>
          </span>
      </div>
  </div>
    

./collaboration-content-filter.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;

>>>.ui.dropdown:not(.button)>.default.text {
    display: none;
     }
     
     .ui.inline.dropdown.search-dropdown {
        margin-left: calculateRem(5px);
        box-sizing: border-box;
        }
    
    .popup-content{
        width: calculateRem(850px) !important;
    }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""