Skip to content

Commit

Permalink
TreeTable | Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Nov 20, 2023
1 parent a02fbe4 commit 80bc002
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 33 deletions.
13 changes: 5 additions & 8 deletions src/app/showcase/doc/treetable/accessibilitydoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import { Component, Input } from '@angular/core';

@Component({
selector: 'accessibility-doc',
template: ` <app-developmentsection>
template: `
<app-docsectiontext [title]="title" [id]="id">
<h3>Screen Reader</h3>
<p>
TreeTable uses a <i>treegrid</i> element whose attributes can be extended with the <i>tableProps</i> option. This property allows passing aria roles and attributes like <i>aria-label</i> and <i>aria-describedby</i> to define the table
for readers. Default role of the table is <i>table</i>. Header, body and footer elements use <i>rowgroup</i>, rows use <i>row</i> role, header cells have <i>columnheader</i> and body cells use <i>cell</i> roles. Sortable headers
<p> Default role of the table is <i>table</i>. Header, body and footer elements use <i>rowgroup</i>, rows use <i>row</i> role, header cells have <i>columnheader</i> and body cells use <i>cell</i> roles. Sortable headers
utilizer <i>aria-sort</i> attribute either set to "ascending" or "descending".
</p>
<p>Row elements manage <i>aria-expanded</i> for state along with <i>aria-posinset</i>, <i>aria-setsize</i> and <i>aria-level</i> attribute to define the hierachy.</p>
<p>When selection is enabled, <i>aria-selected</i> is set to true on a row. In checkbox mode, the built-in checkbox component use <i>checkbox</i> role with <i>aria-checked</i> state attribute.</p>
<p>Row elements manage <i>aria-expanded</i> for state and <i>aria-level</i> attribute to define the hierachy by <i>ttRow</i> directive. Table rows and table cells should be specified by users using the <i>aria-posinset</i>, <i>aria-setsize</i>, <i>aria-label</i>, and <i>aria-describedby</i> attributes, as they are determined through templating.</p>
<p>When selection is enabled, <i>ttSelectableRow</i> directive sets <i>aria-selected</i> to true on a row. In checkbox mode, the built-in checkbox component use <i>checkbox</i> role with <i>aria-checked</i> state attribute.</p>
<p>Editable cells use custom templating so you need to manage aria roles and attributes manually if required.</p>
<p>Paginator is a standalone component used inside the TreeTable, refer to the <a href="/paginator/">paginator</a> for more information about the accessibility features.</p>
<h3>Sortable Headers Keyboard Support</h3>
Expand Down Expand Up @@ -90,8 +88,7 @@ import { Component, Input } from '@angular/core';
</tbody>
</table>
</div>
</app-docsectiontext>
</app-developmentsection>`
</app-docsectiontext>`
})
export class AccessibilityDoc {
@Input() id: string;
Expand Down
14 changes: 9 additions & 5 deletions src/app/showcase/doc/treetable/basicdoc.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core';
import { TreeNode } from 'primeng/api';
import { Code } from '../../domain/code';
import { AppDocSectionTextComponent } from '../../layout/doc/docsectiontext/app.docsectiontext.component';
import { NodeService } from '../../service/nodeservice';
import { AppDocSectionTextComponent } from '../../layout/doc/docsectiontext/app.docsectiontext.component';

@Component({
selector: 'basic-doc',
Expand Down Expand Up @@ -32,7 +32,8 @@ import { NodeService } from '../../service/nodeservice';
</p-treeTable>
</div>
<app-code [code]="code" selector="tree-table-basic-demo"></app-code>
</section>`
</section>`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class BasicDoc implements OnInit {
@Input() id: string;
Expand All @@ -43,10 +44,13 @@ export class BasicDoc implements OnInit {

files!: TreeNode[];

constructor(private nodeService: NodeService) {}
constructor(private nodeService: NodeService, private cd: ChangeDetectorRef) {}

ngOnInit() {
this.nodeService.getFilesystem().then((files) => (this.files = files));
this.nodeService.getFilesystem().then((files) => {
this.files = files.slice(0,5)
this.cd.markForCheck();
});
}

code: Code = {
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/doc/treetable/editdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Column {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode">
<td *ngFor="let col of columns; let i = index" ttEditableColumn [ttEditableColumnDisabled]="i == 0" [ngClass]="{ 'p-toggler-column': i === 0 }">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCellEditor>
Expand Down Expand Up @@ -72,7 +72,7 @@ export class EditDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode">
<td *ngFor="let col of columns; let i = index" ttEditableColumn [ttEditableColumnDisabled]="i == 0" [ngClass]="{ 'p-toggler-column': i === 0 }">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCellEditor>
Expand All @@ -97,7 +97,7 @@ export class EditDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode">
<td *ngFor="let col of columns; let i = index" ttEditableColumn [ttEditableColumnDisabled]="i == 0" [ngClass]="{ 'p-toggler-column': i === 0 }">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCellEditor>
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/doc/treetable/selectioncheckboxdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface Column {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCheckbox [value]="rowNode" *ngIf="i === 0"></p-treeTableCheckbox>
Expand Down Expand Up @@ -87,7 +87,7 @@ export class SelectionCheckboxDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCheckbox [value]="rowNode" *ngIf="i === 0"></p-treeTableCheckbox>
Expand All @@ -114,7 +114,7 @@ export class SelectionCheckboxDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr>
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCheckbox [value]="rowNode" *ngIf="i === 0"></p-treeTableCheckbox>
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/doc/treetable/selectionmultipledoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface Column {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand Down Expand Up @@ -84,7 +84,7 @@ export class SelectionMultipleDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand All @@ -108,7 +108,7 @@ export class SelectionMultipleDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand Down
16 changes: 5 additions & 11 deletions src/app/showcase/doc/treetable/selectionsingledoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface Column {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand Down Expand Up @@ -74,9 +74,7 @@ export class SelectionSingleDoc implements OnInit {

code: Code = {
basic: `
<p-inputSwitch [(ngModel)]="metaKeySelection"></p-inputSwitch>
<p-treeTable [value]="files" [columns]="cols" selectionMode="single" [metaKeySelection]="metaKeySelection" [(selection)]="selectedNode" dataKey="name" [scrollable]="true" [tableStyle]="{'min-width':'50rem'}">
<p-treeTable [value]="files" [columns]="cols" selectionMode="single" [(selection)]="selectedNode" dataKey="name" [scrollable]="true" [tableStyle]="{'min-width':'50rem'}">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
Expand All @@ -85,7 +83,7 @@ export class SelectionSingleDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand All @@ -96,11 +94,7 @@ export class SelectionSingleDoc implements OnInit {

html: `
<div class="card">
<div class="flex gap-3 align-items-center justify-content-center mb-4">
<p-inputSwitch [(ngModel)]="metaKeySelection"></p-inputSwitch>
<span>Metakey</span>
</div>
<p-treeTable [value]="files" [columns]="cols" selectionMode="single" [metaKeySelection]="metaKeySelection" [(selection)]="selectedNode" dataKey="name" [scrollable]="true" [tableStyle]="{'min-width':'50rem'}">
<p-treeTable [value]="files" [columns]="cols" selectionMode="single" [(selection)]="selectedNode" dataKey="name" [scrollable]="true" [tableStyle]="{'min-width':'50rem'}">
<ng-template pTemplate="header" let-columns>
<tr>
<th *ngFor="let col of columns">
Expand All @@ -109,7 +103,7 @@ export class SelectionSingleDoc implements OnInit {
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr [ttRow]="rowNode" [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<tr [ttRow]="rowNode" [ttSelectableRow]="rowNode">
<td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
{{ rowData[col.field] }}
Expand Down

0 comments on commit 80bc002

Please sign in to comment.