mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
feat: Ionic v6 breadcrumbs in catalog module
This commit is contained in:
41
src/app/util/lazy.pipe.ts
Normal file
41
src/app/util/lazy.pipe.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 License 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/>.
|
||||
*/
|
||||
|
||||
import {Observable} from 'rxjs';
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
||||
import {DataProvider, DataScope} from '../modules/data/data.provider';
|
||||
import {get} from '../_helpers/collections/get';
|
||||
|
||||
@Pipe({
|
||||
name: 'lazyThing',
|
||||
pure: true,
|
||||
})
|
||||
export class LazyPipe implements PipeTransform {
|
||||
constructor(private readonly dataProvider: DataProvider) {}
|
||||
|
||||
transform(
|
||||
uid: SCUuid,
|
||||
path?: keyof SCThings | string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
): Observable<SCThings | SCSaveableThing> | any {
|
||||
return new Observable(subscriber => {
|
||||
this.dataProvider.get(uid, DataScope.Remote).then(it => {
|
||||
subscriber.next(path ? get(it, path) : it);
|
||||
subscriber.complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
47
src/app/util/routing-stack.service.ts
Normal file
47
src/app/util/routing-stack.service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 License 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/>.
|
||||
*/
|
||||
|
||||
import {Injectable} from '@angular/core';
|
||||
import {NavigationEnd, Router} from '@angular/router';
|
||||
import {SCSaveableThing, SCThings} from '@openstapps/core';
|
||||
import {DataProvider, DataScope} from '../modules/data/data.provider';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RoutingStackService {
|
||||
currentRoute: string;
|
||||
|
||||
currentDataDetail?: Promise<SCSaveableThing | SCThings>;
|
||||
|
||||
lastRoute: string;
|
||||
|
||||
lastDataDetail?: Promise<SCSaveableThing | SCThings>;
|
||||
|
||||
constructor(private router: Router, private dataProvider: DataProvider) {
|
||||
this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.lastRoute = this.currentRoute;
|
||||
this.currentRoute = event.urlAfterRedirects;
|
||||
|
||||
const uid = this.currentRoute.match(/^\/data-detail\/([\w-]+)$/)?.[1];
|
||||
this.lastDataDetail = this.currentDataDetail;
|
||||
this.currentDataDetail = uid
|
||||
? this.dataProvider.get(uid, DataScope.Remote)
|
||||
: undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.
|
||||
* 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 License for
|
||||
* more details.
|
||||
* 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 License 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/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {NgModule} from '@angular/core';
|
||||
@@ -18,18 +18,21 @@ import {ArrayLastPipe} from './array-last.pipe';
|
||||
import {DateIsThisPipe} from './date-is-today.pipe';
|
||||
import {NullishCoalescingPipe} from './nullish-coalecing.pipe';
|
||||
import {DateFromIndexPipe} from './date-from-index.pipe';
|
||||
import {LazyPipe} from './lazy.pipe';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
ArrayLastPipe,
|
||||
DateIsThisPipe,
|
||||
NullishCoalescingPipe,
|
||||
LazyPipe,
|
||||
DateFromIndexPipe,
|
||||
],
|
||||
exports: [
|
||||
ArrayLastPipe,
|
||||
DateIsThisPipe,
|
||||
NullishCoalescingPipe,
|
||||
LazyPipe,
|
||||
DateFromIndexPipe,
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user