feat: add expandable rows and accordion details to grid and table views
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<div class="h-full overflow-auto border border-surface-border cardShadow">
|
<div [ngClass]="{ 'h-full overflow-auto': true, 'border border-surface-border cardShadow': hasCaption }">
|
||||||
<div
|
<div
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'px-4': hasCaption,
|
'px-4': hasCaption,
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<div class="grid grid-cols-1 gap-3" [ngClass]="{ 'pt-4': hasCaption }">
|
<div class="grid grid-cols-1 gap-3" [ngClass]="{ 'pt-4': hasCaption }">
|
||||||
@for (item of items; track `gridView_${$index}`) {
|
@for (item of items; track `gridView_${$index}`) {
|
||||||
<div class="card border border-surface-border bg-surface-0! mb-0! rounded-2xl p-4!">
|
<div class="card border border-surface-border bg-surface-0! mb-0! rounded-2xl p-4!">
|
||||||
<div class="listKeyValue">
|
<div [ngClass]="{ listKeyValue: true, 'mb-2': expandable }">
|
||||||
@for (col of columns; track `gridView_${col.field.toString()}_${$index}`) {
|
@for (col of columns; track `gridView_${col.field.toString()}_${$index}`) {
|
||||||
@if (col.type !== "index") {
|
@if (col.type !== "index") {
|
||||||
<app-key-value [label]="col.header" [variant]="col.variant">
|
<app-key-value [label]="col.header" [variant]="col.variant">
|
||||||
@@ -23,6 +23,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@if (expandable) {
|
||||||
|
<p-accordion [unstyled]="true" [value]="['0']">
|
||||||
|
<p-accordion-panel value="0" class="border! rounded-lg! overflow-hidden">
|
||||||
|
<p-accordion-header class="bg-surface-200! text-text-color! py-2!">
|
||||||
|
<ng-template #toggleicon let-active="active">
|
||||||
|
<div class="flex items-center gap-4 w-full">
|
||||||
|
<i [ngClass]="{ 'pi pi-chevron-left text-xs! transition': true, '-rotate-90': active }"></i>
|
||||||
|
جزییات بیشتر
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
</p-accordion-header>
|
||||||
|
<p-accordion-content>
|
||||||
|
<div class="listKeyValue pt-4">
|
||||||
|
@for (col of expandColumns; track `gridView_expand_${col.field.toString()}_${$index}`) {
|
||||||
|
@if (col.type !== "index") {
|
||||||
|
<app-key-value [label]="col.header" [variant]="col.variant">
|
||||||
|
<app-page-data-value
|
||||||
|
[item]="item[expandableItemKey!]"
|
||||||
|
[column]="col"
|
||||||
|
(thumbnailClick)="openThumbnailModal($event)"
|
||||||
|
/>
|
||||||
|
</app-key-value>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</p-accordion-content>
|
||||||
|
</p-accordion-panel>
|
||||||
|
</p-accordion>
|
||||||
|
}
|
||||||
@if (showEdit || showDelete || showDetails) {
|
@if (showEdit || showDelete || showDetails) {
|
||||||
<hr class="my-2" />
|
<hr class="my-2" />
|
||||||
<div class="flex justify-center gap-2 mt-4">
|
<div class="flex justify-center gap-2 mt-4">
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ import {
|
|||||||
signal,
|
signal,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { Accordion, AccordionContent, AccordionHeader, AccordionPanel } from 'primeng/accordion';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import { ButtonModule } from 'primeng/button';
|
||||||
import { DrawerModule } from 'primeng/drawer';
|
import { DrawerModule } from 'primeng/drawer';
|
||||||
import { PaginatorModule } from 'primeng/paginator';
|
import { PaginatorModule } from 'primeng/paginator';
|
||||||
import { SkeletonModule } from 'primeng/skeleton';
|
import { SkeletonModule } from 'primeng/skeleton';
|
||||||
import { TableModule } from 'primeng/table';
|
import { TableModule } from 'primeng/table';
|
||||||
import { KeyValueComponent } from '../key-value.component/key-value.component';
|
import { KeyValueComponent } from '../key-value.component/key-value.component';
|
||||||
import { PageDataValueComponent } from './page-data-value.component';
|
|
||||||
import { IColumn } from './page-data-list.component';
|
import { IColumn } from './page-data-list.component';
|
||||||
|
import { PageDataValueComponent } from './page-data-value.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-data-list-grid-view',
|
selector: 'app-page-data-list-grid-view',
|
||||||
@@ -34,6 +35,10 @@ import { IColumn } from './page-data-list.component';
|
|||||||
DrawerModule,
|
DrawerModule,
|
||||||
KeyValueComponent,
|
KeyValueComponent,
|
||||||
PageDataValueComponent,
|
PageDataValueComponent,
|
||||||
|
Accordion,
|
||||||
|
AccordionPanel,
|
||||||
|
AccordionHeader,
|
||||||
|
AccordionContent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppPageDataListGridView<I = any> {
|
export class AppPageDataListGridView<I = any> {
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
<ng-template #header let-columns>
|
<ng-template #header let-columns>
|
||||||
<tr>
|
<tr>
|
||||||
|
@if (expandable) {
|
||||||
|
<th style="width: 3rem"></th>
|
||||||
|
}
|
||||||
@if (showIndex) {
|
@if (showIndex) {
|
||||||
<th [style]="{ width: '3rem', minWidth: '3rem' }"></th>
|
<th [style]="{ width: '3rem', minWidth: '3rem' }"></th>
|
||||||
}
|
}
|
||||||
@@ -35,14 +38,24 @@
|
|||||||
@if (actionsCount()) {
|
@if (actionsCount()) {
|
||||||
<th type="th" [style]="{ width: `${actionsCount() * 2 + (actionsCount() - 1) * 0.25}rem` }"></th>
|
<th type="th" [style]="{ width: `${actionsCount() * 2 + (actionsCount() - 1) * 0.25}rem` }"></th>
|
||||||
}
|
}
|
||||||
@if (expandable) {
|
|
||||||
<th style="width: 3rem"></th>
|
|
||||||
}
|
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #body let-item let-i="rowIndex" let-expanded="expanded">
|
<ng-template #body let-item let-i="rowIndex" let-expanded="expanded">
|
||||||
<tr>
|
<tr>
|
||||||
|
@if (expandable) {
|
||||||
|
<td>
|
||||||
|
<p-button
|
||||||
|
type="button"
|
||||||
|
pRipple
|
||||||
|
[pRowToggler]="item"
|
||||||
|
[text]="true"
|
||||||
|
[rounded]="true"
|
||||||
|
[plain]="true"
|
||||||
|
[icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-left'"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
}
|
||||||
@if (showIndex) {
|
@if (showIndex) {
|
||||||
<td>
|
<td>
|
||||||
{{ i * (currentPage || 1) + 1 }}
|
{{ i * (currentPage || 1) + 1 }}
|
||||||
@@ -65,20 +78,6 @@
|
|||||||
(details)="details(item)"
|
(details)="details(item)"
|
||||||
></td>
|
></td>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (expandable) {
|
|
||||||
<td>
|
|
||||||
<p-button
|
|
||||||
type="button"
|
|
||||||
pRipple
|
|
||||||
[pRowToggler]="item"
|
|
||||||
[text]="true"
|
|
||||||
[rounded]="true"
|
|
||||||
[plain]="true"
|
|
||||||
[icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-left'"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
}
|
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,9 @@
|
|||||||
[showDelete]="showDelete"
|
[showDelete]="showDelete"
|
||||||
[showDetails]="showDetails"
|
[showDetails]="showDetails"
|
||||||
[hasCaption]="!!(pageTitle || showAdd || filter || showRefresh || moreActions)"
|
[hasCaption]="!!(pageTitle || showAdd || filter || showRefresh || moreActions)"
|
||||||
|
[expandable]="expandable"
|
||||||
|
[expandableItemKey]="expandableItemKey"
|
||||||
|
[expandColumns]="expandColumns"
|
||||||
(onEdit)="edit($event)"
|
(onEdit)="edit($event)"
|
||||||
(onDelete)="remove($event)"
|
(onDelete)="remove($event)"
|
||||||
(onDetails)="details($event)"
|
(onDetails)="details($event)"
|
||||||
|
|||||||
Reference in New Issue
Block a user