File

src/app/modules/workspace/components/up-for-review-filter/up-for-review-filter.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

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

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

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

Properties

Private activatedRoute
Type : ActivatedRoute

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

Public config
Type : ConfigService

To get url, app configs

filterIntractEdata
Type : IInteractEventEdata
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
Public redirectUrl
Type : string

redirect url

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>

upForReviewSortingOptions

import { Subject, of} from 'rxjs';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, ConfigService } from '@sunbird/shared';
import * as _ from 'lodash-es';
import { debounceTime, distinctUntilChanged, delay, flatMap } from 'rxjs/operators';
import { IInteractEventEdata } from '@sunbird/telemetry';
@Component({
  selector: 'app-up-for-review-filter',
  templateUrl: './up-for-review-filter.component.html',
  styleUrls: ['./up-for-review-filter.component.scss']
})
export class UpforReviewFilterComponent 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 draft  component
  */
  private activatedRoute: ActivatedRoute;
  /**
   * value typed
   */
  query: string;
  /**
   * upForReviewSortingOptions
  */
  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>;
  /**
  * redirect url
  */
  public redirectUrl: string;
  queryParams: any;
  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.upForReviewSortingOptions;
  }

  ngOnInit() {
    this.filterType = this.config.appConfig.upForReview.filterType;
    this.redirectUrl = this.config.appConfig.upForReview.inPageredirectUrl;
    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: 'up-for-review-page'
      };
  }
  public handleSearch() {
    if (this.query.length > 0) {
      this.queryParams['query'] = this.query;
    } else {
      delete this.queryParams['query'];
    }
    this.route.navigate(['workspace/content/upForReview', 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/upForReview', 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/upForReview', 1], { queryParams: this.queryParams  });
  }
}
<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="one wide column"></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="two wide column pt-5">
    <div class="twelve wide column">
      <div class="field">
        <div class="content dropdown-content">
         <span class="ShowFilterSubTitle">{{resourceService?.frmelmnts?.lbl?.sortby}}:</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>

<ng-template let-popup #popupTemplate>
  <div class="popup-content">
      <app-data-driven-filter [pageId]="'up-for-review-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>
  

./up-for-review-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 ""