Skip to content

Commit 0d88c7c

Browse files
authored
[ENG-9780] Expand File Picker for File Widget on Projects #821
- Ticket: [ENG-9780] - Feature flag: n/a ## Summary of Changes 1. Fixed file widget for loading more than 10 items.
1 parent f331bc2 commit 0d88c7c

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

src/app/features/project/overview/components/files-widget/files-widget.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ <h2>{{ 'project.overview.files.filesPreview' | translate }}</h2>
4343
[resourceId]="selectedRoot!"
4444
[provider]="provider()"
4545
[selectionMode]="null"
46+
[scrollHeight]="'300px'"
4647
(entryFileClicked)="navigateToFile($event)"
4748
(loadFiles)="onLoadFiles($event)"
4849
(setCurrentFolder)="setCurrentFolder($event)"

src/app/features/project/overview/store/project-overview.state.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export class ProjectOverviewState {
4242
@Action(GetProjectById)
4343
getProjectById(ctx: StateContext<ProjectOverviewStateModel>, action: GetProjectById) {
4444
const state = ctx.getState();
45+
46+
if (state.project.isLoading) {
47+
return;
48+
}
49+
4550
ctx.patchState({
4651
project: {
4752
...state.project,
@@ -67,6 +72,11 @@ export class ProjectOverviewState {
6772
@Action(GetProjectInstitutions)
6873
getProjectInstitutions(ctx: StateContext<ProjectOverviewStateModel>, action: GetProjectInstitutions) {
6974
const state = ctx.getState();
75+
76+
if (state.institutions.isLoading) {
77+
return;
78+
}
79+
7080
ctx.patchState({
7181
institutions: {
7282
...state.institutions,
@@ -91,6 +101,11 @@ export class ProjectOverviewState {
91101
@Action(GetProjectIdentifiers)
92102
getProjectIdentifiers(ctx: StateContext<ProjectOverviewStateModel>, action: GetProjectIdentifiers) {
93103
const state = ctx.getState();
104+
105+
if (state.identifiers.isLoading) {
106+
return;
107+
}
108+
94109
ctx.patchState({
95110
identifiers: {
96111
...state.identifiers,
@@ -120,6 +135,10 @@ export class ProjectOverviewState {
120135

121136
const state = ctx.getState();
122137

138+
if (state.license.isLoading) {
139+
return;
140+
}
141+
123142
ctx.patchState({
124143
license: {
125144
...state.license,

src/app/shared/components/files-tree/files-tree.component.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@
2424
<div class="flex-1">
2525
<div class="files-table flex">
2626
<p-tree
27-
[value]="nodes()"
27+
class="tree-table"
28+
styleClass="w-full md:w-[30rem]"
2829
[draggableNodes]="!hasViewOnly() && supportUpload()"
2930
[droppableNodes]="!hasViewOnly() && supportUpload()"
30-
(onScrollIndexChange)="onScrollIndexChange($event)"
31-
[scrollHeight]="scrollHeight()"
32-
[virtualScroll]="true"
33-
[virtualScrollItemSize]="virtualScrollItemSize"
34-
styleClass="w-full md:w-[30rem]"
35-
class="tree-table"
31+
[lazy]="true"
3632
[loading]="isLoadingMore()"
3733
[selectionMode]="selectionMode()"
3834
[selection]="selectedFiles()"
35+
[scrollHeight]="scrollHeight()"
36+
[value]="nodes()"
37+
[virtualScroll]="true"
38+
[virtualScrollItemSize]="virtualScrollItemSize"
39+
(onLazyLoad)="onLazyLoad($event)"
3940
(onNodeSelect)="onNodeSelect($event)"
4041
(onNodeUnselect)="onNodeUnselect($event)"
4142
(onNodeDrop)="onNodeDrop($event)"

src/app/shared/components/files-tree/files-tree.component.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { select } from '@ngxs/store';
33
import { TranslatePipe } from '@ngx-translate/core';
44

55
import { PrimeTemplate } from 'primeng/api';
6-
import { Tree, TreeNodeDropEvent, TreeNodeSelectEvent, TreeScrollIndexChangeEvent } from 'primeng/tree';
6+
import { Tree, TreeLazyLoadEvent, TreeNodeDropEvent, TreeNodeSelectEvent } from 'primeng/tree';
77

88
import { Clipboard } from '@angular/cdk/clipboard';
99
import { DatePipe, isPlatformBrowser } from '@angular/common';
@@ -163,13 +163,6 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit {
163163
this.isLoadingMore.set(false);
164164
}
165165
});
166-
167-
effect(() => {
168-
const loaded = this.files().length;
169-
if (loaded < this.visibleFilesCount()) {
170-
this.loadNextPage();
171-
}
172-
});
173166
}
174167

175168
ngAfterViewInit(): void {
@@ -440,7 +433,7 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit {
440433
}
441434
}
442435

443-
onScrollIndexChange(event: TreeScrollIndexChangeEvent) {
436+
onLazyLoad(event: TreeLazyLoadEvent) {
444437
const loaded = this.files().length;
445438
if (event.last >= loaded - 1) {
446439
this.loadNextPage();

src/app/shared/stores/contributors/contributors.state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export class ContributorsState {
302302
getBibliographicContributors(ctx: StateContext<ContributorsStateModel>, action: GetBibliographicContributors) {
303303
const state = ctx.getState();
304304

305-
if (!action.resourceId || !action.resourceType) {
305+
if (!action.resourceId || !action.resourceType || state.bibliographicContributorsList.isLoading) {
306306
return;
307307
}
308308

0 commit comments

Comments
 (0)