-
+
{{ 'data.detail.NOT_FOUND' | translate }}
@@ -65,7 +65,10 @@
-
+
.
*/
-import {Component, Input, OnInit} from '@angular/core';
+import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {RoutingStackService} from '../../../util/routing-stack.service';
import {
SCCatalog,
@@ -21,24 +21,24 @@ import {
SCThingWithoutReferences,
} from '@openstapps/core';
import {DataProvider, DataScope} from '../data.provider';
-import {fromEvent, Observable} from 'rxjs';
-import {map} from 'rxjs/operators';
+import {fromEvent, Observable, Subscription} from 'rxjs';
+import {map, startWith} from 'rxjs/operators';
+import {DataRoutingService} from '../data-routing.service';
+import {NavController} from '@ionic/angular';
@Component({
selector: 'stapps-data-path',
templateUrl: './data-path.html',
styleUrls: ['./data-path.scss'],
})
-export class DataPathComponent implements OnInit {
+export class DataPathComponent implements OnInit, OnDestroy {
path: Promise;
$width: Observable;
- ngOnInit() {
- this.$width = fromEvent(window, 'resize').pipe(
- map(() => window.innerWidth),
- );
- }
+ subscriptions: Subscription[] = [];
+
+ @Input() autoRouting = true;
@Input() set item(item: SCThings) {
// eslint-disable-next-line unicorn/prefer-ternary
@@ -47,6 +47,11 @@ export class DataPathComponent implements OnInit {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
resolve([...item.superCatalogs!, item]),
);
+ } else if (item.type === SCThingType.Assessment && item.superAssessments) {
+ this.path = new Promise(resolve =>
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ resolve([...item.superAssessments!, item]),
+ );
} else if (
item.type === SCThingType.AcademicEvent &&
item.catalogs &&
@@ -76,7 +81,27 @@ export class DataPathComponent implements OnInit {
}
constructor(
+ readonly dataRoutingService: DataRoutingService,
+ readonly navController: NavController,
readonly routeStack: RoutingStackService,
readonly dataProvider: DataProvider,
) {}
+
+ ngOnInit() {
+ this.$width = fromEvent(window, 'resize').pipe(
+ map(() => window.innerWidth),
+ startWith(window.innerWidth),
+ );
+
+ if (!this.autoRouting) return;
+ this.subscriptions.push(
+ this.dataRoutingService.pathSelectListener().subscribe(item => {
+ void this.navController.navigateBack(['data-detail', item.uid]);
+ }),
+ );
+ }
+
+ ngOnDestroy() {
+ for (const sub of this.subscriptions) sub.unsubscribe();
+ }
}
diff --git a/src/app/modules/data/detail/data-path.html b/src/app/modules/data/detail/data-path.html
index f75b1cf6..20e13d8b 100644
--- a/src/app/modules/data/detail/data-path.html
+++ b/src/app/modules/data/detail/data-path.html
@@ -22,8 +22,7 @@
>
{{ 'name' | thingTranslate: $any(fragment) }}
diff --git a/src/app/modules/data/list/tree-list-fragment.component.ts b/src/app/modules/data/list/tree-list-fragment.component.ts
new file mode 100644
index 00000000..9e19a89f
--- /dev/null
+++ b/src/app/modules/data/list/tree-list-fragment.component.ts
@@ -0,0 +1,44 @@
+/*
+ * 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 .
+ */
+import {Component, Input, TemplateRef} from '@angular/core';
+import {SCThings, SCThingWithoutReferences, SCUuid} from '@openstapps/core';
+import {Tree} from '../../../_helpers/collections/tree-group';
+import {DataListContext} from './data-list.component';
+
+@Component({
+ selector: 'tree-list-fragment',
+ templateUrl: 'tree-list-fragment.html',
+ styleUrls: ['tree-list-fragment.scss'],
+})
+export class TreeListFragmentComponent {
+ entries?: [string, Tree][];
+
+ @Input() set items(items: Tree | undefined) {
+ if (!items) {
+ delete this.entries;
+ return;
+ }
+ const temporary = items._;
+ delete items._;
+ this.entries = Object.entries(items) as [string, Tree][];
+ items._ = temporary;
+ }
+
+ @Input() groupMap: Record;
+
+ @Input() singleType = false;
+
+ @Input() listItemTemplateRef: TemplateRef>;
+}
diff --git a/src/app/modules/data/list/tree-list-fragment.html b/src/app/modules/data/list/tree-list-fragment.html
new file mode 100644
index 00000000..c9400299
--- /dev/null
+++ b/src/app/modules/data/list/tree-list-fragment.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+ {{ header.name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/modules/data/list/tree-list-fragment.scss b/src/app/modules/data/list/tree-list-fragment.scss
new file mode 100644
index 00000000..c624183d
--- /dev/null
+++ b/src/app/modules/data/list/tree-list-fragment.scss
@@ -0,0 +1,18 @@
+/*!
+ * 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 .
+ */
+
+ion-list {
+ margin-left: 16px;
+}
diff --git a/src/app/modules/data/list/tree-list.component.ts b/src/app/modules/data/list/tree-list.component.ts
new file mode 100644
index 00000000..78aabd35
--- /dev/null
+++ b/src/app/modules/data/list/tree-list.component.ts
@@ -0,0 +1,76 @@
+/*
+ * 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 .
+ */
+import {Component, ContentChild, Input, TemplateRef} from '@angular/core';
+import {DataListContext} from './data-list.component';
+import {SCThings, SCThingWithoutReferences, SCUuid} from '@openstapps/core';
+import {Tree, treeGroupBy} from '../../../_helpers/collections/tree-group';
+
+@Component({
+ selector: 'tree-list',
+ templateUrl: 'tree-list.html',
+ styleUrls: ['tree-list.scss'],
+})
+export class TreeListComponent {
+ _items?: Promise;
+
+ _groupingKey?: string;
+
+ _groups?: Promise | undefined>;
+
+ _groupItems?: Record;
+
+ @Input() set groupingKey(value: keyof SCThings | string | undefined) {
+ this._groupingKey = value;
+ this.groupItems();
+ }
+
+ @Input() set items(items: Promise | undefined) {
+ this._items = items;
+ this.groupItems();
+ }
+
+ @Input() singleType = false;
+
+ @ContentChild(TemplateRef) listItemTemplateRef: TemplateRef<
+ DataListContext
+ >;
+
+ groupItems() {
+ if (!this._items || !this._groupingKey) return;
+
+ this._groups = this._items.then(items => {
+ if (!items || !this._groupingKey) return;
+
+ this._groupItems = {};
+ for (const item of items) {
+ const path = (
+ item as unknown as Record
+ )[this._groupingKey];
+
+ for (const pathFragment of path) {
+ this._groupItems[pathFragment.uid] = pathFragment;
+ }
+ }
+
+ const tree = treeGroupBy(items, item =>
+ (item as unknown as Record)[
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this._groupingKey!
+ ].map(thing => thing.uid),
+ );
+ return tree;
+ });
+ }
+}
diff --git a/src/app/modules/data/list/tree-list.html b/src/app/modules/data/list/tree-list.html
new file mode 100644
index 00000000..58114e46
--- /dev/null
+++ b/src/app/modules/data/list/tree-list.html
@@ -0,0 +1,22 @@
+
+
+
diff --git a/src/app/modules/data/list/tree-list.scss b/src/app/modules/data/list/tree-list.scss
new file mode 100644
index 00000000..e2e6035a
--- /dev/null
+++ b/src/app/modules/data/list/tree-list.scss
@@ -0,0 +1,15 @@
+/*!
+ * 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 .
+ */
+