Skip to content
Snippets Groups Projects
Commit fc59cdfe authored by Florent Poittevin's avatar Florent Poittevin
Browse files

Allow to disable sort and filter feature for each column of a table

parent 6b041e88
No related branches found
No related tags found
1 merge request!20Fpo/fix access errors
...@@ -51,10 +51,38 @@ export class AccessView extends BaseDirective implements OnInit { ...@@ -51,10 +51,38 @@ export class AccessView extends BaseDirective implements OnInit {
// TODO Use typeof to get interface propertie name // TODO Use typeof to get interface propertie name
this.columns = [ this.columns = [
{field: "organizationalUnit", header: TRANSLATE("access.table.header.organizationalUnit"), type: FieldTypeEnum.string, order: 0}, {
{field: "title", header: TRANSLATE("access.table.header.title"), type: FieldTypeEnum.string, order: 0}, field: "organizationalUnit",
{field: "yearPublicationDate", header: TRANSLATE("access.table.header.yearPublicationDate"), type: FieldTypeEnum.number, order: 0}, header: TRANSLATE("access.table.header.organizationalUnit"),
{field: "accessLevel", header: TRANSLATE("access.table.header.accessLevel"), type: FieldTypeEnum.string, order: 0}, type: FieldTypeEnum.string,
order: 0,
isSortable: false,
isFilterable: false,
},
{
field: "title",
header: TRANSLATE("access.table.header.title"),
type: FieldTypeEnum.string,
order: 0,
isSortable: false,
isFilterable: false,
},
{
field: "yearPublicationDate",
header: TRANSLATE("access.table.header.yearPublicationDate"),
type: FieldTypeEnum.number,
order: 0,
isSortable: false,
isFilterable: false,
},
{
field: "accessLevel",
header: TRANSLATE("access.table.header.accessLevel"),
type: FieldTypeEnum.string,
order: 0,
isSortable: false,
isFilterable: false,
},
]; ];
this.addToSubscription( this.addToSubscription(
......
...@@ -25,11 +25,46 @@ export class ListView extends AbstractListView<DepositsModel, DepositStateModel> ...@@ -25,11 +25,46 @@ export class ListView extends AbstractListView<DepositsModel, DepositStateModel>
defineColumns() { defineColumns() {
// TODO Use typeof to get interface propertie name // TODO Use typeof to get interface propertie name
this.columns = [ this.columns = [
{field: "title", header: TRANSLATE("deposit.table.header.title"), type: FieldTypeEnum.string, order: 0}, {
{field: "publicationDate", header: TRANSLATE("deposit.table.header.publicationDate"), type: FieldTypeEnum.date, order: 0}, field: "title",
{field: "creation.when", header: TRANSLATE("deposit.table.header.creation.when"), type: FieldTypeEnum.datetime, order: 0}, header: TRANSLATE("deposit.table.header.title"),
{field: "lastUpdate.when", header: TRANSLATE("deposit.table.header.lastUpdate.when"), type: FieldTypeEnum.datetime, order: 0}, type: FieldTypeEnum.string,
{field: "status", header: TRANSLATE("deposit.table.header.status"), type: FieldTypeEnum.string, order: 0}, order: 0,
isFilterable: true,
isSortable: true,
},
{
field: "publicationDate",
header: TRANSLATE("deposit.table.header.publicationDate"),
type: FieldTypeEnum.date,
order: 0,
isFilterable: true,
isSortable: true,
},
{
field: "creation.when",
header: TRANSLATE("deposit.table.header.creation.when"),
type: FieldTypeEnum.datetime,
order: 0,
isFilterable: true,
isSortable: true,
},
{
field: "lastUpdate.when",
header: TRANSLATE("deposit.table.header.lastUpdate.when"),
type: FieldTypeEnum.datetime,
order: 0,
isFilterable: true,
isSortable: true,
},
{
field: "status",
header: TRANSLATE("deposit.table.header.status"),
type: FieldTypeEnum.string,
order: 0,
isFilterable: true,
isSortable: true,
},
]; ];
} }
} }
import {ChangeDetectionStrategy, Component} from "@angular/core"; import {ChangeDetectionStrategy, Component} from "@angular/core";
import {OrganizationalUnitsModel} from "@app/generated-api"; import {OrganizationalUnitsModel} from "@app/generated-api";
import {OrganizationalUnitStateModel} from "@app/shared/organizational-unit.state";
import {FieldTypeEnum} from "@app/shared/enums/field-type.enum"; import {FieldTypeEnum} from "@app/shared/enums/field-type.enum";
import {StateEnum} from "@app/shared/enums/state.enum"; import {StateEnum} from "@app/shared/enums/state.enum";
import {OrganizationalUnitStateModel} from "@app/shared/organizational-unit.state";
import {TRANSLATE} from "@app/shared/utils/translate.util"; import {TRANSLATE} from "@app/shared/utils/translate.util";
import {AbstractListView} from "@app/shared/views/abstract-list/abstract-list.view"; import {AbstractListView} from "@app/shared/views/abstract-list/abstract-list.view";
import {TranslateService} from "@ngx-translate/core"; import {TranslateService} from "@ngx-translate/core";
...@@ -27,17 +27,27 @@ export class ListView extends AbstractListView<OrganizationalUnitsModel, Organiz ...@@ -27,17 +27,27 @@ export class ListView extends AbstractListView<OrganizationalUnitsModel, Organiz
this.columns = [ this.columns = [
{ {
field: "name", field: "name",
header: TRANSLATE("organizationalUnit.table.header.name"), type: FieldTypeEnum.string, order: -1, header: TRANSLATE("organizationalUnit.table.header.name"),
type: FieldTypeEnum.string,
order: -1,
isFilterable: true,
isSortable: true,
}, },
{ {
field: "description", field: "description",
header: TRANSLATE("organizationalUnit.table.header.description"), type: FieldTypeEnum.string, order: 0, header: TRANSLATE("organizationalUnit.table.header.description"),
type: FieldTypeEnum.string,
order: 0,
isFilterable: true,
isSortable: true,
}, },
{ {
field: "creation.when", field: "creation.when",
header: TRANSLATE("organizationalUnit.table.header.creation.when"), header: TRANSLATE("organizationalUnit.table.header.creation.when"),
type: FieldTypeEnum.datetime, type: FieldTypeEnum.datetime,
order: 0, order: 0,
isFilterable: true,
isSortable: true,
}, },
]; ];
} }
......
...@@ -11,26 +11,30 @@ ...@@ -11,26 +11,30 @@
<ng-template pTemplate="header" let-columns> <ng-template pTemplate="header" let-columns>
<tr> <tr>
<th *ngFor="let col of columns" <th *ngFor="let col of columns"
[pSortableColumn]="col.field"> [pSortableColumn]="col.isSortable ? col.field : false"
[class.sortable-column]="col.isSortable"
>
{{col.header | translate}} {{col.header | translate}}
<p-sortIcon [field]="col.field"></p-sortIcon> <p-sortIcon *ngIf="col.isSortable" [field]="col.field"></p-sortIcon>
</th> </th>
</tr> </tr>
<tr> <tr>
<th *ngFor="let col of columns" [ngSwitch]="col.type" class="data-table-filter"> <th *ngFor="let col of columns" [ngSwitch]="col.type" class="data-table-filter">
<div *ngSwitchCase="fieldTypeString" class="filter-text"> <ng-container *ngIf="col.isFilterable">
<!-- <mat-form-field style="width: 100%" [floatLabel]="'never'">--> <div *ngSwitchCase="fieldTypeString" class="filter-text">
<!-- <input #filter matInput (keyup)="onValueChange(col, $event.target.value)" [value]="getValue(col.field)">--> <!-- <mat-form-field style="width: 100%" [floatLabel]="'never'">-->
<!-- <button mat-button *ngIf="filter.value" matSuffix mat-icon-button aria-label="Clear" (click)="filter.value='';onValueChange(col, filter.value)">--> <!-- <input #filter matInput (keyup)="onValueChange(col, $event.target.value)" [value]="getValue(col.field)">-->
<!-- <fa-icon matSuffix icon="times"></fa-icon>--> <!-- <button mat-button *ngIf="filter.value" matSuffix mat-icon-button aria-label="Clear" (click)="filter.value='';onValueChange(col, filter.value)">-->
<!-- </button>--> <!-- <fa-icon matSuffix icon="times"></fa-icon>-->
<!-- </mat-form-field>--> <!-- </button>-->
<!-- </mat-form-field>-->
<input type="text "#filter (keyup)="onValueChange(col, $event.target.value)" [value]="getValue(col.field)"> <input type="text " #filter (keyup)="onValueChange(col, $event.target.value)" [value]="getValue(col.field)">
<button mat-button *ngIf="filter.value" matSuffix mat-icon-button aria-label="Clear" (click)="filter.value='';onValueChange(col, filter.value)"> <button mat-button *ngIf="filter.value" matSuffix mat-icon-button aria-label="Clear" (click)="filter.value='';onValueChange(col, filter.value)">
<fa-icon matSuffix icon="times"></fa-icon> <fa-icon matSuffix icon="times"></fa-icon>
</button> </button>
</div> </div>
</ng-container>
</th> </th>
</tr> </tr>
</ng-template> </ng-template>
......
...@@ -78,7 +78,15 @@ $inputGroupTextColor: #444444; ...@@ -78,7 +78,15 @@ $inputGroupTextColor: #444444;
.ui-table .ui-sortable-column:not(.ui-state-highlight):hover { .ui-table .ui-sortable-column:not(.ui-state-highlight):hover {
background-color: $headerBgColor !important; background-color: $headerBgColor !important;
color: $headerTextColor !important; color: $headerTextColor !important;
text-decoration: underline; cursor: default;
}
.sortable-column {
cursor: pointer !important;
&:hover {
text-decoration: underline;
}
} }
.ui-table .ui-sortable-column:not(.ui-state-highlight):hover .ui-sortable-column-icon { .ui-table .ui-sortable-column:not(.ui-state-highlight):hover .ui-sortable-column-icon {
......
...@@ -5,4 +5,6 @@ export interface DataTableColumnsModel { ...@@ -5,4 +5,6 @@ export interface DataTableColumnsModel {
header: string; header: string;
type?: FieldTypeEnum; type?: FieldTypeEnum;
order: number; order: number;
isSortable?: boolean;
isFilterable?: boolean;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment