MOBILE-3660 core: Create and use popover controller singleton
parent
66f64c02dc
commit
67e3021e54
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { PopoverController, IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreLocalNotifications } from '@services/local-notifications';
|
import { CoreLocalNotifications } from '@services/local-notifications';
|
||||||
|
@ -35,7 +35,7 @@ import { CoreCategoryData, CoreCourses, CoreEnrolledCourseData } from '@features
|
||||||
import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
|
import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
|
||||||
import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter';
|
import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Network, NgZone } from '@singletons';
|
import { Network, NgZone, PopoverController } from '@singletons';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
@ -100,9 +100,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
||||||
category: true,
|
category: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor() {
|
||||||
private popoverCtrl: PopoverController,
|
|
||||||
) {
|
|
||||||
this.currentSiteId = CoreSites.instance.getCurrentSiteId();
|
this.currentSiteId = CoreSites.instance.getCurrentSiteId();
|
||||||
|
|
||||||
if (CoreLocalNotifications.instance.isAvailable()) {
|
if (CoreLocalNotifications.instance.isAvailable()) {
|
||||||
|
@ -537,7 +535,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
||||||
* @param event Event.
|
* @param event Event.
|
||||||
*/
|
*/
|
||||||
async openFilter(event: MouseEvent): Promise<void> {
|
async openFilter(event: MouseEvent): Promise<void> {
|
||||||
const popover = await this.popoverCtrl.create({
|
const popover = await PopoverController.instance.create({
|
||||||
component: AddonCalendarFilterPopoverComponent,
|
component: AddonCalendarFilterPopoverComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
courses: this.courses,
|
courses: this.courses,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||||
import { PopoverController, IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
@ -23,7 +23,7 @@ import { AddonCalendar, AddonCalendarProvider, AddonCalendarUpdatedEventEvent }
|
||||||
import { AddonCalendarOffline } from '../../services/calendar-offline';
|
import { AddonCalendarOffline } from '../../services/calendar-offline';
|
||||||
import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider } from '../../services/calendar-sync';
|
import { AddonCalendarSync, AddonCalendarSyncEvents, AddonCalendarSyncProvider } from '../../services/calendar-sync';
|
||||||
import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper';
|
import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper';
|
||||||
import { Network, NgZone } from '@singletons';
|
import { Network, NgZone, PopoverController } from '@singletons';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { CoreEnrolledCourseData } from '@features/courses/services/courses';
|
import { CoreEnrolledCourseData } from '@features/courses/services/courses';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params } from '@angular/router';
|
||||||
|
@ -83,7 +83,6 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected popoverCtrl: PopoverController,
|
|
||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
this.currentSiteId = CoreSites.instance.getCurrentSiteId();
|
this.currentSiteId = CoreSites.instance.getCurrentSiteId();
|
||||||
|
@ -341,7 +340,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
||||||
* @param event Event.
|
* @param event Event.
|
||||||
*/
|
*/
|
||||||
async openFilter(event: MouseEvent): Promise<void> {
|
async openFilter(event: MouseEvent): Promise<void> {
|
||||||
const popover = await this.popoverCtrl.create({
|
const popover = await PopoverController.instance.create({
|
||||||
component: AddonCalendarFilterPopoverComponent,
|
component: AddonCalendarFilterPopoverComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
courses: this.courses,
|
courses: this.courses,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, ViewChild, OnDestroy, OnInit } from '@angular/core';
|
import { Component, ViewChild, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { PopoverController, IonContent, IonRefresher } from '@ionic/angular';
|
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||||
import {
|
import {
|
||||||
AddonCalendarProvider,
|
AddonCalendarProvider,
|
||||||
AddonCalendar,
|
AddonCalendar,
|
||||||
|
@ -36,7 +36,7 @@ import { CoreConstants } from '@/core/constants';
|
||||||
import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter';
|
import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { Network, NgZone } from '@singletons';
|
import { Network, NgZone, PopoverController } from '@singletons';
|
||||||
import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
|
import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
@ -101,9 +101,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
|
||||||
category: true,
|
category: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor() {
|
||||||
private popoverCtrl: PopoverController,
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.siteHomeId = CoreSites.instance.getCurrentSiteHomeId();
|
this.siteHomeId = CoreSites.instance.getCurrentSiteHomeId();
|
||||||
this.notificationsEnabled = CoreLocalNotifications.instance.isAvailable();
|
this.notificationsEnabled = CoreLocalNotifications.instance.isAvailable();
|
||||||
|
@ -624,7 +622,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
|
||||||
* @param event Event.
|
* @param event Event.
|
||||||
*/
|
*/
|
||||||
async openFilter(event: MouseEvent): Promise<void> {
|
async openFilter(event: MouseEvent): Promise<void> {
|
||||||
const popover = await this.popoverCtrl.create({
|
const popover = await PopoverController.instance.create({
|
||||||
component: AddonCalendarFilterPopoverComponent,
|
component: AddonCalendarFilterPopoverComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
courses: this.courses,
|
courses: this.courses,
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { NavParams, PopoverController } from '@ionic/angular';
|
import { NavParams } from '@ionic/angular';
|
||||||
|
import { PopoverController } from '@singletons';
|
||||||
import { CoreContextMenuItemComponent } from './context-menu-item';
|
import { CoreContextMenuItemComponent } from './context-menu-item';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +33,6 @@ export class CoreContextMenuPopoverComponent {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
navParams: NavParams,
|
navParams: NavParams,
|
||||||
protected popoverCtrl: PopoverController,
|
|
||||||
) {
|
) {
|
||||||
this.title = navParams.get('title');
|
this.title = navParams.get('title');
|
||||||
this.items = navParams.get('items') || [];
|
this.items = navParams.get('items') || [];
|
||||||
|
@ -43,7 +43,7 @@ export class CoreContextMenuPopoverComponent {
|
||||||
* Close the popover.
|
* Close the popover.
|
||||||
*/
|
*/
|
||||||
closeMenu(item?: CoreContextMenuItemComponent): void {
|
closeMenu(item?: CoreContextMenuItemComponent): void {
|
||||||
this.popoverCtrl.dismiss(item);
|
PopoverController.instance.dismiss(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,10 +15,9 @@
|
||||||
import { Component, Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
|
import { Component, Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { auditTime } from 'rxjs/operators';
|
import { auditTime } from 'rxjs/operators';
|
||||||
import { PopoverController } from '@ionic/angular';
|
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { Translate } from '@singletons';
|
import { PopoverController, Translate } from '@singletons';
|
||||||
import { CoreContextMenuItemComponent } from './context-menu-item';
|
import { CoreContextMenuItemComponent } from './context-menu-item';
|
||||||
import { CoreContextMenuPopoverComponent } from './context-menu-popover';
|
import { CoreContextMenuPopoverComponent } from './context-menu-popover';
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ export class CoreContextMenuComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected popoverCtrl: PopoverController,
|
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
) {
|
) {
|
||||||
// Create the stream and subscribe to it. We ignore successive changes during 250ms.
|
// Create the stream and subscribe to it. We ignore successive changes during 250ms.
|
||||||
|
@ -179,7 +177,7 @@ export class CoreContextMenuComponent implements OnInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
async showContextMenu(event: MouseEvent): Promise<void> {
|
async showContextMenu(event: MouseEvent): Promise<void> {
|
||||||
if (!this.expanded) {
|
if (!this.expanded) {
|
||||||
const popover = await this.popoverCtrl.create(
|
const popover = await PopoverController.instance.create(
|
||||||
{
|
{
|
||||||
event,
|
event,
|
||||||
component: CoreContextMenuPopoverComponent,
|
component: CoreContextMenuPopoverComponent,
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { PopoverController } from '@ionic/angular';
|
|
||||||
import { CoreCourses } from '../../services/courses';
|
import { CoreCourses } from '../../services/courses';
|
||||||
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '../../services/courses-helper';
|
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '../../services/courses-helper';
|
||||||
import { CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
import { CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
||||||
|
import { PopoverController } from '@singletons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component is meant to display a popover with the course options.
|
* This component is meant to display a popover with the course options.
|
||||||
|
@ -32,10 +32,6 @@ export class CoreCoursesCourseOptionsMenuComponent implements OnInit {
|
||||||
|
|
||||||
downloadCourseEnabled = false;
|
downloadCourseEnabled = false;
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected popoverController: PopoverController,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
|
@ -49,7 +45,7 @@ export class CoreCoursesCourseOptionsMenuComponent implements OnInit {
|
||||||
* @param action Action name to take.
|
* @param action Action name to take.
|
||||||
*/
|
*/
|
||||||
action(action: string): void {
|
action(action: string): void {
|
||||||
this.popoverController.dismiss(action);
|
PopoverController.instance.dismiss(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { PopoverController } from '@ionic/angular';
|
|
||||||
import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
@ -21,7 +20,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreCourses } from '@features/courses/services/courses';
|
import { CoreCourses } from '@features/courses/services/courses';
|
||||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
||||||
import { Translate } from '@singletons';
|
import { PopoverController, Translate } from '@singletons';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '../../services/courses-helper';
|
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '../../services/courses-helper';
|
||||||
import { CoreCoursesCourseOptionsMenuComponent } from '../course-options-menu/course-options-menu';
|
import { CoreCoursesCourseOptionsMenuComponent } from '../course-options-menu/course-options-menu';
|
||||||
|
@ -62,10 +61,6 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
||||||
protected courseStatusObserver?: CoreEventObserver;
|
protected courseStatusObserver?: CoreEventObserver;
|
||||||
protected siteUpdatedObserver?: CoreEventObserver;
|
protected siteUpdatedObserver?: CoreEventObserver;
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected popoverCtrl: PopoverController,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
|
@ -204,7 +199,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const popover = await this.popoverCtrl.create({
|
const popover = await PopoverController.instance.create({
|
||||||
component: CoreCoursesCourseOptionsMenuComponent,
|
component: CoreCoursesCourseOptionsMenuComponent,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
course: this.course,
|
course: this.course,
|
||||||
|
|
|
@ -13,14 +13,12 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
// import { PopoverController } from '@ionic/angular';
|
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreCourses, CoreCourseSearchedData, CoreCourseUserAdminOrNavOptionIndexed, CoreEnrolledCourseData } from './courses';
|
import { CoreCourses, CoreCourseSearchedData, CoreCourseUserAdminOrNavOptionIndexed, CoreEnrolledCourseData } from './courses';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreWSExternalFile } from '@services/ws';
|
import { CoreWSExternalFile } from '@services/ws';
|
||||||
import { AddonCourseCompletion } from '@/addons/coursecompletion/services/coursecompletion';
|
import { AddonCourseCompletion } from '@/addons/coursecompletion/services/coursecompletion';
|
||||||
// import { CoreCoursePickerMenuPopoverComponent } from '@components/course-picker-menu/course-picker-menu-popover';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to gather some common courses functions.
|
* Helper to gather some common courses functions.
|
||||||
|
@ -276,19 +274,6 @@ export class CoreCoursesHelperProvider {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a context menu to select a course, and return the courseId and categoryId of the selected course (-1 for all courses).
|
|
||||||
* Returns an empty object if popover closed without picking a course.
|
|
||||||
*
|
|
||||||
* @param event Click event.
|
|
||||||
* @param courses List of courses, from CoreCoursesHelperProvider.getCoursesForPopover.
|
|
||||||
* @param courseId The course to select at start.
|
|
||||||
* @return Promise resolved with the course ID and category ID.
|
|
||||||
*/
|
|
||||||
async selectCourse(): Promise<void> {
|
|
||||||
// @todo params and logic
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CoreCoursesHelper extends makeSingleton(CoreCoursesHelperProvider) { }
|
export class CoreCoursesHelper extends makeSingleton(CoreCoursesHelperProvider) { }
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
GestureController as GestureControllerService,
|
GestureController as GestureControllerService,
|
||||||
ActionSheetController as ActionSheetControllerService,
|
ActionSheetController as ActionSheetControllerService,
|
||||||
NavController as NavControllerService,
|
NavController as NavControllerService,
|
||||||
|
PopoverController as PopoverControllerService,
|
||||||
} from '@ionic/angular';
|
} from '@ionic/angular';
|
||||||
|
|
||||||
import { Badge as BadgeService } from '@ionic-native/badge/ngx';
|
import { Badge as BadgeService } from '@ionic-native/badge/ngx';
|
||||||
|
@ -148,6 +149,7 @@ export class ActionSheetController extends makeSingleton(ActionSheetControllerSe
|
||||||
export class AlertController extends makeSingleton(AlertControllerService) {}
|
export class AlertController extends makeSingleton(AlertControllerService) {}
|
||||||
export class LoadingController extends makeSingleton(LoadingControllerService) {}
|
export class LoadingController extends makeSingleton(LoadingControllerService) {}
|
||||||
export class ModalController extends makeSingleton(ModalControllerService) {}
|
export class ModalController extends makeSingleton(ModalControllerService) {}
|
||||||
|
export class PopoverController extends makeSingleton(PopoverControllerService) {}
|
||||||
export class ToastController extends makeSingleton(ToastControllerService) {}
|
export class ToastController extends makeSingleton(ToastControllerService) {}
|
||||||
export class GestureController extends makeSingleton(GestureControllerService) {}
|
export class GestureController extends makeSingleton(GestureControllerService) {}
|
||||||
export class ApplicationInit extends makeSingleton(ApplicationInitStatus) {}
|
export class ApplicationInit extends makeSingleton(ApplicationInitStatus) {}
|
||||||
|
|
Loading…
Reference in New Issue