File

src/app/manage-learn/reports/observation-solution-listing/observation-solution-listing.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(apiService: AssessmentApiService, utils: UtilsService, loader: LoaderService, router: Router)
Parameters :
Name Type Optional
apiService AssessmentApiService No
utils UtilsService No
loader LoaderService No
router Router No

Methods

applyFilter
applyFilter(filter)
Parameters :
Name Optional
filter No
Returns : void
Async getSolutions
getSolutions()
Returns : any
goToEntityList
goToEntityList(solution)
Parameters :
Name Optional
solution No
Returns : void
goToReports
goToReports(solution)
Parameters :
Name Optional
solution No
Returns : void
loadMore
loadMore()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

entityType
Type : string
Default value : ''
filters
Type : Array<string>
Default value : []
layout
Default value : LibraryFiltersLayout.ROUND
pageNo
Type : number
Default value : 1
pageSize
Type : number
Default value : 10
selectedFilterIndex
Type : number
Default value : 0
showLoadMore
Type : boolean
Default value : true
solutionList
Type : []
Default value : []
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { RouterLinks } from '@app/app/app.constant';
import { LibraryFiltersLayout } from '@project-sunbird/common-consumption';
import { LoaderService, UtilsService } from '../../core';
import { urlConstants } from '../../core/constants/urlConstants';
import { AssessmentApiService } from '../../core/services/assessment-api.service';

@Component({
  selector: 'app-observation-solution-listing',
  templateUrl: './observation-solution-listing.component.html',
  styleUrls: ['./observation-solution-listing.component.scss'],
})
export class ObservationSolutionListingComponent implements OnInit {
  filters: Array<string> = [];
  selectedFilterIndex: number = 0;
  layout = LibraryFiltersLayout.ROUND;
  solutionList = [];
  entityType: string = '';
  pageSize: number = 10;
  pageNo: number = 1;
  showLoadMore: boolean = true;

  constructor(
    private apiService: AssessmentApiService,
    private utils: UtilsService,
    private loader: LoaderService,
    private router: Router
  ) {}

  ngOnInit() {
    this.getSolutions();
  }

  async getSolutions() {
    this.loader.startLoader();
    let payload = await this.utils.getProfileInfo();
    const config = {
      url:
        urlConstants.API_URLS.OBSERVATION_REPORT_SOLUTION_LIST +
        `limit=${this.pageSize}&page=${this.pageNo}&entityType=${this.entityType}`,
      payload: payload,
    };
    this.apiService.post(config).subscribe(
      (data) => {
        this.loader.stopLoader();
        this.solutionList = data && data.result ? this.solutionList.concat(data.result.data) : [];
        this.filters = data && data.result && !this.filters.length ? data.result.entityType : this.filters;
        this.showLoadMore = this.solutionList.length < data.result.count ? true : false;
      },
      (error) => {
        this.loader.stopLoader();
      }
    );
  }

  goToEntityList(solution) {
    this.router.navigate([`${RouterLinks.REPORTS}/${RouterLinks.OBSERVATION_SOLUTION_ENTITY_LISTING}`], {
      state: solution,
    });
  }

  goToReports(solution) {
 
    let state = {
      scores: false,
      observation: true,
      entityId: solution.entities[0]._id,
      entityType: solution.entityType,
      observationId: solution.observationId,
    };
    if (solution.isRubricDriven) {
      state.scores = true;
    }
    if (!solution.criteriaLevelReport) {
      state['filter'] = { questionId: [] };
      state['criteriaWise'] = false;
    }
    this.router.navigate([RouterLinks.GENERIC_REPORT], {
      state: state,
    });
  }

  loadMore() {
    this.pageNo++;
    this.getSolutions();
  }

  applyFilter(filter) {
    this.selectedFilterIndex = filter.data.index;
    this.entityType = filter && filter.data ? filter.data.text : '';
    this.solutionList = [];
    this.getSolutions();
  }
}
<ion-content>
  <div slot="fixed" class="fixed-container">
    <app-common-header title="{{ 'FRMELEMNTS_LBL_OBSERVATION_REPORTS' | translate }}"
      subTitle="{{ 'FRMELEMNTS_LBL_OBSERVATION_REPORTS_DESC' | translate }}"></app-common-header>
    <sb-library-filters [list]="filters" [layout]="layout" (selectedFilter)="applyFilter($event);"
      *ngIf="filters?.length">
    </sb-library-filters>
  </div>

  <div class="scrollable-container">
    <div *ngFor="let solution of solutionList; let solutionIndex = index">
      <app-item-list-card [title]="solution?.name" [subTitle]="solution?.programName"
        (cardSelect)="(solution?.entities?.length >1) ? goToEntityList(solution) : goToReports(solution)">
        <ion-icon class="mg-popup-btn-icon" name="arrow-forward" arrow></ion-icon>
      </app-item-list-card>
    </div>
  </div>


  <app-no-data *ngIf="!solutionList?.length"></app-no-data>

</ion-content>

<ion-footer class="ion-no-border ion-padding-horizontal" *ngIf="showLoadMore">
  <ion-toolbar>
    <ion-button expand="block" (click)="loadMore()" class="custom-btn-txt-transform-none">
      {{ 'FRMELEMNTS_BTN_VIEW_MORE' | translate }}
      </ion-button>
  </ion-toolbar>
</ion-footer>

./observation-solution-listing.component.scss

@import "src/assets/styles/variables";
@import "src/assets/styles/_custom-mixins";
@import "src/assets/styles/fonts";
@import "src/assets/styles/_variables.scss";

.fixed-container {
    width: 100%;
    margin-top: 56px;
    position: relative;
    z-index: 2;
  }
  
  .scrollable-container {
    padding-top:210px;
    z-index: 1;
  }
  
  .main-container {
    background: map-get($colors, white);
    position: relative;
  }
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""