mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[AAE-7819] Fix for custom header (#7585)
This commit is contained in:
parent
694d71a103
commit
d26204cd9b
@ -196,7 +196,9 @@
|
|||||||
"REPLACE_COLUMNS": "Replace columns",
|
"REPLACE_COLUMNS": "Replace columns",
|
||||||
"LOAD_NODE": "Load Node",
|
"LOAD_NODE": "Load Node",
|
||||||
"MULTISELECT": "Multiselect",
|
"MULTISELECT": "Multiselect",
|
||||||
"MULTISELECT_DESCRIPTION": "Use Cmd (Mac) or Ctrl (Windows) to toggle selection of multiple items"
|
"MULTISELECT_DESCRIPTION": "Use Cmd (Mac) or Ctrl (Windows) to toggle selection of multiple items",
|
||||||
|
"USE_CUSTOM_COLUMN_HEADER": "Use custom template for 'User' header",
|
||||||
|
"CUSTOM_COLUMN_HEADER": "Custom User Header Template"
|
||||||
},
|
},
|
||||||
"ANALYTICS_REPORT": {
|
"ANALYTICS_REPORT": {
|
||||||
"NO_REPORT_MESSAGE": "No report selected. Choose a report from the list"
|
"NO_REPORT_MESSAGE": "No report selected. Choose a report from the list"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
Sticky header
|
Sticky header
|
||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
|
|
||||||
<div style="height: 310px; overflow-y: auto;" data-automation-id="datatable">
|
<div data-automation-id="datatable" class="adf-datatable-demo-app">
|
||||||
<adf-datatable
|
<adf-datatable
|
||||||
#dataTable
|
#dataTable
|
||||||
[data]="data"
|
[data]="data"
|
||||||
@ -40,6 +40,14 @@
|
|||||||
</data-columns>
|
</data-columns>
|
||||||
-->
|
-->
|
||||||
</adf-datatable>
|
</adf-datatable>
|
||||||
|
|
||||||
|
<ng-template #customColumnHeaderTemplate>
|
||||||
|
<div>
|
||||||
|
<span class="adf-datatable-demo-app-custom-user-header">
|
||||||
|
{{ 'DATATABLE.CUSTOM_COLUMN_HEADER'| translate }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@ -49,6 +57,7 @@
|
|||||||
<div data-automation-id="multiselect">
|
<div data-automation-id="multiselect">
|
||||||
<mat-checkbox [(ngModel)]="multiselect">{{ 'DATATABLE.MULTISELECT'| translate }}</mat-checkbox>
|
<mat-checkbox [(ngModel)]="multiselect">{{ 'DATATABLE.MULTISELECT'| translate }}</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>{{ 'DATATABLE.MULTISELECT_DESCRIPTION'| translate }}</p>
|
<p>{{ 'DATATABLE.MULTISELECT_DESCRIPTION'| translate }}</p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
@ -59,9 +68,11 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
|
<div class="adf-datatable-demo-app-actions">
|
||||||
<button mat-raised-button (click)="reset()">{{ 'DATATABLE.RESET_DEFAULT'| translate }}</button>
|
<button mat-raised-button (click)="reset()">{{ 'DATATABLE.RESET_DEFAULT'| translate }}</button>
|
||||||
<button mat-raised-button (click)="addRow()">{{ 'DATATABLE.ADD_ROW'| translate }}</button>
|
<button mat-raised-button (click)="addRow()">{{ 'DATATABLE.ADD_ROW'| translate }}</button>
|
||||||
<button mat-raised-button (click)="replaceRows()">{{ 'DATATABLE.REPLACE_ROWS'| translate }}</button>
|
<button mat-raised-button (click)="replaceRows()">{{ 'DATATABLE.REPLACE_ROWS'| translate }}</button>
|
||||||
<button mat-raised-button (click)="replaceColumns()">{{ 'DATATABLE.REPLACE_COLUMNS'| translate }}</button>
|
<button mat-raised-button (click)="replaceColumns()">{{ 'DATATABLE.REPLACE_COLUMNS'| translate }}</button>
|
||||||
|
<button mat-raised-button (click)="showCustomHeaderColumn()">{{ 'DATATABLE.USE_CUSTOM_COLUMN_HEADER'| translate }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
.adf-datatable-demo-app {
|
||||||
|
height: 310px;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
&-actions {
|
||||||
|
display: flex;
|
||||||
|
column-gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-custom-user-header {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, ViewChild } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
DataCellEvent,
|
DataCellEvent,
|
||||||
DataColumn,
|
DataColumn,
|
||||||
@ -56,17 +56,20 @@ export class FilteredDataAdapter extends ObjectDataTableAdapter {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-datatable',
|
selector: 'app-datatable',
|
||||||
templateUrl: './datatable.component.html'
|
templateUrl: './datatable.component.html',
|
||||||
|
styleUrls: ['./datatable.component.scss']
|
||||||
})
|
})
|
||||||
export class DataTableComponent {
|
export class DataTableComponent {
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
selectionMode = 'single';
|
||||||
|
|
||||||
|
@ViewChild('customColumnHeaderTemplate') customColumnHeaderTemplate;
|
||||||
|
|
||||||
multiselect = false;
|
multiselect = false;
|
||||||
data: FilteredDataAdapter;
|
data: FilteredDataAdapter;
|
||||||
stickyHeader = false;
|
stickyHeader = false;
|
||||||
|
|
||||||
@Input()
|
|
||||||
selectionMode = 'single';
|
|
||||||
|
|
||||||
selectionModes = [
|
selectionModes = [
|
||||||
{ value: 'none', viewValue: 'None' },
|
{ value: 'none', viewValue: 'None' },
|
||||||
{ value: 'single', viewValue: 'Single' },
|
{ value: 'single', viewValue: 'Single' },
|
||||||
@ -298,6 +301,21 @@ export class DataTableComponent {
|
|||||||
this.data.setColumns(columns);
|
this.data.setColumns(columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showCustomHeaderColumn() {
|
||||||
|
const columns = this.data.getColumns().map(column => {
|
||||||
|
if (column.title === 'Users') {
|
||||||
|
return {
|
||||||
|
...column,
|
||||||
|
header: this.customColumnHeaderTemplate
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return column;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.data.setColumns(columns);
|
||||||
|
}
|
||||||
|
|
||||||
onShowRowActionsMenu(event: DataCellEvent) {
|
onShowRowActionsMenu(event: DataCellEvent) {
|
||||||
const myAction = {
|
const myAction = {
|
||||||
title: 'Hello'
|
title: 'Hello'
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
adf-drop-zone dropTarget="header" [dropColumn]="col">
|
adf-drop-zone dropTarget="header" [dropColumn]="col">
|
||||||
|
|
||||||
<div
|
<div
|
||||||
*ngIf="!col.header"
|
|
||||||
[attr.data-automation-id]="'auto_header_content_id_' + col.key"
|
[attr.data-automation-id]="'auto_header_content_id_' + col.key"
|
||||||
class="adf-datatable-cell-header-content"
|
class="adf-datatable-cell-header-content"
|
||||||
[class.adf-datatable-cell-header-content--hovered]="hoveredHeaderColumnIndex === columnIndex && !isDraggingHeaderColumn"
|
[class.adf-datatable-cell-header-content--hovered]="hoveredHeaderColumnIndex === columnIndex && !isDraggingHeaderColumn"
|
||||||
@ -59,11 +58,17 @@
|
|||||||
[attr.data-automation-id]="'adf-datatable-cell-header-drag-icon-placeholder-'+col.key"
|
[attr.data-automation-id]="'adf-datatable-cell-header-drag-icon-placeholder-'+col.key"
|
||||||
></span>
|
></span>
|
||||||
|
|
||||||
<span *ngIf="col.title" class="adf-datatable-cell-value">{{col.title | translate}}</span>
|
<ng-container *ngIf="!col.header">
|
||||||
|
<span *ngIf="col.title" class="adf-datatable-cell-value">{{col.title | translate}}</span>
|
||||||
|
|
||||||
<span *ngIf="col.title && col.sortable && isDraggingHeaderColumn" class="adf-sr-only" aria-live="polite">
|
<span *ngIf="col.title && col.sortable && isDraggingHeaderColumn" class="adf-sr-only" aria-live="polite">
|
||||||
{{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }}
|
{{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }}
|
||||||
</span>
|
</span>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<div *ngIf="col.header" class="adf-datatable-cell-value">
|
||||||
|
<ng-template [ngTemplateOutlet]="col.header" [ngTemplateOutletContext]="{$implicit: col}"></ng-template>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ng-template *ngIf="allowFiltering" [ngTemplateOutlet]="headerFilterTemplate" [ngTemplateOutletContext]="{$implicit: col}"></ng-template>
|
<ng-template *ngIf="allowFiltering" [ngTemplateOutlet]="headerFilterTemplate" [ngTemplateOutletContext]="{$implicit: col}"></ng-template>
|
||||||
|
|
||||||
@ -73,8 +78,6 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-template *ngIf="col.header" [ngTemplateOutlet]="col.header" [ngTemplateOutletContext]="{$implicit: col}"></ng-template>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
*ngIf="col.draggable"
|
*ngIf="col.draggable"
|
||||||
cdkDragHandle
|
cdkDragHandle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user