File
Implements
Constructor
constructor(alertCtrl: AlertController, modal: ModalController, translate: TranslateService, http: HttpClient, loaderService: LoaderService, kendraApiService: KendraApiService, utils: UtilsService, platform: Platform)
|
|
Parameters :
Name |
Type |
Optional |
alertCtrl |
AlertController
|
No
|
modal |
ModalController
|
No
|
translate |
TranslateService
|
No
|
http |
HttpClient
|
No
|
loaderService |
LoaderService
|
No
|
kendraApiService |
KendraApiService
|
No
|
utils |
UtilsService
|
No
|
platform |
Platform
|
No
|
|
Methods
Async
createProgram
|
createProgram()
|
|
|
Async
getPrograms
|
getPrograms()
|
|
|
selectProgram
|
selectProgram(data)
|
|
|
button
|
Type : string
|
Default value : "FRMELEMNTS_BTN_ADD_PROGRAM"
|
|
Public
platform
|
Type : Platform
|
|
title
|
Type : string
|
Default value : "FRMELEMNTS_LBL_MY_PROGRAMS"
|
|
import { Component, OnInit } from '@angular/core';
import { AlertController, ModalController, Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http';
import { LoaderService, UtilsService } from '../../core';
import { KendraApiService } from '../../core/services/kendra-api.service';
import { urlConstants } from '../../core/constants/urlConstants';
@Component({
selector: 'app-add-programs',
templateUrl: './add-programs.component.html',
styleUrls: ['./add-programs.component.scss'],
})
export class AddProgramsComponent implements OnInit {
dataList;
selectedData;
button = "FRMELEMNTS_BTN_ADD_PROGRAM";
title = "FRMELEMNTS_LBL_MY_PROGRAMS";
type;
constructor(
private alertCtrl: AlertController,
private modal: ModalController,
private translate: TranslateService,
private http: HttpClient,
private loaderService: LoaderService,
private kendraApiService: KendraApiService,
private utils: UtilsService,
public platform: Platform
) { }
ngOnInit() {
this.getPrograms();
}
async getPrograms() {
this.loaderService.startLoader();
const config = {
url: urlConstants.API_URLS.PROGRAM_LISTING+'isAPrivateProgram=true',
}
this.kendraApiService.get(config).subscribe(data => {
this.loaderService.stopLoader();
if (data.result && data.result.length) {
this.dataList = data.result;
}
}, error => {
this.loaderService.stopLoader();
})
}
async createProgram() {
let text;
this.translate.get(['FRMELEMNTS_LBL_CREATE_PROGRAM', 'FRMELEMNTS_MSG_CREATE_PROGRAM_MESSAGE', 'CANCEL', 'FRMELEMNTS_BTN_SAVE', 'FRMELEMNTS_LBL_CREATE_PROGRAM_INPUT_PLACEHOLDER', 'FRMELEMNTS_LBL_CREATE_PROGRAM_INPUT_NAME']).subscribe(data => {
text = data;
})
const alert = await this.alertCtrl.create({
cssClass:'central-alert',
header: text['FRMELEMNTS_LBL_CREATE_PROGRAM'],
message: text['FRMELEMNTS_MSG_CREATE_PROGRAM_MESSAGE'],
inputs: [
{
name: 'name',
type: 'text',
placeholder: text['FRMELEMNTS_LBL_CREATE_PROGRAM_INPUT_PLACEHOLDER']
}
],
buttons: [
{
text: text['CANCEL'],
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
}
}, {
text: text['FRMELEMNTS_BTN_SAVE'],
handler: (data) => {
data.name = data.name.trim();
if (data.name || data.name != "") {
data.created = true;
data.isAPrivateProgram = true;
this.selectedData = data;
this.close(this.selectedData);
}
}
}
]
});
await alert.present();
}
selectProgram(data) {
this.selectedData = data;
}
close(data?) {
this.modal.dismiss(data);
}
addProgram() {
if (this.selectedData) {
this.close(this.selectedData);
}
}
}
<ion-toolbar [ngClass]="{'container': platform.is('ios')}">
<ion-title>
{{title | translate}}
</ion-title>
<ion-buttons (click)="close()" slot="start" class="padding">
<ion-icon role="button" name="arrow-back" aria-label="back" slot="icon-only" style="padding-left: 10px;"></ion-icon>
</ion-buttons>
</ion-toolbar>
<ion-content class="ion-padding">
<ion-button color="primary" expand="block" (click)="createProgram()" *ngIf="type== 'programs'" class="custom-btn-txt-transform-none">
{{'FRMELEMNTS_LBL_CREATE_NEW_PROGRAM' | translate}}
</ion-button>
<ion-list>
<ion-radio-group>
<ion-item *ngFor="let data of dataList">
<ion-label class="text-wrap">{{data.name}}</ion-label>
<ion-radio slot="start" value="{{data._id}}" (click)="selectProgram(data)"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</ion-content>
<ion-footer *ngIf="dataList">
<ion-button expand="block" (click)="addProgram()" class="custom-btn-txt-transform-none">
{{button | translate}}
</ion-button>
</ion-footer>
.container {
margin-top: env(safe-area-inset-top);
}
.text-wrap{
white-space: normal !important;
}
Legend
Html element with directive