mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
refactor(angular): loading controller uses correct core instance (#28543)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? As a takeaway from our learning session about a menuController bug in Ionic Angular, the team would like to update our other providers to use the same architecture as the menuController to prevent this kind of issue from happening again in the future. We also noticed that the common provider does not provide much value and it's easier to just have two separate implementations in `src` and `standalone`. (There wasn't much code we could de-duplicate) ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removed the common loading provider in favor of separate ones in src/standalone ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
export { LoadingController } from './providers/loading-controller';
|
|
||||||
export { MenuController } from './providers/menu-controller';
|
export { MenuController } from './providers/menu-controller';
|
||||||
export { DomController } from './providers/dom-controller';
|
export { DomController } from './providers/dom-controller';
|
||||||
export { NavController } from './providers/nav-controller';
|
export { NavController } from './providers/nav-controller';
|
||||||
|
@ -20,7 +20,6 @@ export * from './directives/validators';
|
|||||||
|
|
||||||
// PROVIDERS
|
// PROVIDERS
|
||||||
export {
|
export {
|
||||||
LoadingController,
|
|
||||||
DomController,
|
DomController,
|
||||||
NavController,
|
NavController,
|
||||||
Config,
|
Config,
|
||||||
@ -37,6 +36,7 @@ export { AlertController } from './providers/alert-controller';
|
|||||||
export { AnimationController } from './providers/animation-controller';
|
export { AnimationController } from './providers/animation-controller';
|
||||||
export { ActionSheetController } from './providers/action-sheet-controller';
|
export { ActionSheetController } from './providers/action-sheet-controller';
|
||||||
export { GestureController } from './providers/gesture-controller';
|
export { GestureController } from './providers/gesture-controller';
|
||||||
|
export { LoadingController } from './providers/loading-controller';
|
||||||
export { MenuController } from './providers/menu-controller';
|
export { MenuController } from './providers/menu-controller';
|
||||||
export { ModalController } from './providers/modal-controller';
|
export { ModalController } from './providers/modal-controller';
|
||||||
export { PickerController } from './providers/picker-controller';
|
export { PickerController } from './providers/picker-controller';
|
||||||
|
13
packages/angular/src/providers/loading-controller.ts
Normal file
13
packages/angular/src/providers/loading-controller.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { OverlayBaseController } from '@ionic/angular/common';
|
||||||
|
import type { LoadingOptions } from '@ionic/core';
|
||||||
|
import { loadingController } from '@ionic/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
|
||||||
|
constructor() {
|
||||||
|
super(loadingController);
|
||||||
|
}
|
||||||
|
}
|
@ -9,13 +9,13 @@ export { ActionSheetController } from './providers/action-sheet-controller';
|
|||||||
export { AlertController } from './providers/alert-controller';
|
export { AlertController } from './providers/alert-controller';
|
||||||
export { AnimationController } from './providers/animation-controller';
|
export { AnimationController } from './providers/animation-controller';
|
||||||
export { GestureController } from './providers/gesture-controller';
|
export { GestureController } from './providers/gesture-controller';
|
||||||
|
export { LoadingController } from './providers/loading-controller';
|
||||||
export { MenuController } from './providers/menu-controller';
|
export { MenuController } from './providers/menu-controller';
|
||||||
export { ModalController } from './providers/modal-controller';
|
export { ModalController } from './providers/modal-controller';
|
||||||
export { PickerController } from './providers/picker-controller';
|
export { PickerController } from './providers/picker-controller';
|
||||||
export { PopoverController } from './providers/popover-controller';
|
export { PopoverController } from './providers/popover-controller';
|
||||||
export { ToastController } from './providers/toast-controller';
|
export { ToastController } from './providers/toast-controller';
|
||||||
export {
|
export {
|
||||||
LoadingController,
|
|
||||||
DomController,
|
DomController,
|
||||||
NavController,
|
NavController,
|
||||||
Config,
|
Config,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { OverlayBaseController } from '@ionic/angular/common';
|
||||||
import type { LoadingOptions } from '@ionic/core/components';
|
import type { LoadingOptions } from '@ionic/core/components';
|
||||||
import { loadingController } from '@ionic/core/components';
|
import { loadingController } from '@ionic/core/components';
|
||||||
|
import { defineCustomElement } from '@ionic/core/components/ion-loading.js';
|
||||||
import { OverlayBaseController } from '../utils/overlay';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -10,5 +10,8 @@ import { OverlayBaseController } from '../utils/overlay';
|
|||||||
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
|
export class LoadingController extends OverlayBaseController<LoadingOptions, HTMLIonLoadingElement> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(loadingController);
|
super(loadingController);
|
||||||
|
|
||||||
|
// TODO: FW-5415 may remove the need for this
|
||||||
|
defineCustomElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,6 +46,12 @@ describe('Providers', () => {
|
|||||||
cy.get('ion-alert').should('be.visible');
|
cy.get('ion-alert').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should open a loading-indicator', () => {
|
||||||
|
cy.get('button#open-loading').click();
|
||||||
|
|
||||||
|
cy.get('ion-loading').should('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
it('should open a picker', () => {
|
it('should open a picker', () => {
|
||||||
cy.get('button#open-picker').click();
|
cy.get('button#open-picker').click();
|
||||||
|
|
||||||
|
@ -9,6 +9,12 @@ describe('Overlay Controllers', () => {
|
|||||||
cy.get('ion-alert').should('be.visible');
|
cy.get('ion-alert').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should present a loading indicator', () => {
|
||||||
|
cy.get('button#open-loading').click();
|
||||||
|
|
||||||
|
cy.get('ion-loading').should('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
it('should present a modal', () => {
|
it('should present a modal', () => {
|
||||||
cy.get('button#open-modal').click();
|
cy.get('button#open-modal').click();
|
||||||
|
|
||||||
|
@ -47,5 +47,6 @@
|
|||||||
<button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button>
|
<button id="set-menu-count" (click)="setMenuCount()">Set Menu Count</button>
|
||||||
<button id="open-alert" (click)="openAlert()">Open Alert</button>
|
<button id="open-alert" (click)="openAlert()">Open Alert</button>
|
||||||
<button id="open-action-sheet" (click)="openActionSheet()">Open Action Sheet</button>
|
<button id="open-action-sheet" (click)="openActionSheet()">Open Action Sheet</button>
|
||||||
|
<button id="open-loading" (click)="openLoading()">Open Loading Indicator</button>
|
||||||
<button id="open-picker" (click)="openPicker()">Open Picker</button>
|
<button id="open-picker" (click)="openPicker()">Open Picker</button>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
@ -34,7 +34,7 @@ export class ProvidersComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private actionSheetCtrl: ActionSheetController,
|
private actionSheetCtrl: ActionSheetController,
|
||||||
private alertCtrl: AlertController,
|
private alertCtrl: AlertController,
|
||||||
loadingCtrl: LoadingController,
|
private loadingCtrl: LoadingController,
|
||||||
private menuCtrl: MenuController,
|
private menuCtrl: MenuController,
|
||||||
private pickerCtrl: PickerController,
|
private pickerCtrl: PickerController,
|
||||||
modalCtrl: ModalController,
|
modalCtrl: ModalController,
|
||||||
@ -129,6 +129,15 @@ export class ProvidersComponent {
|
|||||||
await alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async openLoading() {
|
||||||
|
const loading = await this.loadingCtrl.create({
|
||||||
|
message: 'Loading...',
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
|
||||||
|
await loading.present();
|
||||||
|
}
|
||||||
|
|
||||||
async openPicker() {
|
async openPicker() {
|
||||||
const picker = await this.pickerCtrl.create({
|
const picker = await this.pickerCtrl.create({
|
||||||
columns: [],
|
columns: [],
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<button id="open-alert" (click)="openAlert()">Open Alert</button>
|
<button id="open-alert" (click)="openAlert()">Open Alert</button>
|
||||||
|
<button id="open-loading" (click)="openLoading()">Open Loading Indicator</button>
|
||||||
<button id="open-modal" (click)="openModal()">Open Modal</button>
|
<button id="open-modal" (click)="openModal()">Open Modal</button>
|
||||||
<button id="open-picker" (click)="openPicker()">Open Picker</button>
|
<button id="open-picker" (click)="openPicker()">Open Picker</button>
|
||||||
<button id="open-popover" (click)="openPopover($event)">Open Popover</button>
|
<button id="open-popover" (click)="openPopover($event)">Open Popover</button>
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { AlertController, ModalController, PickerController, PopoverController } from '@ionic/angular/standalone';
|
import {
|
||||||
|
AlertController,
|
||||||
|
LoadingController,
|
||||||
|
ModalController,
|
||||||
|
PickerController,
|
||||||
|
PopoverController,
|
||||||
|
} from '@ionic/angular/standalone';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-overlay-controllers',
|
selector: 'app-overlay-controllers',
|
||||||
@ -9,6 +15,7 @@ import { AlertController, ModalController, PickerController, PopoverController }
|
|||||||
export class OverlayControllersComponent {
|
export class OverlayControllersComponent {
|
||||||
constructor(
|
constructor(
|
||||||
private alertCtrl: AlertController,
|
private alertCtrl: AlertController,
|
||||||
|
private loadingCtrl: LoadingController,
|
||||||
private modalCtrl: ModalController,
|
private modalCtrl: ModalController,
|
||||||
private pickerCtrl: PickerController,
|
private pickerCtrl: PickerController,
|
||||||
private popoverCtrl: PopoverController
|
private popoverCtrl: PopoverController
|
||||||
@ -28,6 +35,15 @@ export class OverlayControllersComponent {
|
|||||||
await alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async openLoading() {
|
||||||
|
const loading = await this.loadingCtrl.create({
|
||||||
|
message: 'Loading...',
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
|
||||||
|
await loading.present();
|
||||||
|
}
|
||||||
|
|
||||||
async openModal() {
|
async openModal() {
|
||||||
const modal = await this.modalCtrl.create({
|
const modal = await this.modalCtrl.create({
|
||||||
component: DialogComponent,
|
component: DialogComponent,
|
||||||
|
Reference in New Issue
Block a user