MOBILE-3742 links: Support choose site when clicking links
parent
82c00bae84
commit
0d5e543713
|
@ -4,6 +4,11 @@
|
||||||
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
|
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
|
||||||
</ion-buttons>
|
</ion-buttons>
|
||||||
<ion-title>{{ 'core.contentlinks.chooseaccount' | translate }}</ion-title>
|
<ion-title>{{ 'core.contentlinks.chooseaccount' | translate }}</ion-title>
|
||||||
|
<ion-buttons slot="end">
|
||||||
|
<ion-button (click)="closeModal()" [attr.aria-label]="'core.close' | translate">
|
||||||
|
<ion-icon slot="icon-only" name="fas-times" aria-hidden="true"></ion-icon>
|
||||||
|
</ion-button>
|
||||||
|
</ion-buttons>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
@ -27,11 +32,6 @@
|
||||||
<p>{{site.siteUrl}}</p>
|
<p>{{site.siteUrl}}</p>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item>
|
|
||||||
<ion-label>
|
|
||||||
<ion-button expand="block" (click)="cancel()">{{ 'core.login.cancel' | translate }}</ion-button>
|
|
||||||
</ion-label>
|
|
||||||
</ion-item>
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</core-loading>
|
</core-loading>
|
||||||
</ion-content>
|
</ion-content>
|
|
@ -12,10 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { CoreSiteBasicInfo, CoreSites } from '@services/sites';
|
import { CoreSiteBasicInfo, CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { Translate } from '@singletons';
|
import { ModalController, Translate } from '@singletons';
|
||||||
import { CoreContentLinksAction } from '../../services/contentlinks-delegate';
|
import { CoreContentLinksAction } from '../../services/contentlinks-delegate';
|
||||||
import { CoreContentLinksHelper } from '../../services/contentlinks-helper';
|
import { CoreContentLinksHelper } from '../../services/contentlinks-helper';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
|
@ -27,12 +27,13 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
* @todo Include routing and testing.
|
* @todo Include routing and testing.
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-core-content-links-choose-site',
|
selector: 'core-content-links-choose-site-modal',
|
||||||
templateUrl: 'choose-site.html',
|
templateUrl: 'choose-site-modal.html',
|
||||||
})
|
})
|
||||||
export class CoreContentLinksChooseSitePage implements OnInit {
|
export class CoreContentLinksChooseSiteModalComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() url!: string;
|
||||||
|
|
||||||
url!: string;
|
|
||||||
sites: CoreSiteBasicInfo[] = [];
|
sites: CoreSiteBasicInfo[] = [];
|
||||||
loaded = false;
|
loaded = false;
|
||||||
protected action?: CoreContentLinksAction;
|
protected action?: CoreContentLinksAction;
|
||||||
|
@ -42,12 +43,10 @@ export class CoreContentLinksChooseSitePage implements OnInit {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
const url = CoreNavigator.getRouteParam<string>('url');
|
if (!this.url) {
|
||||||
if (!url) {
|
return this.closeModal();
|
||||||
return this.leaveView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.url = url;
|
|
||||||
let siteIds: string[] | undefined = [];
|
let siteIds: string[] | undefined = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -75,25 +74,20 @@ export class CoreContentLinksChooseSitePage implements OnInit {
|
||||||
this.sites = await CoreSites.getSites(siteIds);
|
this.sites = await CoreSites.getSites(siteIds);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.contentlinks.errornosites', true);
|
CoreDomUtils.showErrorModalDefault(error, 'core.contentlinks.errornosites', true);
|
||||||
this.leaveView();
|
this.closeModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel.
|
|
||||||
*/
|
|
||||||
cancel(): void {
|
|
||||||
this.leaveView();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the action on a certain site.
|
* Perform the action on a certain site.
|
||||||
*
|
*
|
||||||
* @param siteId Site ID.
|
* @param siteId Site ID.
|
||||||
*/
|
*/
|
||||||
siteClicked(siteId: string): void {
|
async siteClicked(siteId: string): Promise<void> {
|
||||||
|
await ModalController.dismiss();
|
||||||
|
|
||||||
if (this.isRootURL) {
|
if (this.isRootURL) {
|
||||||
CoreNavigator.navigateToSiteHome({ siteId });
|
CoreNavigator.navigateToSiteHome({ siteId });
|
||||||
} else if (this.action) {
|
} else if (this.action) {
|
||||||
|
@ -102,14 +96,10 @@ export class CoreContentLinksChooseSitePage implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel and leave the view.
|
* Close the modal.
|
||||||
*/
|
*/
|
||||||
protected async leaveView(): Promise<void> {
|
closeModal(): void {
|
||||||
try {
|
ModalController.dismiss();
|
||||||
await CoreSites.logout();
|
|
||||||
} finally {
|
|
||||||
await CoreNavigator.navigate('/login/sites', { reset: true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,26 +12,19 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
|
||||||
|
|
||||||
import { CoreSharedModule } from '@/core/shared.module';
|
import { CoreSharedModule } from '@/core/shared.module';
|
||||||
import { CoreContentLinksChooseSitePage } from './choose-site';
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CoreContentLinksChooseSiteModalComponent } from './choose-site-modal/choose-site-modal';
|
||||||
const routes: Routes = [
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
component: CoreContentLinksChooseSitePage,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
CoreContentLinksChooseSitePage,
|
CoreContentLinksChooseSiteModalComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild(routes),
|
|
||||||
CoreSharedModule,
|
CoreSharedModule,
|
||||||
],
|
],
|
||||||
|
exports: [
|
||||||
|
CoreContentLinksChooseSiteModalComponent,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class CoreContentLinksChooseSitePageModule {}
|
export class CoreContentLinksComponentsModule {}
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { NgModule, Type } from '@angular/core';
|
import { NgModule, Type } from '@angular/core';
|
||||||
|
import { CoreContentLinksComponentsModule } from './components/components.module';
|
||||||
import { CoreContentLinksDelegateService } from './services/contentlinks-delegate';
|
import { CoreContentLinksDelegateService } from './services/contentlinks-delegate';
|
||||||
import { CoreContentLinksHelperProvider } from './services/contentlinks-helper';
|
import { CoreContentLinksHelperProvider } from './services/contentlinks-helper';
|
||||||
|
|
||||||
|
@ -22,5 +22,9 @@ export const CORE_CONTENTLINKS_SERVICES: Type<unknown>[] = [
|
||||||
CoreContentLinksHelperProvider,
|
CoreContentLinksHelperProvider,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({})
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CoreContentLinksComponentsModule,
|
||||||
|
],
|
||||||
|
})
|
||||||
export class CoreContentLinksModule {}
|
export class CoreContentLinksModule {}
|
||||||
|
|
|
@ -17,9 +17,10 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreContentLinksDelegate, CoreContentLinksAction } from './contentlinks-delegate';
|
import { CoreContentLinksDelegate, CoreContentLinksAction } from './contentlinks-delegate';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, ModalController, Translate } from '@singletons';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { Params } from '@angular/router';
|
import { Params } from '@angular/router';
|
||||||
|
import { CoreContentLinksChooseSiteModalComponent } from '../components/choose-site-modal/choose-site-modal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features regarding content links.
|
* Service that provides some features regarding content links.
|
||||||
|
@ -111,7 +112,15 @@ export class CoreContentLinksHelperProvider {
|
||||||
* @todo set correct root.
|
* @todo set correct root.
|
||||||
*/
|
*/
|
||||||
async goToChooseSite(url: string): Promise<void> {
|
async goToChooseSite(url: string): Promise<void> {
|
||||||
await CoreNavigator.navigate('CoreContentLinksChooseSitePage @todo', { params: { url }, reset: true });
|
const modal = await ModalController.create({
|
||||||
|
component: CoreContentLinksChooseSiteModalComponent,
|
||||||
|
componentProps: {
|
||||||
|
url: url,
|
||||||
|
},
|
||||||
|
cssClass: 'core-modal-fullscreen',
|
||||||
|
});
|
||||||
|
|
||||||
|
await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue