MOBILE-2567 assign: Fix leaving teacher view
parent
e327beaa3d
commit
9d09a31af5
|
@ -92,23 +92,6 @@ export class AddonModAssignSubmissionListPage implements OnInit, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can leave the page or not.
|
||||
*
|
||||
* @return {boolean|Promise<void>} Resolved if we can leave it, rejected if not.
|
||||
*/
|
||||
ionViewCanLeave(): boolean | Promise<void> {
|
||||
// If split view is enabled, check if we can leave the details page.
|
||||
if (this.splitviewCtrl.isOn()) {
|
||||
const detailsPage = this.splitviewCtrl.getDetailsNav().getActive().instance;
|
||||
if (detailsPage && detailsPage.ionViewCanLeave) {
|
||||
return detailsPage.ionViewCanLeave();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch assignment data.
|
||||
*
|
||||
|
|
|
@ -109,6 +109,10 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy {
|
|||
handleCanLeave(): void {
|
||||
// Listen for the didEnter event on the details nav to detect everytime a page is loaded.
|
||||
this.detailsDidEnterSubscription = this.detailNav.viewDidEnter.subscribe((detailsViewController: ViewController) => {
|
||||
if (!this.isOn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const masterViewController = this.masterNav.getActive();
|
||||
|
||||
if (this.masterCanLeaveOverridden) {
|
||||
|
@ -133,7 +137,7 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy {
|
|||
return Promise.resolve().then(() => {
|
||||
if (this.originalMasterCanLeave) {
|
||||
// First call the master canLeave.
|
||||
const result = this.originalMasterCanLeave();
|
||||
const result = this.originalMasterCanLeave.apply(masterViewController.instance);
|
||||
if (typeof result == 'boolean' && !result) {
|
||||
// User cannot leave, return a rejected promise so the details canLeave isn't executed.
|
||||
return Promise.reject(null);
|
||||
|
|
Loading…
Reference in New Issue