File

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

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(navCtrl: NavController, navParams: NavParams, utils: UtilityService, toast: ToastService, modalCtrl: ModalController, commonUtilService: CommonUtilService, platform: Platform)
Parameters :
Name Type Optional
navCtrl NavController No
navParams NavParams No
utils UtilityService No
toast ToastService No
modalCtrl ModalController No
commonUtilService CommonUtilService No
platform Platform No

Methods

applyFilter
applyFilter()
Returns : void
close
close()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onQuestionClick
onQuestionClick(id)
Parameters :
Name Optional
id No
Returns : void

Properties

data
Type : any
dataType
Type : any
filteredData
Type : any
Public navCtrl
Type : NavController
Public navParams
Type : NavParams
Public platform
Type : Platform
import { Component, OnInit } from '@angular/core';
import { ToastService } from '@app/app/manage-learn/core';
import { CommonUtilService, UtilityService } from '@app/services';
import { ModalController, NavController, NavParams, Platform } from '@ionic/angular';

@Component({
  selector: 'report-modal-filter',
  templateUrl: './report.modal.filter.html',
  styleUrls: ['./report.modal.filter.scss'],
})
export class ReportModalFilter implements OnInit {
  filteredData: any;
  data: any;
  dataType: any;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    // private viewCntrl: ViewController,
    private utils: UtilityService,
    private toast: ToastService,
    private modalCtrl: ModalController,
    private commonUtilService: CommonUtilService,
    public platform: Platform
  ) {}

  ngOnInit() {
    this.data = this.navParams.get('data');
    this.filteredData = this.navParams.get('filteredData');
    this.dataType = this.navParams.get('dataType');
  }

  /*  onQuestionClick(externalId) {
    if (this.filteredQuestions.includes(externalId)) {
      const indexOfQuestion = this.filteredQuestions.indexOf(externalId);
      this.filteredQuestions.splice(indexOfQuestion, 1);
    } else {
      this.filteredQuestions.push(externalId);
    }
    console.log(JSON.stringify(this.filteredQuestions));
  }
   */
  onQuestionClick(id) {
    if (this.filteredData.includes(id)) {
      const indexOfQuestion = this.filteredData.indexOf(id);
      this.filteredData.splice(indexOfQuestion, 1);
    } else {
      this.filteredData.push(id);
    }
    console.log(JSON.stringify(this.filteredData));
  }

  applyFilter() {
    let msg = this.commonUtilService.translateMessage('FRMELEMENTS_MSG_SELECT_AT_LEAST_ONE_QUESTION');
    if (this.dataType == 'criteria') {
      msg = this.commonUtilService.translateMessage('FRMELEMENTS_MSG_SELECT_AT_LEAST_ONE_CRITERIA');
    }
    !this.filteredData.length
      ? this.toast.openToast(msg)
      : // : this.viewCntrl.dismiss({
        this.modalCtrl.dismiss({
          filter: this.filteredData,
          action: 'updated',
        });
  }
  /* applyFilter() {
    !this.filteredQuestions.length
      ? this.toast.openToast('Select at least one question')
      : // : this.viewCntrl.dismiss({
        this.modalCtrl.dismiss({
          filter: this.filteredQuestions,
          action: 'updated',
        });
  }
 */
  close() {
    this.modalCtrl.dismiss('cancel');
  }
}
<ion-content padding [ngClass]="{'container': platform.is('ios')}">
  <div>
    <h3 class="heading" *ngIf="dataType == 'question'">{{ 'FRMELEMENTS_MSG_QUESTION_FILTER' | translate }}</h3>
    <h3 class="heading" *ngIf="dataType == 'criteria'">{{ 'FRMELEMENTS_MSG_CRITERIA_FILTER' | translate }}</h3>
  </div>

  <ion-list >
    <ion-item *ngFor="let d of data" (click)="onQuestionClick(d?._id)">
      <ion-label class="wrap">{{ d?.name }}</ion-label>
      <ion-checkbox [checked]="filteredData?.includes(d?._id)"></ion-checkbox>
    </ion-item>
  </ion-list>
</ion-content>

<ion-footer no-shadow>
  <ion-toolbar class="_toolbar-background-md" position="bottom">
    <ion-row>
      <ion-col>
        <ion-button ion-button full (click)="close()" class="btnText w-100 custom-btn-txt-transform-none">
          {{ 'CANCEL' | translate }}
        </ion-button>
      </ion-col>
      <ion-col>
        <ion-button ion-button full (click)="applyFilter()" class="btnText w-100 custom-btn-txt-transform-none">
          {{ 'FRMELEMENTS_BTN_APPLY_FILTER' | translate }}
        </ion-button>
      </ion-col>
    </ion-row>
  </ion-toolbar>
</ion-footer>

./report.modal.filter.scss

.wrap {
  white-space: normal !important;
}
.container {
  margin-top: env(safe-area-inset-top);
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""