ngx-redi-core 1.2.4 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -21
- package/{projects/ngx-redi-core/RediTable → RediForms}/src/modules/redi-table/redi-table.component.html +1 -1
- package/{projects/ngx-redi-core/RediTable → RediForms}/src/modules/redi-table/redi-table.component.ts +3 -3
- package/{projects/ngx-redi-core/RediTable/index.ts → RediTable/public-api.ts} +0 -3
- package/RediTable/src/modules/redi-table/redi-table.component.css +106 -0
- package/RediTable/src/modules/redi-table/redi-table.component.html +70 -0
- package/RediTable/src/modules/redi-table/redi-table.component.spec.ts +162 -0
- package/RediTable/src/modules/redi-table/redi-table.component.ts +322 -0
- package/RediTable/src/modules/redi-table.module.ts +32 -0
- package/RediUI/index.ts +2 -0
- package/RediUI/ng-package.json +6 -0
- package/RediUI/public-api.ts +9 -0
- package/RediUI/src/models/interfaces/column-definition.ts +14 -0
- package/RediUI/src/models/interfaces/data-table.ts +28 -0
- package/RediUI/src/models/interfaces/row-action.ts +32 -0
- package/RediUI/src/models/types/event-table.type.spec.ts +7 -0
- package/RediUI/src/models/types/event-table.type.ts +3 -0
- package/RediUI/src/modules/redi-table/redi-table.component.css +106 -0
- package/RediUI/src/modules/redi-table/redi-table.component.html +70 -0
- package/RediUI/src/modules/redi-table/redi-table.component.spec.ts +162 -0
- package/RediUI/src/modules/redi-table/redi-table.component.ts +322 -0
- package/RediUI/src/modules/redi-table.module.ts +32 -0
- package/Security/index.ts +2 -0
- package/Security/ng-package.json +6 -0
- package/{projects/ngx-redi-core/Security → Security}/public-api.ts +2 -1
- package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/interceptors/redi-secure.interceptor.spec.ts +16 -15
- package/Security/src/modules/security-web-intercept/services/cifrado-basico.service.spec.ts +16 -0
- package/Security/src/modules/security-web-intercept/services/cifrado-basico.service.ts +53 -0
- package/index.ts +2 -0
- package/package.json +18 -34
- package/{projects/ngx-redi-core/tsconfig.lib.json → tsconfig.lib.json} +1 -1
- package/.editorconfig +0 -16
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/tasks.json +0 -42
- package/angular.json +0 -45
- package/projects/ngx-redi-core/README.md +0 -22
- package/projects/ngx-redi-core/package-lock.json +0 -1110
- package/projects/ngx-redi-core/package.json +0 -37
- package/tsconfig.json +0 -41
- /package/{projects/ngx-redi-core/Helper → Helper}/index.ts +0 -0
- /package/{projects/ngx-redi-core/Helper → Helper}/ng-package.json +0 -0
- /package/{projects/ngx-redi-core/Helper → Helper}/public-api.ts +0 -0
- /package/{projects/ngx-redi-core/Helper → Helper}/src/helpers/csv.service.spec.ts +0 -0
- /package/{projects/ngx-redi-core/Helper → Helper}/src/helpers/csv.service.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/index.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/ng-package.json +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/public-api.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/assets/cloud.svg +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/assets/documento.svg +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/assets/lista.svg +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/models/classes/proceso-archivo-csv.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/models/classes/proceso-archivo-csv.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/models/directives/drag-drop.directive.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/models/directives/drag-drop.directive.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/modules/redi-drag-drop/redi-drag-drop.component.html +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/modules/redi-drag-drop/redi-drag-drop.component.scss +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/modules/redi-drag-drop/redi-drag-drop.component.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/modules/redi-drag-drop/redi-drag-drop.component.ts +0 -0
- /package/{projects/ngx-redi-core/RediDragDrop → RediDragDrop}/src/modules/redi-drag-drop.module.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediForms}/index.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediForms}/ng-package.json +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediForms}/public-api.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediForms}/src/modules/redi-table/redi-table.component.css +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediForms}/src/modules/redi-table/redi-table.component.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediForms}/src/modules/redi-table.module.ts +0 -0
- /package/{projects/ngx-redi-core/Security → RediGrid}/index.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediGrid}/ng-package.json +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/public-api.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/models/interfaces/cell.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/models/interfaces/data-grid.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/modules/redi-grid/redi-grid.component.css +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/modules/redi-grid/redi-grid.component.html +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/modules/redi-grid/redi-grid.component.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/modules/redi-grid/redi-grid.component.ts +0 -0
- /package/{projects/ngx-redi-core/RediGrid → RediGrid}/src/modules/redi-grid.module.ts +0 -0
- /package/{projects/ngx-redi-core → RediTable}/index.ts +0 -0
- /package/{projects/ngx-redi-core/Security → RediTable}/ng-package.json +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediTable}/src/models/interfaces/column-definition.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediTable}/src/models/interfaces/data-table.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediTable}/src/models/interfaces/row-action.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediTable}/src/models/types/event-table.type.spec.ts +0 -0
- /package/{projects/ngx-redi-core/RediTable → RediTable}/src/models/types/event-table.type.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/interceptors/redi-secure.interceptor.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/models/secure-factory.model.spec.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/models/secure-factory.model.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/models/tipo-operacion.enum.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/services/cifrado.service.spec.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/services/cifrado.service.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/services/reflection.service.spec.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security-web-intercept/services/reflection.service.ts +0 -0
- /package/{projects/ngx-redi-core/Security → Security}/src/modules/security.module.ts +0 -0
- /package/{projects/ngx-redi-core/karma.conf → karma.conf} +0 -0
- /package/{projects/ngx-redi-core/ng-package.json → ng-package.json} +0 -0
- /package/{projects/ngx-redi-core/public-api.ts → public-api.ts} +0 -0
- /package/{projects/ngx-redi-core/tsconfig.lib.prod.json → tsconfig.lib.prod.json} +0 -0
- /package/{projects/ngx-redi-core/tsconfig.spec.json → tsconfig.spec.json} +0 -0
package/README.md
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
# BazRedi
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# NgxRediCore
|
|
3
|
+
Esta librería fue generada con [Angular CLI](https://www.npmjs.com/package/@angular/cli) version 15.2.8.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Los componentes internos que componen ngx-redi-core son:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- RediDragDrop: Componente Drag&Drop para la carga de archivos
|
|
8
|
+
- RediGrid: Componente Grid que presenta la información en una hoja de cálculo
|
|
9
|
+
- RediTable: Componente Tabla que ordena registros interactivos en una tabla con ordenamiento, paginación, filtros y acciones
|
|
10
|
+
- RediSecureInterceptor: Interceptor de seguridad para cifrado y descifrado de peticiones Web
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Estructura del proyecto
|
|
13
|
+
El proyecto se encuentra separado en módulos que contienen la funcionalidad específica de cada componente.
|
|
14
|
+
Cada módulo del proyecto representa un entrypoint para el acceso para la API pública, los entrypoints de referencia son:
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
ngx-redi-core/RediTable
|
|
17
|
+
ngx-redi-core/RediGrid
|
|
18
|
+
ngx-redi-core/RediDragDrop
|
|
19
|
+
ngx-redi-core/Security
|
|
12
20
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
16
|
-
|
|
17
|
-
## Running unit tests
|
|
18
|
-
|
|
19
|
-
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
20
|
-
|
|
21
|
-
## Running end-to-end tests
|
|
22
|
-
|
|
23
|
-
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
|
24
|
-
|
|
25
|
-
## Further help
|
|
26
|
-
|
|
27
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
21
|
+
## Importación
|
|
22
|
+
Para importar en un proyecto se ejecutará el siguiente comando `npm install ngx-redi-core`, adicional se deberá incluir la importación en el Módulo sobre el modulo del entrypoint expuesto que se desee importar (https://angular.io/guide/architecture-modules)
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
<tr mat-header-row *matHeaderRowDef="columnas; sticky:true"></tr>
|
|
59
59
|
<!-- Estilizados alternado de filas -->
|
|
60
60
|
<tr mat-row *matRowDef="let row; columns: columnas;let rowNum = index" [class.odd]="rowNum%2"
|
|
61
|
-
[class.even]="!(rowNum%2)" (click)="onRowSelect(
|
|
61
|
+
[class.even]="!(rowNum%2)" (click)="onRowSelect(row)"></tr>
|
|
62
62
|
</table>
|
|
63
63
|
</div>
|
|
64
64
|
<!-- Paginador de datos -->
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Librerías angular */
|
|
2
|
-
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
|
|
2
|
+
import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
|
|
3
3
|
import { MatPaginator } from '@angular/material/paginator';
|
|
4
4
|
import { MatSort } from '@angular/material/sort';
|
|
5
5
|
import { MatTableDataSource } from '@angular/material/table';
|
|
@@ -295,12 +295,12 @@ export class RediTableComponent<T extends object> implements OnInit, OnChanges {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
public onRowSelect(event:
|
|
298
|
+
public onRowSelect(event: T) {
|
|
299
299
|
this.onRowClick.emit(event);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
@Output()
|
|
303
|
-
public onRowClick = new EventEmitter<
|
|
303
|
+
public onRowClick = new EventEmitter<T>();
|
|
304
304
|
|
|
305
305
|
|
|
306
306
|
protected deshabilitarAccion(action: RowAction<T>, element: any) {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: grid;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
tbody {
|
|
6
|
+
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.section {
|
|
10
|
+
overflow: auto;
|
|
11
|
+
height: 300px;
|
|
12
|
+
background-color: white;
|
|
13
|
+
max-height: 90vh;
|
|
14
|
+
border: 1px solid #f4f4f4;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
table {
|
|
18
|
+
width: 100%;
|
|
19
|
+
color: #676a6f;
|
|
20
|
+
|
|
21
|
+
overflow: auto;
|
|
22
|
+
|
|
23
|
+
padding: 0px;
|
|
24
|
+
background-color: #f7f7f7;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.odd {
|
|
28
|
+
background-color: #f4f4f4;
|
|
29
|
+
|
|
30
|
+
font-size: 1.05em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.even {
|
|
34
|
+
background-color: white;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.odd,
|
|
38
|
+
.even {
|
|
39
|
+
height: 2.5em;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
td.mat-cell {
|
|
44
|
+
border: 0px;
|
|
45
|
+
color: #676a6f;
|
|
46
|
+
font-size: 1.05em;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.odd:hover,
|
|
50
|
+
.even:hover {
|
|
51
|
+
background-color: #cddce9;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
th {
|
|
55
|
+
font-size: 1.2em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
tr.mat-header-row {
|
|
59
|
+
height: 2.55em;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input {
|
|
63
|
+
min-width: 250px;
|
|
64
|
+
border: solid 2px #dadada;
|
|
65
|
+
float: right;
|
|
66
|
+
margin-bottom: 8px;
|
|
67
|
+
outline: 0;
|
|
68
|
+
padding-right: 2em;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mat-icon{
|
|
72
|
+
color: #676a6f;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.icon {
|
|
76
|
+
float: right;
|
|
77
|
+
margin-left: -3em;
|
|
78
|
+
position: relative;
|
|
79
|
+
margin-top: 1px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.visible {
|
|
83
|
+
display: contents;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.hidden {
|
|
87
|
+
display: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
::-webkit-scrollbar {
|
|
91
|
+
width: 6px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
::-webkit-scrollbar-track {
|
|
95
|
+
background: #cccccc;
|
|
96
|
+
margin-top: 2.6em;
|
|
97
|
+
margin-bottom: 1.4em;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
caption {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.disabled-button{
|
|
105
|
+
color: #cecece;
|
|
106
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!-- Contenedor principal del componente -->
|
|
2
|
+
<div class="container">
|
|
3
|
+
<!-- Filtro de datos para la tabla -->
|
|
4
|
+
<div *ngIf="filtrarDatos">
|
|
5
|
+
<mat-icon class="icon"> search </mat-icon>
|
|
6
|
+
<input #filtroInput placeholder="Filtro" (keyup)="applyFilter(filtroInput.value)" />
|
|
7
|
+
</div>
|
|
8
|
+
<!-- Tabla de datos -->
|
|
9
|
+
<div class="section">
|
|
10
|
+
<table mat-table [dataSource]="dataSource" matSort>
|
|
11
|
+
<caption> RediTableComponent </caption>
|
|
12
|
+
<!-- Contenedor de selección -->
|
|
13
|
+
<ng-container *ngIf="seleccionarFilas" matColumnDef="select">
|
|
14
|
+
<!-- Encabezado de tabla con selección de registros -->
|
|
15
|
+
<th scope="col" mat-header-cell *matHeaderCellDef>
|
|
16
|
+
<!-- controles de selección -->
|
|
17
|
+
<mat-checkbox (change)="$event ? alternarSeleccion() : null"
|
|
18
|
+
[checked]="dataTable.seleccion.hasValue() && todoSeleccionado()"
|
|
19
|
+
[indeterminate]="dataTable.seleccion.hasValue() && !todoSeleccionado()">
|
|
20
|
+
</mat-checkbox>
|
|
21
|
+
</th>
|
|
22
|
+
<!-- Selector de fila -->
|
|
23
|
+
<td mat-cell *matCellDef="let row">
|
|
24
|
+
<mat-checkbox (change)="$event ? dataTable.seleccion.toggle(row) : null"
|
|
25
|
+
[checked]="dataTable.seleccion.isSelected(row)" [aria-label]="validarEtiqueta(row)">
|
|
26
|
+
</mat-checkbox>
|
|
27
|
+
</td>
|
|
28
|
+
</ng-container>
|
|
29
|
+
<!-- Ordenamiento de encabezados -->
|
|
30
|
+
<ng-container>
|
|
31
|
+
<ng-container [matColumnDef]="column.identificador" *ngFor="let column of datosColumna">
|
|
32
|
+
<!-- Definición de encabezado por columna -->
|
|
33
|
+
<th scope="col" mat-header-cell *matHeaderCellDef mat-sort-header
|
|
34
|
+
[attr.disabled]="ordenamientoActivo()">
|
|
35
|
+
{{column.etiqueta ||
|
|
36
|
+
column.identificador}} </th>
|
|
37
|
+
<!-- Creación de identificadores de tabla -->
|
|
38
|
+
<td mat-cell *matCellDef="let element"> {{element[column.identificador]}} </td>
|
|
39
|
+
</ng-container>
|
|
40
|
+
</ng-container>
|
|
41
|
+
<!-- Definición de acciones -->
|
|
42
|
+
<ng-container *ngIf="verAcciones()" matColumnDef="actions" stickyEnd>
|
|
43
|
+
<th scope="col" mat-header-cell *matHeaderCellDef aria-label="row actions"> </th>
|
|
44
|
+
<!-- Definición de acciones por fila -->
|
|
45
|
+
<td mat-cell *matCellDef="let element">
|
|
46
|
+
<!-- Configuración de botones de acción -->
|
|
47
|
+
<button mat-icon-button color="primary" *ngFor="let action of dataTable.acciones"
|
|
48
|
+
(click)="action?.emiter?.emit({target:element,source:dataSource})"
|
|
49
|
+
[disabled]="deshabilitarAccion(action,element)">
|
|
50
|
+
<!-- Icono dinámico de la acción -->
|
|
51
|
+
<mat-icon [ngClass]="deshabilitarAccion(action,element) ? 'disabled-button' : ''">
|
|
52
|
+
{{action.icono || 'apps'}}
|
|
53
|
+
</mat-icon>
|
|
54
|
+
</button>
|
|
55
|
+
</td>
|
|
56
|
+
</ng-container>
|
|
57
|
+
<!-- Definición de columnas -->
|
|
58
|
+
<tr mat-header-row *matHeaderRowDef="columnas; sticky:true"></tr>
|
|
59
|
+
<!-- Estilizados alternado de filas -->
|
|
60
|
+
<tr mat-row *matRowDef="let row; columns: columnas;let rowNum = index" [class.odd]="rowNum%2"
|
|
61
|
+
[class.even]="!(rowNum%2)" (click)="onRowSelect(row)"></tr>
|
|
62
|
+
</table>
|
|
63
|
+
</div>
|
|
64
|
+
<!-- Paginador de datos -->
|
|
65
|
+
<div [ngClass]="paginar ? 'visible' : 'hidden'">
|
|
66
|
+
<!-- Configuración de Paginador -->
|
|
67
|
+
<mat-paginator [pageSizeOptions]="[5,10,20,50,100]" showFirstLastButtons aria-label="Seleccione una pagina">
|
|
68
|
+
</mat-paginator>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { RediTableComponent } from './redi-table.component';
|
|
3
|
+
import { RediTableModule } from '../redi-table.module';
|
|
4
|
+
|
|
5
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Component, SimpleChange } from '@angular/core';
|
|
6
|
+
|
|
7
|
+
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import { MatTableModule } from '@angular/material/table';
|
|
10
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
11
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
12
|
+
|
|
13
|
+
import { CommonModule } from '@angular/common';
|
|
14
|
+
|
|
15
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
16
|
+
|
|
17
|
+
import { DataTable } from '../../models/interfaces/data-table';
|
|
18
|
+
import { ColumnDefinition } from '../../models/interfaces/column-definition';
|
|
19
|
+
import { RowAction } from '../../models/interfaces/row-action';
|
|
20
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
21
|
+
import { MatSort } from '@angular/material/sort';
|
|
22
|
+
|
|
23
|
+
describe('RediTableComponent', () => {
|
|
24
|
+
let component: RediTableComponent<Pais>;
|
|
25
|
+
let fixture: ComponentFixture<RediTableComponent<Pais>>;
|
|
26
|
+
|
|
27
|
+
interface Pais {
|
|
28
|
+
id: string;
|
|
29
|
+
nombre: string;
|
|
30
|
+
iso: string;
|
|
31
|
+
fechaAlta: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
beforeEach(async () => {
|
|
35
|
+
await TestBed.configureTestingModule({
|
|
36
|
+
declarations: [RediTableComponent],
|
|
37
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
38
|
+
imports: [
|
|
39
|
+
CommonModule,
|
|
40
|
+
MatPaginatorModule,
|
|
41
|
+
MatIconModule,
|
|
42
|
+
MatTableModule,
|
|
43
|
+
ScrollingModule,
|
|
44
|
+
MatCheckboxModule,
|
|
45
|
+
BrowserAnimationsModule]
|
|
46
|
+
})
|
|
47
|
+
.compileComponents();
|
|
48
|
+
fixture = TestBed.createComponent(RediTableComponent<Pais>);
|
|
49
|
+
component = fixture.componentInstance;
|
|
50
|
+
component.dataTable = {
|
|
51
|
+
dataSource: [
|
|
52
|
+
{ id: "01", nombre: "México", iso: "MX", fechaAlta: "13/10/2021" } as Pais,
|
|
53
|
+
{ id: "02", nombre: "Estados Unidos", iso: "EU", fechaAlta: "13/10/2021" } as Pais,
|
|
54
|
+
{ id: "03", nombre: "El Salvador", iso: "SV", fechaAlta: "13/10/2021" } as Pais,
|
|
55
|
+
{ id: "04", nombre: "Guatemala", iso: "GT", fechaAlta: "22/10/2021" } as Pais,
|
|
56
|
+
{ id: "05", nombre: "Puerto Rico", iso: "PR", fechaAlta: "15/10/2021" } as Pais,
|
|
57
|
+
{ id: "06", nombre: "República de Cuba", iso: "CU", fechaAlta: "15/10/2021" } as Pais,
|
|
58
|
+
{ id: "07", nombre: "Venezuela", iso: "VE", fechaAlta: "13/10/2021" } as Pais,
|
|
59
|
+
{ id: "08", nombre: "Colombia", iso: "COL", fechaAlta: "22/10/2021" } as Pais,
|
|
60
|
+
{ id: "09", nombre: "Argentina", iso: "ARG", fechaAlta: "15/10/2021" } as Pais,
|
|
61
|
+
{ id: "10", nombre: "Belice", iso: "BZ", fechaAlta: "15/10/2021" } as Pais
|
|
62
|
+
],
|
|
63
|
+
columnas: [{ identificador: 'id', etiqueta: 'ID' } as ColumnDefinition,
|
|
64
|
+
{ identificador: 'nombre', etiqueta: 'Nombre' } as ColumnDefinition,
|
|
65
|
+
{ identificador: 'iso', etiqueta: 'ISO' } as ColumnDefinition,
|
|
66
|
+
{ identificador: 'fechaAlta', etiqueta: 'Fecha de alta' } as ColumnDefinition],
|
|
67
|
+
acciones: [
|
|
68
|
+
{
|
|
69
|
+
icono: 'delete_outline',
|
|
70
|
+
accion: (itemRow, dataSource) => {
|
|
71
|
+
dataSource?.data.splice(dataSource?.data.indexOf(itemRow), 1);
|
|
72
|
+
dataSource?._updateChangeSubscription()
|
|
73
|
+
}
|
|
74
|
+
} as RowAction,
|
|
75
|
+
{
|
|
76
|
+
icono: 'edit',
|
|
77
|
+
accion: (itemRow, dataSource) => {
|
|
78
|
+
console.log(dataSource)
|
|
79
|
+
}
|
|
80
|
+
} as RowAction],
|
|
81
|
+
seleccion: new SelectionModel<Pais>(true, [])
|
|
82
|
+
} as DataTable<Pais>;
|
|
83
|
+
fixture.detectChanges();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should create', () => {
|
|
87
|
+
expect(component).toBeTruthy();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('cambio de estados', () => {
|
|
91
|
+
component.paginar = true;
|
|
92
|
+
component.ngOnChanges({ paginar: new SimpleChange(false, component.paginar, true) });
|
|
93
|
+
fixture.detectChanges();
|
|
94
|
+
|
|
95
|
+
component.filtrarDatos = true;
|
|
96
|
+
component.ngOnChanges({ filtrarDatos: new SimpleChange(false, component.filtrarDatos, true) });
|
|
97
|
+
fixture.detectChanges();
|
|
98
|
+
|
|
99
|
+
component.filtrarDatos = false;
|
|
100
|
+
component.ngOnChanges({ filtrarDatos: new SimpleChange(true, component.filtrarDatos, false) });
|
|
101
|
+
fixture.detectChanges();
|
|
102
|
+
|
|
103
|
+
component.ordenarDatos = true;
|
|
104
|
+
component.ngOnChanges({ ordenarDatos: new SimpleChange(false, component.ordenarDatos, true) });
|
|
105
|
+
fixture.detectChanges();
|
|
106
|
+
|
|
107
|
+
component.seleccionarFilas = true;
|
|
108
|
+
component.ngOnChanges({ seleccionarFilas: new SimpleChange(false, component.seleccionarFilas, true) });
|
|
109
|
+
fixture.detectChanges();
|
|
110
|
+
|
|
111
|
+
component.seleccionarFilas = false;
|
|
112
|
+
component.ngOnChanges({ seleccionarFilas: new SimpleChange(true, component.seleccionarFilas, false) });
|
|
113
|
+
fixture.detectChanges();
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
component.paginar = false;
|
|
117
|
+
component.ngOnChanges({ paginar: new SimpleChange(true, component.paginar, false) });
|
|
118
|
+
fixture.detectChanges();
|
|
119
|
+
expect(component.paginar).toBe(false);
|
|
120
|
+
|
|
121
|
+
component.filtrarDatos = false;
|
|
122
|
+
component.ngOnChanges({ filtrarDatos: new SimpleChange(true, component.filtrarDatos, false) });
|
|
123
|
+
fixture.detectChanges();
|
|
124
|
+
|
|
125
|
+
component.ordenarDatos = false;
|
|
126
|
+
component.sort = {} as MatSort;
|
|
127
|
+
component.ngOnChanges({ ordenarDatos: new SimpleChange(true, component.ordenarDatos, false) });
|
|
128
|
+
fixture.detectChanges();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('filtrar datos',()=>{
|
|
132
|
+
expect(component.applyFilter('Me'));
|
|
133
|
+
|
|
134
|
+
component.paginar = true;
|
|
135
|
+
component.ngOnChanges({ paginar: new SimpleChange(false, component.paginar, true) });
|
|
136
|
+
fixture.detectChanges();
|
|
137
|
+
expect(component.paginar).toBe(true);
|
|
138
|
+
|
|
139
|
+
expect(component.applyFilter('Me'));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('seleccion de filas', () => {
|
|
143
|
+
expect(component.alternarSeleccion());
|
|
144
|
+
component.dataTable.seleccion.select(...component.dataTable.dataSource);
|
|
145
|
+
expect(component.alternarSeleccion());
|
|
146
|
+
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
it('metodos en general', () => {
|
|
151
|
+
expect(component.validarEtiqueta(false));
|
|
152
|
+
component.dataTable.columnas=[];
|
|
153
|
+
expect(component.ngAfterViewInit())
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
interface Pais {
|
|
160
|
+
id: number;
|
|
161
|
+
nombre: string;
|
|
162
|
+
}
|