feat(directory-picker): add selection actions for folders, add buttons for select all, deselect all, and select current folder (#2293)

Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
Balázs Szücs
2026-01-18 18:31:04 -07:00
committed by GitHub
parent f1f16a98d8
commit 3b56294d1c
4 changed files with 115 additions and 9 deletions
@@ -651,7 +651,9 @@
gap: 0.5rem;
max-height: 400px;
overflow-y: auto;
overflow-x: hidden;
padding-right: 0.25rem;
width: 100%;
&::-webkit-scrollbar {
width: 6px;
@@ -685,6 +687,10 @@
border: 1px solid var(--border-color);
border-radius: 8px;
transition: all 0.3s ease;
width: 100%;
max-width: 100%;
overflow: hidden;
min-height: 70px;
&:hover {
border-color: var(--primary-color);
@@ -702,6 +708,7 @@
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
.folder-icon-wrapper {
display: flex;
@@ -711,6 +718,7 @@
height: 38px;
background: var(--overlay-background);
border-radius: 8px;
flex-shrink: 0;
.folder-icon {
font-size: 1.125rem;
@@ -741,8 +749,9 @@
flex: 1;
display: flex;
flex-direction: column;
gap: 0.25rem;
gap: 0.375rem;
min-width: 0;
overflow: hidden;
.folder-path {
font-size: 0.9rem;
@@ -751,6 +760,8 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100%;
line-height: 1.3;
}
.folder-meta {
@@ -759,19 +770,27 @@
gap: 0.25rem;
font-size: 0.75rem;
color: var(--text-secondary-color);
line-height: 1.3;
i {
font-size: 0.6875rem;
flex-shrink: 0;
}
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
flex: 1;
}
}
}
::ng-deep .p-button {
flex-shrink: 0;
}
@media (max-width: 640px) {
flex-direction: column;
align-items: flex-start;
@@ -44,6 +44,42 @@
/>
</div>
<div class="selection-actions">
<p-button
label="Select All"
icon="pi pi-check-square"
severity="secondary"
[outlined]="true"
size="small"
(click)="selectAll()"
[disabled]="filteredPaths.length === 0"
pTooltip="Select all visible folders"
tooltipPosition="bottom"
/>
<p-button
label="Deselect All"
icon="pi pi-times-circle"
severity="secondary"
[outlined]="true"
size="small"
(click)="deselectAll()"
[disabled]="selectedFolders.length === 0"
pTooltip="Clear all selections"
tooltipPosition="bottom"
/>
<p-button
label="Select Current"
icon="pi pi-folder"
severity="info"
[outlined]="true"
size="small"
(click)="selectCurrent()"
[disabled]="!selectedProductName || selectedProductName === '/'"
pTooltip="Select the current directory"
tooltipPosition="bottom"
/>
</div>
@if (selectedFolders.length > 0) {
<div class="selection-badge">
<i class="pi pi-check-circle"></i>
@@ -14,10 +14,13 @@
max-width: 700px;
display: flex;
flex-direction: column;
height: 80vh;
max-height: 900px;
@media (max-width: 640px) {
width: 100%;
max-width: 100%;
height: 90vh;
}
}
@@ -98,6 +101,21 @@
}
}
.selection-actions {
display: flex;
gap: 0.5rem;
align-items: center;
@media (max-width: 640px) {
flex-direction: column;
width: 100%;
::ng-deep .p-button {
width: 100%;
}
}
}
.selection-badge {
display: flex;
align-items: center;
@@ -145,14 +163,12 @@
border: 1px solid var(--border-color);
border-top: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
min-height: 500px;
max-height: 500px;
flex: 1;
min-height: 0;
overflow: hidden;
@media (max-width: 480px) {
padding: 1rem;
min-height: 300px;
max-height: 400px;
}
}
@@ -278,11 +294,13 @@
flex-direction: column;
gap: 0.5rem;
overflow-y: auto;
overflow-x: hidden;
flex: 1;
padding-right: 0.25rem;
min-height: 0;
opacity: 1;
transition: opacity 0.3s ease-in-out;
width: 100%;
&.loading {
opacity: 0;
@@ -330,7 +348,7 @@
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
padding: 0.875rem 1rem;
background: var(--ground-background);
border: 1px solid var(--border-color);
border-radius: 8px;
@@ -338,6 +356,10 @@
cursor: pointer;
opacity: 0;
animation: fadeInItem 0.3s ease-out forwards;
width: 100%;
max-width: 100%;
overflow: hidden;
min-height: 70px;
@for $i from 1 through 20 {
&:nth-child(#{$i}) {
@@ -407,8 +429,9 @@
flex: 1;
display: flex;
flex-direction: column;
gap: 0.25rem;
gap: 0.375rem;
min-width: 0;
overflow: hidden;
.directory-name {
font-size: 0.9375rem;
@@ -417,6 +440,8 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100%;
line-height: 1.3;
}
.directory-path {
@@ -426,6 +451,8 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100%;
line-height: 1.3;
}
}
@@ -478,8 +505,8 @@
}
.dialog-footer {
@include panel.dialog-footer;
border-top: none;
@include panel.dialog-footer;
border-top: 1px solid var(--border-color);
.selection-info {
display: flex;
@@ -150,6 +150,30 @@ export class DirectoryPickerComponent implements OnInit {
this.dynamicDialogRef.close(null);
}
selectAll(): void {
this.filteredPaths.forEach(folder => {
if (!this.selectedFolders.includes(folder)) {
this.selectedFolders.push(folder);
}
this.selectedFoldersMap[folder] = true;
});
}
deselectAll(): void {
this.selectedFolders = [];
Object.keys(this.selectedFoldersMap).forEach(key => {
this.selectedFoldersMap[key] = false;
});
}
selectCurrent(): void {
const currentPath = this.selectedProductName || '/';
if (!this.selectedFolders.includes(currentPath)) {
this.selectedFolders.push(currentPath);
}
this.selectedFoldersMap[currentPath] = true;
}
getFolderName(path: string): string {
return path.split('/').filter(p => p).pop() || path;
}