Hi here i’m try to call the popover in details component.
using popover i’m displaying the users.but invalid users
i need to show toasts and i should stop dissmiss the popover.
but this validation method is called from service component so i needed to stop the popover dissmiss from service component only . how could i do it. plz help out here.
If you could provide some code examples, that would be helpful in answering your specific question.
This may or may not help, but in Ionic the PopoverController
itself has a getTop()
method which returns a promise that, when it resolves, gives you the current “topmost” popover.
If you want to be sure that the popover you’re talking about is the correct one, you can test it like this:
const popover = await this.popoverCtrl.getTop();
if (popover.id === 'some-id-here') {
popover.dismiss();
}
coaching-details.ts
const selectListDetail: SelectListDetail = {
isMultipleSelectionEnabled: false,
isSearchEnabled: true,
title: this.translate.instant('COACHING_TEAM_MEMBERS'),
dividerTitle: this.translate.instant('ALL_TEAM_MEMBERS_CAP'),
data: options,
coachingpageconfirm:true,
navOptions: { animate: false }
};
this._selectProductModal = this.modalCtrl.create(SelectListComponent, { viewData: selectListDetail }, { enableBackdropDismiss: false });
this._selectProductModal.present({ animate: false });
this._selectProductModal.dismiss();
this._selectProductModal.onDidDismiss((data: { selectedItems: SelectListData[], isDone: boolean }) => {
if (data && data.isDone && Array.isArray(data.selectedItems)) {
if (data.selectedItems[0].id && data.selectedItems[0].id != this.selectedCoaching.indskr_coachingfor_value) {
const coaching: Report = <Report>{ ...this.selectedCoaching };
coaching.indskr_coachingfor_value = data.selectedItems[0].id;
coaching.indskr_name = this.translate.instant("COACHING_FOR") + " " + data.selectedItems[0].title + " " + this.translate.instant("ON") + " " + moment(this.selectedCoaching.createdon).format("MMM DD" + ", " + "YYYY");
coaching.created_for = data.selectedItems[0].title;
for (var createuser of this.coachingReportService.users) {
if (createuser.id == data.selectedItems[0].id) {
coaching.created_for_firstname = createuser.firstName;
}
}
this.coachingReportService.updateCoachingFor(coaching);
}
else {
this.selectedCoaching.created_for = null;
this.selectedCoaching.indskr_coachingfor_value = null;
}}
});
here this.coachingReportService.updateCoachingFor(coaching);
while exexuting this method will dispays the toasts ,alerts . but i should show these in popover only .
service component
public updateCoachingFor(coaching: Report) {
if (this.selectedReport.value.indskr_coachingfor_value &&
this.selectedReport.value.indskr_coachingfor_value !== coaching.indskr_coachingfor_value) {
this.alertService.showAlert({
title: this.translate.instant('COACHING_RESET'),
message: this.translate.instant('COACHING_ALL_CHANGES_LOST_AND_RESET')}
).then (res => {
if(res.role == "ok") {
this.updateCoaching(coaching);
}
});
} else {
this.updateCoaching(coaching);
}
}
private async updateCoaching(coaching: Report) {
if (this.isDuplicateCoaching(coaching)) {
return;
}
if (this.isOffline(coaching)) {
//On change of selected user: clear meetings, ratingssummary, ratingrecommendation
coaching.meetings = [];
coaching.indskr_ratingssummary = "";
coaching.indskr_recommendations = "";
coaching.min_rating = new CoachingRating();
coaching.max_rating = new CoachingRating();
let assementCategory: AssessmentCategory[] = new Array<AssessmentCategory>();
assementCategory = this.getCoachingTemplatesByUser(coaching.indskr_coachingfor_value);
if (assementCategory.length === 0) {
this.retainPreviousCoachingState();
return;
}
coaching.categories = assementCategory;
//add to offline update document hashmap
await this.updateCoachingReportOffline(coaching, true);
// this.navService.popWithPageTracking();
this.coachingstatuscheck=true;
} else {
const loader = this.loadingCtrl.create();
loader.present();
this.coachingReportDataService.updateCoachingFor(coaching.indskr_coachingreportid, coaching)
.then(
async (res: Report) => {
res.min_rating = new CoachingRating();
res.max_rating = new CoachingRating();
let existingCoaching = await this.updateSelectedCoachingInDB(coaching, res);
await this.updateCoachingDetails(existingCoaching, true);
loader.dismiss();
// this.navService.popWithPageTracking();
},
(error) => {
this.checkCoachingError(error, coaching);
loader.dismiss();
});
}
}
What do you mean by this? Toasts are a different type of overlay and are not displayed in a Popover. It’s not clear what you are asking.