File

src/app/manage-learn/shared/components/filter-modal/filter-modal.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs

Constructor

constructor(loader: LoaderService, kendraSrvc: KendraApiService, unnatiSrvc: UnnatiDataService, modalCtrl: ModalController, utils: UtilsService, location: Location, platform: Platform)
Parameters :
Name Type Optional
loader LoaderService No
kendraSrvc KendraApiService No
unnatiSrvc UnnatiDataService No
modalCtrl ModalController No
utils UtilsService No
location Location No
platform Platform No

Inputs

entityId
Type : string
type
Type : string

Methods

dismissModal
dismissModal(data?)
Parameters :
Name Optional
data Yes
Returns : void
getEntityTypes
getEntityTypes()
Returns : void
loadData
loadData(event)
Parameters :
Name Optional
event No
Returns : void
ngOnInit
ngOnInit()
Returns : void
search
search(searchText)
Parameters :
Name Optional
searchText No
Returns : void
Async searchProgramByEntity
searchProgramByEntity(searchText: any)
Parameters :
Name Type Optional
searchText any No
Returns : any
Async serachEntity
serachEntity(searchText: any)
Parameters :
Name Type Optional
searchText any No
Returns : any
typeChange
typeChange(e)
Parameters :
Name Optional
e No
Returns : void

Properties

count
Type : any
dataList
Type : any
Default value : []
entityTypes
Type : any
Public kendraSrvc
Type : KendraApiService
limit
Type : number
Default value : 15
page
Type : number
Default value : 1
Public platform
Type : Platform
searchText
Type : any
selectedType
Type : string
Default value : 'school'
Public unnatiSrvc
Type : UnnatiDataService
import { Component, Input, OnInit } from '@angular/core';
import { LoaderService, UtilsService } from '@app/app/manage-learn/core';
import { KendraApiService } from '@app/app/manage-learn/core/services/kendra-api.service';
import { UnnatiDataService } from '@app/app/manage-learn/core/services/unnati-data.service';
import { ModalController, Platform } from '@ionic/angular';
import * as _ from 'underscore';
import { urlConstants } from '@app/app/manage-learn/core/constants/urlConstants';
import { Location } from '@angular/common';

@Component({
  selector: 'app-filter-modal',
  templateUrl: './filter-modal.component.html',
  styleUrls: ['./filter-modal.component.scss'],
})
export class FilterModalComponent implements OnInit {
  page = 1;
  limit = 15;
  entityTypes: any;
  selectedType = 'school';
  dataList: any = [];
  @Input() type: string;
  @Input() entityId: string;
  searchText: any;
  count: any;
  constructor(
    private loader: LoaderService,
    // public reportSrvc: ReportsService,
    public kendraSrvc: KendraApiService,
    public unnatiSrvc: UnnatiDataService,
    private modalCtrl: ModalController,
    private utils: UtilsService,
    private location: Location,
    public platform: Platform
  ) {
    this.search = _.debounce(this.search, 500);
  }

  ngOnInit() {
    this.dataList = [];
    this.search('');
  }

  typeChange(e) {
    this.selectedType = e.detail.value;

    this.serachEntity(this.searchText);
  }

  search(searchText) {
    if (searchText == null || searchText == undefined) {
      searchText = '';
    }
    this.searchText = searchText;

    this.type == 'entity' ? this.serachEntity(searchText) : this.searchProgramByEntity(searchText);
  }
  async searchProgramByEntity(searchText: any) {
    this.loader.startLoader();
    let payload = await this.utils.getProfileData();
    const config = {
      url:
        urlConstants.API_URLS.GET_PROGRAM_BY_ENTITY +
        // this.entityId +
        `?search=${encodeURIComponent(searchText)}&page=${this.page}&limit=${this.limit}`,
      payload: payload,
    };
    this.unnatiSrvc.post(config).subscribe(
      (data) => {
        this.loader.stopLoader();
        this.dataList = this.dataList.concat(data.result.data);
      },
      (error) => {
        this.loader.stopLoader();
      }
    );
  }
  async serachEntity(searchText: any) {

  }
  getEntityTypes() {
    this.utils.getMandatoryEntitiesList().then((data) => {
      this.entityTypes = data;
    });
  }

  dismissModal(data?) {
    this.modalCtrl.dismiss(data);
  }

  loadData(event) {
    setTimeout(() => {
      event.target.complete();
      this.page++;
      this.search(this.searchText);
      if (this.dataList.length == this.count) {
        event.target.disabled = true;
      }
    }, 500);
  }
}
<ion-header  [ngClass]="{'container': platform.is('ios')}" >
  <app-search-header (onSearch)="search($event)">
    <ion-back-button></ion-back-button>
  </app-search-header>
</ion-header>
<ion-content>
  <ion-toolbar class="sb-header-toolbar">
    <ion-buttons class="font-size-20 padding-left-6" (click)="dismissModal()" slot="start">
      <ion-icon slot="start" role="button" name="arrow-back" aria-label="back" class="batches-header-text"></ion-icon>
    </ion-buttons>
  </ion-toolbar>
  <div *ngIf="entityTypes && type == 'entity'">
    <ion-select placeholder="Select One" (ionChange)="typeChange($event)" [value]="selectedType">
      <ion-select-option [value]="t" *ngFor="let t of entityTypes; let i = index">{{
        t | uppercase
      }}</ion-select-option>
    </ion-select>

    <p class="type-filter-container" color="primary">{{ selectedType }}</p>
  </div>
  <div>
    <p class="type-filter-container py-24" *ngIf="type == 'program'" color="primary">Programs</p>
  </div>
  <section>
    <app-no-data *ngIf="!dataList.length"></app-no-data>
  </section>
  <div *ngIf="dataList">
    <ion-item lines="inset" *ngFor="let data of dataList" (click)="dismissModal(data)">
      <ion-label class="ion-text-wrap">{{ data?.name }} </ion-label>
    </ion-item>
    <ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
      <ion-infinite-scroll-content loadingSpinner="bubbles" loadingText="Loading more data...">
      </ion-infinite-scroll-content>
    </ion-infinite-scroll>
  </div>
</ion-content>

./filter-modal.component.scss

.type-filter-container {
  display: flex;
  justify-content: center;
  text-transform: capitalize;
  font-size: 1.375rem;
}
.container {
  margin-top: env(safe-area-inset-top);
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""