ngx-edu-sharing-ui 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +16 -0
- package/.eslintrc.json +44 -0
- package/README.md +40 -0
- package/assets/scss/mixins.scss +95 -0
- package/assets/scss/variables.scss +33 -0
- package/karma.conf.js +42 -0
- package/ng-package.json +10 -0
- package/package.json +19 -0
- package/src/lib/actionbar/actionbar.component.html +59 -0
- package/src/lib/actionbar/actionbar.component.scss +123 -0
- package/src/lib/actionbar/actionbar.component.ts +174 -0
- package/src/lib/common/edu-sharing-ui-common.module.ts +80 -0
- package/src/lib/directives/border-box-observer.directive.ts +75 -0
- package/src/lib/directives/check-text-overflow.directive.ts +61 -0
- package/src/lib/directives/drag-nodes/drag-nodes.ts +32 -0
- package/src/lib/directives/drag-nodes/nodes-drag-source.directive.ts +79 -0
- package/src/lib/directives/drag-nodes/nodes-drag.directive.ts +43 -0
- package/src/lib/directives/drag-nodes/nodes-drop-target.directive.ts +116 -0
- package/src/lib/directives/focus-state.directive.ts +34 -0
- package/src/lib/directives/icon.directive.ts +142 -0
- package/src/lib/directives/nodes-drop-target-legacy.directive.ts +155 -0
- package/src/lib/dropdown/dropdown.component.html +32 -0
- package/src/lib/dropdown/dropdown.component.scss +67 -0
- package/src/lib/dropdown/dropdown.component.ts +71 -0
- package/src/lib/edu-sharing-ui-configuration.ts +47 -0
- package/src/lib/edu-sharing-ui.module.ts +49 -0
- package/src/lib/list-items/available-widgets.ts +30 -0
- package/src/lib/list-items/format-duration.pipe.ts +17 -0
- package/src/lib/list-items/list-base/list-base.component.html +52 -0
- package/src/lib/list-items/list-base/list-base.component.ts +44 -0
- package/src/lib/list-items/list-collection-info/list-collection-info.component.html +48 -0
- package/src/lib/list-items/list-collection-info/list-collection-info.component.scss +8 -0
- package/src/lib/list-items/list-collection-info/list-collection-info.component.ts +24 -0
- package/src/lib/list-items/list-counts/list-counts.component.html +1 -0
- package/src/lib/list-items/list-counts/list-counts.component.scss +3 -0
- package/src/lib/list-items/list-counts/list-counts.component.ts +59 -0
- package/src/lib/list-items/list-items.module.ts +33 -0
- package/src/lib/list-items/list-node-license/list-node-license.component.html +8 -0
- package/src/lib/list-items/list-node-license/list-node-license.component.ts +47 -0
- package/src/lib/list-items/list-node-replication-source/list-node-replication-source.component.html +11 -0
- package/src/lib/list-items/list-node-replication-source/list-node-replication-source.component.ts +60 -0
- package/src/lib/list-items/list-node-workflow/list-node-workflow.component.html +3 -0
- package/src/lib/list-items/list-node-workflow/list-node-workflow.component.ts +21 -0
- package/src/lib/list-items/list-text/list-text.component.html +176 -0
- package/src/lib/list-items/list-text/list-text.component.scss +3 -0
- package/src/lib/list-items/list-text/list-text.component.ts +107 -0
- package/src/lib/list-items/list-widget.ts +52 -0
- package/src/lib/list-items/node-row/node-row.component.html +31 -0
- package/src/lib/list-items/node-row/node-row.component.scss +50 -0
- package/src/lib/list-items/node-row/node-row.component.ts +16 -0
- package/src/lib/list-items/node-source.pipe.ts +48 -0
- package/src/lib/node-entries/combined-data-source.ts +51 -0
- package/src/lib/node-entries/custom-templates-data-source.ts +6 -0
- package/src/lib/node-entries/drag-preview/drag-preview.component.html +6 -0
- package/src/lib/node-entries/drag-preview/drag-preview.component.scss +35 -0
- package/src/lib/node-entries/drag-preview/drag-preview.component.ts +15 -0
- package/src/lib/node-entries/entries-model.ts +120 -0
- package/src/lib/node-entries/items-cap.ts +54 -0
- package/src/lib/node-entries/list-item-label.pipe.ts +28 -0
- package/src/lib/node-entries/mixins.scss +23 -0
- package/src/lib/node-entries/node-cache.spec.ts +199 -0
- package/src/lib/node-entries/node-cache.ts +81 -0
- package/src/lib/node-entries/node-data-source-remote.ts +33 -0
- package/src/lib/node-entries/node-data-source.ts +148 -0
- package/src/lib/node-entries/node-entries-card/node-entries-card.component.html +167 -0
- package/src/lib/node-entries/node-entries-card/node-entries-card.component.scss +28 -0
- package/src/lib/node-entries/node-entries-card/node-entries-card.component.ts +132 -0
- package/src/lib/node-entries/node-entries-card/node-entries-card.main.scss +261 -0
- package/src/lib/node-entries/node-entries-card-grid/node-entries-card-grid.component.html +205 -0
- package/src/lib/node-entries/node-entries-card-grid/node-entries-card-grid.component.scss +181 -0
- package/src/lib/node-entries/node-entries-card-grid/node-entries-card-grid.component.ts +361 -0
- package/src/lib/node-entries/node-entries-card-small/node-entries-card-small.component.html +100 -0
- package/src/lib/node-entries/node-entries-card-small/node-entries-card-small.component.scss +46 -0
- package/src/lib/node-entries/node-entries-card-small/node-entries-card-small.component.ts +40 -0
- package/src/lib/node-entries/node-entries-global-options/node-entries-global-options.component.html +23 -0
- package/src/lib/node-entries/node-entries-global-options/node-entries-global-options.component.scss +58 -0
- package/src/lib/node-entries/node-entries-global-options/node-entries-global-options.component.ts +16 -0
- package/src/lib/node-entries/node-entries-global.service.ts +79 -0
- package/src/lib/node-entries/node-entries-table/column-chooser/column-chooser.component.html +25 -0
- package/src/lib/node-entries/node-entries-table/column-chooser/column-chooser.component.scss +32 -0
- package/src/lib/node-entries/node-entries-table/column-chooser/column-chooser.component.ts +31 -0
- package/src/lib/node-entries/node-entries-table/node-entries-table.component.html +270 -0
- package/src/lib/node-entries/node-entries-table/node-entries-table.component.scss +169 -0
- package/src/lib/node-entries/node-entries-table/node-entries-table.component.ts +333 -0
- package/src/lib/node-entries/node-entries-templates.service.ts +31 -0
- package/src/lib/node-entries/node-entries-wrapper.component.ts +363 -0
- package/src/lib/node-entries/node-entries.component.html +33 -0
- package/src/lib/node-entries/node-entries.component.scss +13 -0
- package/src/lib/node-entries/node-entries.component.ts +151 -0
- package/src/lib/node-entries/node-entries.module.ts +93 -0
- package/src/lib/node-entries/node-rating/node-rating.component.html +53 -0
- package/src/lib/node-entries/node-rating/node-rating.component.scss +31 -0
- package/src/lib/node-entries/node-rating/node-rating.component.ts +105 -0
- package/src/lib/node-entries/node-stats-badges/node-stats-badges.component.html +39 -0
- package/src/lib/node-entries/node-stats-badges/node-stats-badges.component.scss +44 -0
- package/src/lib/node-entries/node-stats-badges/node-stats-badges.component.ts +43 -0
- package/src/lib/node-entries/node-type-badge/node-type-badge.component.html +31 -0
- package/src/lib/node-entries/node-type-badge/node-type-badge.component.scss +5 -0
- package/src/lib/node-entries/node-type-badge/node-type-badge.component.ts +36 -0
- package/src/lib/node-entries/option-button/option-button.component.ts +42 -0
- package/src/lib/node-entries/preview-image/preview-image.component.html +19 -0
- package/src/lib/node-entries/preview-image/preview-image.component.scss +31 -0
- package/src/lib/node-entries/preview-image/preview-image.component.ts +47 -0
- package/src/lib/node-entries/sort-select-panel/sort-select-panel.component.html +27 -0
- package/src/lib/node-entries/sort-select-panel/sort-select-panel.component.scss +9 -0
- package/src/lib/node-entries/sort-select-panel/sort-select-panel.component.ts +26 -0
- package/src/lib/node-url/node-url.component.html +66 -0
- package/src/lib/node-url/node-url.component.scss +32 -0
- package/src/lib/node-url/node-url.component.ts +136 -0
- package/src/lib/pipes/file-size.pipe.ts +24 -0
- package/src/lib/pipes/format-date.pipe.ts +39 -0
- package/src/lib/pipes/node-icon.pipe.ts +11 -0
- package/src/lib/pipes/node-image-size.pipe.ts +18 -0
- package/src/lib/pipes/node-image.pipe.ts +71 -0
- package/src/lib/pipes/node-person-name.pipe.ts +41 -0
- package/src/lib/pipes/node-title.pipe.ts +12 -0
- package/src/lib/pipes/option-tooltip.pipe.ts +32 -0
- package/src/lib/pipes/replace-chars.pipe.ts +21 -0
- package/src/lib/pipes/vcard-name.pipe.ts +11 -0
- package/src/lib/services/abstract/app.service.ts +4 -0
- package/src/lib/services/abstract/keyboard-shortcuts.service.ts +10 -0
- package/src/lib/services/abstract/options-helper.service.ts +29 -0
- package/src/lib/services/abstract/toast.service.ts +5 -0
- package/src/lib/services/accessibility.service.ts +101 -0
- package/src/lib/services/local-events.service.ts +29 -0
- package/src/lib/services/node-entries.service.ts +172 -0
- package/src/lib/services/node-helper.service.ts +239 -0
- package/src/lib/services/nodes-drag-drop.service.ts +165 -0
- package/src/lib/services/options-helper-data.service.ts +186 -0
- package/src/lib/services/repo-url.service.ts +46 -0
- package/src/lib/services/temporary-storage.service.ts +58 -0
- package/src/lib/services/ui.service.ts +182 -0
- package/src/lib/sort-dropdown/sort-dropdown.component.html +22 -0
- package/src/lib/sort-dropdown/sort-dropdown.component.scss +47 -0
- package/src/lib/sort-dropdown/sort-dropdown.component.ts +42 -0
- package/src/lib/spinner/spinner.component.html +14 -0
- package/src/lib/spinner/spinner.component.scss +141 -0
- package/src/lib/spinner/spinner.component.ts +12 -0
- package/src/lib/translations/README.md +44 -0
- package/src/lib/translations/fallback-translation-handler.ts +7 -0
- package/src/lib/translations/languages.ts +6 -0
- package/src/lib/translations/translation-loader.spec.ts +352 -0
- package/src/lib/translations/translation-loader.ts +189 -0
- package/src/lib/translations/translation-source.ts +9 -0
- package/src/lib/translations/translations.module.ts +49 -0
- package/src/lib/translations/translations.service.spec.ts +152 -0
- package/src/lib/translations/translations.service.ts +188 -0
- package/src/lib/types/accessibillity.ts +15 -0
- package/src/lib/types/api-models.ts +4 -0
- package/src/lib/types/drag-drop.ts +22 -0
- package/src/lib/types/keyboard-shortcuts.ts +29 -0
- package/src/lib/types/list-item.ts +67 -0
- package/src/lib/types/option-item.ts +247 -0
- package/src/lib/types/workflow.ts +35 -0
- package/src/lib/util/DateHelper.spec.ts +112 -0
- package/src/lib/util/DateHelper.ts +197 -0
- package/src/lib/util/VCard.ts +277 -0
- package/src/lib/util/color-helper.ts +125 -0
- package/src/lib/util/duration-helper.spec.ts +35 -0
- package/src/lib/util/duration-helper.ts +98 -0
- package/src/lib/util/functions.ts +15 -0
- package/src/lib/util/helper.ts +60 -0
- package/src/lib/util/isNumeric.ts +13 -0
- package/src/lib/util/rest-helper.ts +28 -0
- package/src/lib/util/ui-animation.ts +154 -0
- package/src/lib/util/ui-constants.ts +20 -0
- package/src/module.ts +76 -0
- package/src/test.ts +28 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { CdkOverlayOrigin } from '@angular/cdk/overlay';
|
|
2
|
+
import {
|
|
3
|
+
AfterViewInit,
|
|
4
|
+
ApplicationRef,
|
|
5
|
+
ChangeDetectionStrategy,
|
|
6
|
+
ChangeDetectorRef,
|
|
7
|
+
Component,
|
|
8
|
+
ElementRef,
|
|
9
|
+
NgZone,
|
|
10
|
+
OnChanges,
|
|
11
|
+
OnDestroy,
|
|
12
|
+
SimpleChanges,
|
|
13
|
+
ViewChild,
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { MatMenuTrigger } from '@angular/material/menu';
|
|
16
|
+
import { MatPaginator } from '@angular/material/paginator';
|
|
17
|
+
import { MatSort, MatSortHeader, Sort } from '@angular/material/sort';
|
|
18
|
+
import * as rxjs from 'rxjs';
|
|
19
|
+
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
20
|
+
import {
|
|
21
|
+
debounceTime,
|
|
22
|
+
delay,
|
|
23
|
+
distinctUntilChanged,
|
|
24
|
+
first,
|
|
25
|
+
map,
|
|
26
|
+
shareReplay,
|
|
27
|
+
startWith,
|
|
28
|
+
takeUntil,
|
|
29
|
+
} from 'rxjs/operators';
|
|
30
|
+
import {
|
|
31
|
+
ClickSource,
|
|
32
|
+
InteractionType,
|
|
33
|
+
NodeEntriesDataType,
|
|
34
|
+
NodeEntriesDisplayType,
|
|
35
|
+
} from '../entries-model';
|
|
36
|
+
import { NodeEntriesGlobalService } from '../node-entries-global.service';
|
|
37
|
+
import { NodeEntriesService } from '../../services/node-entries.service';
|
|
38
|
+
import { UIService } from '../../services/ui.service';
|
|
39
|
+
import { BorderBoxObserverDirective } from '../../directives/border-box-observer.directive';
|
|
40
|
+
import { ListItem } from '../../types/list-item';
|
|
41
|
+
import { CanDrop, DragData } from '../../types/drag-drop';
|
|
42
|
+
import { Node } from 'ngx-edu-sharing-api';
|
|
43
|
+
import { Target } from '../../types/option-item';
|
|
44
|
+
import { Toast } from '../../services/abstract/toast.service';
|
|
45
|
+
import { DropdownComponent } from '../../dropdown/dropdown.component';
|
|
46
|
+
import { NodeDataSourceRemote } from '../node-data-source-remote';
|
|
47
|
+
|
|
48
|
+
@Component({
|
|
49
|
+
selector: 'es-node-entries-table',
|
|
50
|
+
templateUrl: './node-entries-table.component.html',
|
|
51
|
+
styleUrls: ['./node-entries-table.component.scss'],
|
|
52
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
53
|
+
})
|
|
54
|
+
export class NodeEntriesTableComponent<T extends NodeEntriesDataType>
|
|
55
|
+
implements OnChanges, AfterViewInit, OnDestroy
|
|
56
|
+
{
|
|
57
|
+
readonly InteractionType = InteractionType;
|
|
58
|
+
readonly ClickSource = ClickSource;
|
|
59
|
+
readonly NodeEntriesDisplayType = NodeEntriesDisplayType;
|
|
60
|
+
readonly Target = Target;
|
|
61
|
+
|
|
62
|
+
@ViewChild(MatSort) sort: MatSort;
|
|
63
|
+
@ViewChild(MatPaginator) paginator: MatPaginator;
|
|
64
|
+
@ViewChild('columnChooserTrigger') columnChooserTrigger: CdkOverlayOrigin;
|
|
65
|
+
@ViewChild(DropdownComponent) dropdown: DropdownComponent;
|
|
66
|
+
@ViewChild('menuTrigger') menuTrigger: MatMenuTrigger;
|
|
67
|
+
|
|
68
|
+
dropdownLeft: number;
|
|
69
|
+
dropdownTop: number;
|
|
70
|
+
|
|
71
|
+
loading: Observable<boolean>;
|
|
72
|
+
isPageSelected = new BehaviorSubject(false);
|
|
73
|
+
isAllSelected = new BehaviorSubject(false);
|
|
74
|
+
columnChooserVisible = false;
|
|
75
|
+
columnChooserTriggerReady = false;
|
|
76
|
+
error: Observable<any>;
|
|
77
|
+
pageSizeOptions = [25, 50, 100];
|
|
78
|
+
isDragging = false;
|
|
79
|
+
|
|
80
|
+
private readonly maximumColumnsNumber$ = new BehaviorSubject(1);
|
|
81
|
+
readonly visibleDataColumns$;
|
|
82
|
+
readonly visibleColumnNames$;
|
|
83
|
+
|
|
84
|
+
private destroyed = new Subject<void>();
|
|
85
|
+
|
|
86
|
+
constructor(
|
|
87
|
+
public entriesService: NodeEntriesService<T>,
|
|
88
|
+
public entriesGlobalService: NodeEntriesGlobalService,
|
|
89
|
+
private applicationRef: ApplicationRef,
|
|
90
|
+
private toast: Toast,
|
|
91
|
+
private changeDetectorRef: ChangeDetectorRef,
|
|
92
|
+
public ui: UIService,
|
|
93
|
+
private ngZone: NgZone,
|
|
94
|
+
private elementRef: ElementRef<HTMLElement>,
|
|
95
|
+
) {
|
|
96
|
+
this.visibleDataColumns$ = this.getVisibleDataColumns();
|
|
97
|
+
this.visibleColumnNames$ = this.getVisibleColumnNames();
|
|
98
|
+
this.registerMaximumColumnsNumber();
|
|
99
|
+
this.entriesService.selection.changed
|
|
100
|
+
.pipe(takeUntil(this.destroyed), debounceTime(0))
|
|
101
|
+
.subscribe(() => this.changeDetectorRef.detectChanges());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
ngAfterViewInit(): void {
|
|
105
|
+
void Promise.resolve().then(() => {
|
|
106
|
+
this.registerSortChanges();
|
|
107
|
+
if (this.entriesService.dataSource instanceof NodeDataSourceRemote) {
|
|
108
|
+
(this.entriesService.dataSource as NodeDataSourceRemote).sortPanel = this.sort;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
this.visibleDataColumns$
|
|
112
|
+
.pipe(first(), delay(0))
|
|
113
|
+
.subscribe(() => (this.columnChooserTriggerReady = true));
|
|
114
|
+
rxjs.combineLatest([
|
|
115
|
+
this.entriesService.dataSource$.pipe(startWith(void 0 as void)),
|
|
116
|
+
this.entriesService.options$.pipe(startWith(void 0 as void)),
|
|
117
|
+
this.entriesService.dataSource.isLoadingSubject.pipe(startWith(void 0 as void)),
|
|
118
|
+
this.entriesService.selection.changed.pipe(startWith(void 0 as void)),
|
|
119
|
+
])
|
|
120
|
+
.pipe(takeUntil(this.destroyed))
|
|
121
|
+
.subscribe(() => {
|
|
122
|
+
this.changeDetectorRef.detectChanges();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
127
|
+
this.updateSort();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ngOnDestroy(): void {
|
|
131
|
+
this.destroyed.next();
|
|
132
|
+
this.destroyed.complete();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onRowContextMenu({ event, node }: { event: MouseEvent | Event; node: T }) {
|
|
136
|
+
if (!this.entriesService.selection.selected.includes(node)) {
|
|
137
|
+
this.entriesService.selection.clear();
|
|
138
|
+
this.entriesService.selection.select(node);
|
|
139
|
+
}
|
|
140
|
+
event.stopPropagation();
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
if (event instanceof MouseEvent) {
|
|
143
|
+
({ clientX: this.dropdownLeft, clientY: this.dropdownTop } = event);
|
|
144
|
+
} else {
|
|
145
|
+
({ x: this.dropdownLeft, y: this.dropdownTop } = (
|
|
146
|
+
event.target as HTMLElement
|
|
147
|
+
).getBoundingClientRect());
|
|
148
|
+
}
|
|
149
|
+
// Wait for the menu to reflect changed options.
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
if (this.dropdown.canShowDropdown()) {
|
|
152
|
+
this.menuTrigger.openMenu();
|
|
153
|
+
} else {
|
|
154
|
+
this.toast.toast('NO_AVAILABLE_OPTIONS');
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private updateSort(): void {
|
|
160
|
+
this.sort.sort({
|
|
161
|
+
id: this.entriesService.sort?.active,
|
|
162
|
+
start: this.entriesService.sort?.direction as 'asc' | 'desc',
|
|
163
|
+
disableClear: false,
|
|
164
|
+
});
|
|
165
|
+
// Fix missing sorting indicators. See
|
|
166
|
+
// https://github.com/angular/components/issues/10242#issuecomment-470726829. Seems
|
|
167
|
+
// to be fixed upstream with Angular 11.
|
|
168
|
+
(
|
|
169
|
+
this.sort.sortables.get(this.entriesService.sort?.active) as MatSortHeader
|
|
170
|
+
)._setAnimationTransitionState({
|
|
171
|
+
toState: 'active',
|
|
172
|
+
});
|
|
173
|
+
/*
|
|
174
|
+
this.route.queryParams.pipe(first()).subscribe((queryParams: Params) => {
|
|
175
|
+
const sort: Sort = queryParams.sort ? JSON.parse(queryParams.sort) : null;
|
|
176
|
+
if (sort && sort.direction) {
|
|
177
|
+
this.sort.sort({ id: sort.active, start: sort.direction, disableClear: false });
|
|
178
|
+
// Fix missing sorting indicators. See
|
|
179
|
+
// https://github.com/angular/components/issues/10242#issuecomment-470726829. Seems
|
|
180
|
+
// to be fixed upstream with Angular 11.
|
|
181
|
+
(
|
|
182
|
+
this.sort.sortables.get(sort.active) as MatSortHeader
|
|
183
|
+
)._setAnimationTransitionState({
|
|
184
|
+
toState: 'active',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (queryParams.pageIndex && queryParams.pageSize) {
|
|
188
|
+
this.paginator.pageIndex = queryParams.pageIndex;
|
|
189
|
+
this.paginator.pageSize = queryParams.pageSize;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
*/
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private registerMaximumColumnsNumber() {
|
|
196
|
+
BorderBoxObserverDirective.observeElement(this.elementRef)
|
|
197
|
+
.pipe(
|
|
198
|
+
takeUntil(this.destroyed),
|
|
199
|
+
map((box) => this.getMaximumColumnsNumber(box.width)),
|
|
200
|
+
distinctUntilChanged(),
|
|
201
|
+
)
|
|
202
|
+
.subscribe((maximumColumnsNumber) =>
|
|
203
|
+
this.ngZone.run(() => this.maximumColumnsNumber$.next(maximumColumnsNumber)),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private getMaximumColumnsNumber(tableWidth: number): number {
|
|
208
|
+
return Math.max(
|
|
209
|
+
1,
|
|
210
|
+
Math.floor(
|
|
211
|
+
// Subtract total width of always visible columns like checkboxes and icons.
|
|
212
|
+
(tableWidth - 187) /
|
|
213
|
+
// Divide by with of data columns (including margin).
|
|
214
|
+
126,
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private getVisibleDataColumns(): Observable<ListItem[]> {
|
|
220
|
+
return rxjs
|
|
221
|
+
.combineLatest([this.maximumColumnsNumber$, this.entriesService.columnsSubject])
|
|
222
|
+
.pipe(
|
|
223
|
+
map(([maximumColumnsNumber, columns]) => {
|
|
224
|
+
return (columns ?? [])
|
|
225
|
+
.filter((column) => column.visible)
|
|
226
|
+
.filter((_, index) => index < maximumColumnsNumber);
|
|
227
|
+
}),
|
|
228
|
+
shareReplay(1),
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private getVisibleColumnNames(): Observable<string[]> {
|
|
233
|
+
return this.visibleDataColumns$.pipe(
|
|
234
|
+
map((visibleDataColumns) => {
|
|
235
|
+
const columns = [];
|
|
236
|
+
if (this.entriesService.checkbox) {
|
|
237
|
+
columns.push('select');
|
|
238
|
+
}
|
|
239
|
+
columns.push('icon');
|
|
240
|
+
return columns.concat(visibleDataColumns.map((c) => c.name)).concat(['actions']);
|
|
241
|
+
}),
|
|
242
|
+
shareReplay(1),
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
isSortable(column: ListItem) {
|
|
247
|
+
return this.entriesService.sort?.columns.some((c) => c.name === column.name);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
toggleAll(checked: boolean) {
|
|
251
|
+
if (checked) {
|
|
252
|
+
this.entriesService.selection.select(...this.entriesService.dataSource.getData());
|
|
253
|
+
} else {
|
|
254
|
+
this.entriesService.selection.clear();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private registerSortChanges() {
|
|
259
|
+
this.sort.sortChange.subscribe((sort: Sort) => {
|
|
260
|
+
this.entriesService.sort.active = sort.active;
|
|
261
|
+
this.entriesService.sort.direction = sort.direction;
|
|
262
|
+
this.entriesService.sortChange.emit(this.entriesService.sort);
|
|
263
|
+
/*this.router.navigate(['.'], {
|
|
264
|
+
relativeTo: this.route,
|
|
265
|
+
queryParams: { sort: JSON.stringify(sort) },
|
|
266
|
+
queryParamsHandling: 'merge',
|
|
267
|
+
replaceUrl: true,
|
|
268
|
+
});*/
|
|
269
|
+
});
|
|
270
|
+
/*
|
|
271
|
+
this.paginator.page
|
|
272
|
+
.pipe(
|
|
273
|
+
// As a response to changes of other parameters, the pageIndex might be reset to 0 and a
|
|
274
|
+
// page event triggers. This change of other parameters is likely to cause a
|
|
275
|
+
// `router.navigate()` call elsewhere. When this happens just before our call, our
|
|
276
|
+
// updates are ignored. To shield against this, we wait a tick.
|
|
277
|
+
delay(0),
|
|
278
|
+
)
|
|
279
|
+
.subscribe(({ pageIndex, pageSize }: PageEvent) => {
|
|
280
|
+
this.router.navigate(['.'], {
|
|
281
|
+
relativeTo: this.route,
|
|
282
|
+
queryParams: { pageIndex, pageSize },
|
|
283
|
+
queryParamsHandling: 'merge',
|
|
284
|
+
replaceUrl: true,
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
*/
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
canDrop = (dragData: DragData<T>): CanDrop => {
|
|
291
|
+
return this.entriesService.dragDrop.dropAllowed?.(dragData);
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
drop(dragData: DragData<Node>) {
|
|
295
|
+
this.entriesService.dragDrop.dropped(dragData.target, {
|
|
296
|
+
element: dragData.draggedNodes,
|
|
297
|
+
mode: dragData.action,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
getDragData(node: T): T[] {
|
|
302
|
+
const selection = this.entriesService.selection;
|
|
303
|
+
if (selection.isSelected(node)) {
|
|
304
|
+
return selection.selected;
|
|
305
|
+
} else {
|
|
306
|
+
return [node];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
onDragStarted(node: T) {
|
|
311
|
+
if (!this.entriesService.selection.isSelected(node)) {
|
|
312
|
+
this.entriesService.selection.clear();
|
|
313
|
+
this.entriesService.selection.select(node);
|
|
314
|
+
}
|
|
315
|
+
this.isDragging = true;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
onDragEnded() {
|
|
319
|
+
this.isDragging = false;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
loadData(source: 'scroll' | 'button') {
|
|
323
|
+
// TODO: focus next item when triggered via button.
|
|
324
|
+
this.entriesService.loadMore(source);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async openMenu(node: T) {
|
|
328
|
+
this.entriesService.selection.clear();
|
|
329
|
+
this.entriesService.selection.select(node);
|
|
330
|
+
await this.applicationRef.tick();
|
|
331
|
+
this.dropdown.menu.focusFirstItem();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Injectable, TemplateRef } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Injectable()
|
|
4
|
+
export class NodeEntriesTemplatesService {
|
|
5
|
+
/**
|
|
6
|
+
* custom heading/title above the current result set
|
|
7
|
+
*/
|
|
8
|
+
title: TemplateRef<any>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Additional top matter that is provided by the selected node-entries component.
|
|
12
|
+
*/
|
|
13
|
+
entriesTopMatter: TemplateRef<unknown>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* custom container in case the data source is empty
|
|
17
|
+
*/
|
|
18
|
+
empty: TemplateRef<any>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* custom container for the action area on each element
|
|
22
|
+
* (small grid only)
|
|
23
|
+
*/
|
|
24
|
+
actionArea: TemplateRef<any>;
|
|
25
|
+
/**
|
|
26
|
+
* custom container for showing an overlay across each element
|
|
27
|
+
*/
|
|
28
|
+
overlay: TemplateRef<any>;
|
|
29
|
+
|
|
30
|
+
constructor() {}
|
|
31
|
+
}
|