mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
refactor: update to ionic v6
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
TemplateRef,
|
||||
} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {IonRefresher, ViewWillEnter} from '@ionic/angular';
|
||||
import {IonRefresher, ViewWillEnter, ModalController} from '@ionic/angular';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {
|
||||
SCLanguageCode,
|
||||
@@ -57,6 +57,10 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
*/
|
||||
item?: SCThings | null = undefined;
|
||||
|
||||
@Input() inputItem?: SCThings;
|
||||
|
||||
@Input() isModal = false;
|
||||
|
||||
/**
|
||||
* The language of the item
|
||||
*/
|
||||
@@ -100,12 +104,14 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param modalController the modal controller
|
||||
* @param translateService he translate provider
|
||||
*/
|
||||
constructor(
|
||||
protected readonly route: ActivatedRoute,
|
||||
private readonly dataProvider: DataProvider,
|
||||
private readonly favoritesService: FavoritesService,
|
||||
readonly modalController: ModalController,
|
||||
translateService: TranslateService,
|
||||
) {
|
||||
this.language = translateService.currentLang as SCLanguageCode;
|
||||
@@ -127,11 +133,13 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
*/
|
||||
async getItem(uid: SCUuid, forceReload: boolean) {
|
||||
try {
|
||||
const item = await (this.externalData
|
||||
? new Promise<SCThings | null | undefined>(resolve =>
|
||||
this.loadItem.emit({uid, forceReload, resolve}),
|
||||
)
|
||||
: this.dataProvider.get(uid, DataScope.Remote));
|
||||
const item =
|
||||
this.inputItem ??
|
||||
(await (this.externalData
|
||||
? new Promise<SCThings | null | undefined>(resolve =>
|
||||
this.loadItem.emit({uid, forceReload, resolve}),
|
||||
)
|
||||
: this.dataProvider.get(uid, DataScope.Remote)));
|
||||
|
||||
this.item = !item
|
||||
? // eslint-disable-next-line unicorn/no-null
|
||||
@@ -170,7 +178,9 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
* @param refresher Refresher component that triggers the update
|
||||
*/
|
||||
async refresh(refresher: IonRefresher) {
|
||||
await this.getItem(this.route.snapshot.paramMap.get('uid') ?? '', true);
|
||||
if (!this.inputItem) {
|
||||
await this.getItem(this.route.snapshot.paramMap.get('uid') ?? '', true);
|
||||
}
|
||||
await refresher.complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
<ion-header *ngIf="defaultHeader">
|
||||
<ion-toolbar color="primary">
|
||||
<ion-buttons slot="start">
|
||||
<ion-buttons slot="start" *ngIf="!isModal">
|
||||
<ion-back-button></ion-back-button>
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title>{{ 'data.detail.TITLE' | translate }}</ion-title>
|
||||
<ion-buttons slot="primary">
|
||||
<ion-buttons [slot]="isModal ? 'start' : 'primary'">
|
||||
<stapps-favorite-button
|
||||
*ngIf="item"
|
||||
[item]="$any(item)"
|
||||
></stapps-favorite-button>
|
||||
</ion-buttons>
|
||||
<ion-buttons slot="end" *ngIf="isModal">
|
||||
<ion-button fill="clear" (click)="modalController.dismiss()">
|
||||
<ion-label>{{ 'modal.DISMISS' | translate }}</ion-label>
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ng-content select="[header]"></ng-content>
|
||||
|
||||
@@ -50,6 +50,11 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
@Input() showDefaultData = false;
|
||||
|
||||
/**
|
||||
* Show the navigation drawer
|
||||
*/
|
||||
@Input() showDrawer = true;
|
||||
|
||||
/**
|
||||
* Api query filter
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<ion-toolbar color="primary">
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
<ion-menu-button></ion-menu-button>
|
||||
<ion-menu-button *ngIf="showDrawer"></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-buttons slot="end">
|
||||
<ion-menu-button menu="context" auto-hide="false">
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
<ng-container *ngIf="items | async as items; else loading">
|
||||
<!--
|
||||
~ Copyright (C) 2022 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licens for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ng-container *ngIf="items as items; else loading">
|
||||
<ion-list>
|
||||
<ng-container *ngIf="!listHeader; else header"></ng-container>
|
||||
<ng-container *ngFor="let item of items">
|
||||
<ng-container *ngFor="let item of items | async">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
listItemTemplateRef || defaultListItem;
|
||||
|
||||
Reference in New Issue
Block a user