File

src/app/manage-learn/programs/program-listing/program-listing.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(router: Router, location: Location, loader: LoaderService, headerService: AppHeaderService, platform: Platform, utils: UtilsService, kendraService: KendraApiService)
Parameters :
Name Type Optional
router Router No
location Location No
loader LoaderService No
headerService AppHeaderService No
platform Platform No
utils UtilsService No
kendraService KendraApiService No

Methods

Async getPrograms
getPrograms()
Returns : any
Private handleBackButton
handleBackButton()
Returns : void
handleNavBackButton
handleNavBackButton()
Returns : void
ionViewWillEnter
ionViewWillEnter()
Returns : void
ionViewWillLeave
ionViewWillLeave()
Returns : void
loadMore
loadMore()
Returns : void
ngOnInit
ngOnInit()
Returns : void
selectedProgram
selectedProgram(id)
Parameters :
Name Optional
id No
Returns : void

Properties

Private backButtonFunc
Type : Subscription
count
Type : number
Default value : 0
description
headerConfig
Type : object
Default value : { showHeader: true, showBurgerMenu: false, actionButtons: [] }
limit
Type : number
Default value : 25
page
Type : number
Default value : 1
programs
Type : []
Default value : []
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
import { RouterLinks } from '@app/app/app.constant';
import { AppHeaderService } from '@app/services';
import { Subscription } from 'rxjs';
import { Platform } from '@ionic/angular';
import { KendraApiService } from '../../core/services/kendra-api.service';
import { urlConstants } from '../../core/constants/urlConstants';
import { UtilsService, LoaderService } from '../../core';

@Component({
    selector: 'app-program-listing',
    templateUrl: './program-listing.component.html',
    styleUrls: ['./program-listing.component.scss'],
})
export class ProgramListingComponent implements OnInit {
    private backButtonFunc: Subscription;
    headerConfig = {
        showHeader: true,
        showBurgerMenu: false,
        actionButtons: []
    };
    programs = [];
    count = 0;
    description;
    page = 1;
    limit = 25;


    constructor(private router: Router, private location: Location,
        private loader: LoaderService,
        private headerService: AppHeaderService, private platform: Platform, private utils: UtilsService, private kendraService: KendraApiService) { }

    ngOnInit() {
        this.getPrograms();
    }

    async getPrograms() {
        this.loader.startLoader();
        let payload = await this.utils.getProfileInfo();
        if (payload) {
            const config = {
                url: urlConstants.API_URLS.PROGRAM_LISTING +false+ '&page=' + this.page + '&limit=' + this.limit + '&search=',
                payload: payload
            }
            this.kendraService.post(config).subscribe(success => {
                this.loader.stopLoader();
                if (success.result.data) {
                    this.programs = this.programs.concat(success.result.data);
                    this.count = success.result.count;
                    this.description = success.result.description;
                }
            }, error => {
                this.loader.stopLoader();
                this.programs = [];
            })
        } else {
            this.loader.stopLoader();
        }
    }

    ionViewWillEnter() {
        this.headerConfig = this.headerService.getDefaultPageConfig();
        this.headerConfig.actionButtons = [];
        this.headerConfig.showHeader = true;
        this.headerConfig.showBurgerMenu = false;
        this.headerService.updatePageConfig(this.headerConfig);
        this.handleBackButton();
    }

    ionViewWillLeave() {
        if (this.backButtonFunc) {
            this.backButtonFunc.unsubscribe();
        }
        this.utils.closeProfileAlert();
    }

    private handleBackButton() {
        this.backButtonFunc = this.platform.backButton.subscribeWithPriority(10, () => {
            this.location.back();
            this.backButtonFunc.unsubscribe();
        });
    }

    selectedProgram(id) {
        this.router.navigate([`/${RouterLinks.PROGRAM}/${RouterLinks.SOLUTIONS}`, id]);
    }

    handleNavBackButton() {
        this.location.back();
    }

    loadMore() {
        this.page = this.page + 1;
        this.getPrograms();
    }

}
  <ion-content>
    <ion-list>
      <ion-item lines="none">
        <div style="margin-top: 15px">
          <ion-label>
            <div class="title">{{'PROGRAMS' | translate }}</div>
            <div>
              <div class="desc">{{'PROGRAMS_DESC' | translate}}</div>
            </div>
          </ion-label>
        </div>
      </ion-item>
    </ion-list>
    <app-item-list-card [title]="data?.name"  [id]="data?._id"
      (cardSelect)="selectedProgram($event)" *ngFor="let data of programs">
   </app-item-list-card>
    <app-no-data *ngIf="!programs?.length"></app-no-data>

  </ion-content>
  <div class="px-5">
    <ion-button expand="block" class="custom-btn-txt-transform-none" (click)="loadMore();" *ngIf="programs?.length && count > programs?.length">
      {{ 'FRMELEMNTS_BTN_VIEW_MORE' | translate }}
    </ion-button>
  </div>

./program-listing.component.scss

.desc {
    color: #555;
    white-space: normal;
    padding: 5px 0px 30px 0px;
    margin-bottom: 10px;
    font-size: 1rem;
}

.title{
    font-size: 1rem;
    font-weight: bold;
    // color: $black;
    color: black;
}

.list-md {
    padding-top: 0px !important; 
    padding-bottom: 0px !important;
}

.button-native {
    background: #DFE7F1 !important;
}

ion-button {
    font-size: 0.875rem;
    height: 2.25rem;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""