Skip to content

Commit 34857c7

Browse files
sara-resara-gnucoop
authored andcommitted
feat(material/forms): redesign table field
1 parent e3909c4 commit 34857c7

File tree

5 files changed

+54
-75
lines changed

5 files changed

+54
-75
lines changed

projects/core/forms/src/read-only-table-field.html

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
<ng-template #controlCell>
1616
<ng-container *ngIf="c|ajfGetTableCellControl as contr">
1717
<ng-container *ngIf="contr">
18-
<span class="ajf-table-cell"
19-
>{{ contr.control!.value | ajfTranslateIfString | ajfFormatIfNumber: '.0-2'
20-
}}</span
21-
>
18+
<span>{{ contr.control!.value | ajfTranslateIfString | ajfFormatIfNumber:
19+
'.0-2'
20+
}}</span>
2221
</ng-container>
2322
</ng-container>
2423
</ng-template>
@@ -27,4 +26,4 @@
2726
</tr>
2827
</ng-container>
2928
</ng-container>
30-
</table>
29+
</table>

projects/core/forms/src/table-row-class.ts

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ import {Pipe, PipeTransform} from '@angular/core';
3131
@Pipe({name: 'ajfTableRowClass'})
3232
export class AjfTableRowClass implements PipeTransform {
3333
transform(value: number): string {
34+
if (value === 0) {
35+
return 'ajf-header-row';
36+
}
3437
return value % 2 == 0 ? 'ajf-row-even' : 'ajf-row-odd';
3538
}
3639
}

projects/material/forms/src/field.scss

-13
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ ajf-field {
2323
font-style: italic;
2424
padding: 5px;
2525
}
26-
27-
tr.ajf-row-odd {
28-
background-color: grey;
29-
}
3026
}
3127

3228
table {
@@ -66,15 +62,6 @@ table {
6662
}
6763
}
6864
}
69-
70-
&:last-of-type {
71-
td {
72-
span,
73-
input {
74-
border-bottom-color: #cccccc;
75-
}
76-
}
77-
}
7865
}
7966
}
8067

projects/material/forms/src/table-field.html

+9-22
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,21 @@
1515
<ng-template #controlCell>
1616
<ng-container *ngIf="c|ajfGetTableCellControl as contr">
1717
<ng-container *ngIf="contr">
18-
<ng-container
19-
*ngIf="contr!.show && (node.rows[row-1][column]|ajfIsCellEditable); else plainTextCell"
20-
>
18+
<ng-container *ngIf="contr!.show && (node.rows[row-1][column]|ajfIsCellEditable); else plainTextCell">
2119
<ng-container *ngIf="contr.type === 'number';else genericInput">
22-
<input
23-
(focusout)="contr!.show = false"
24-
type="number"
25-
[formControl]="contr.control"
26-
(keydown.tab)="goToNextCell($event, row, column)"
27-
autofocus
28-
/>
20+
<input (focusout)="contr!.show = false" type="number" [formControl]="contr.control"
21+
(keydown.tab)="goToNextCell($event, row, column)" autofocus />
2922
</ng-container>
3023
<ng-template #genericInput>
31-
<input
32-
(focusout)="contr!.show = false"
33-
[type]="contr.type"
34-
[formControl]="contr.control"
35-
(keydown.tab)="goToNextCell($event, row, column)"
36-
autofocus
37-
/>
24+
<input (focusout)="contr!.show = false" [type]="contr.type" [formControl]="contr.control"
25+
(keydown.tab)="goToNextCell($event, row, column)" autofocus />
3826
</ng-template>
3927
</ng-container>
4028

4129
<ng-template #plainTextCell>
42-
<span class="ajf-table-cell" (click)="goToCell(row, column)"
43-
>{{ contr.control!.value | ajfTranslateIfString | ajfFormatIfNumber: '.0-2'
44-
}}</span
45-
>
30+
<span (click)="goToCell(row, column)">{{ contr.control!.value |
31+
ajfTranslateIfString | ajfFormatIfNumber: '.0-2'
32+
}}</span>
4633
</ng-template>
4734
</ng-container>
4835
</ng-container>
@@ -52,4 +39,4 @@
5239
</tr>
5340
</ng-container>
5441
</ng-container>
55-
</table>
42+
</table>
+38-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
table.ajf-table-field {
2-
border-collapse: collapse;
3-
border-spacing: 0;
42
width: 100%;
3+
border-collapse: collapse;
4+
.ajf-header-row {
5+
font-weight: bold;
6+
background-color: #f9f9f9;
7+
}
58

6-
tr {
7-
td {
8-
position: relative;
9-
min-width: 2em;
10-
border-top: solid 1px #cccccc;
11-
border-left: solid 1px #cccccc;
12-
13-
span, input {
14-
cursor: text;
15-
width: 100%;
16-
box-sizing: border-box;
17-
outline: none;
18-
display: inline-block;
19-
font-family: inherit;
20-
font-size: inherit;
21-
line-height: inherit;
22-
text-align: center;
23-
position: relative;
24-
min-height: 22px;
25-
border: none;
26-
}
9+
th,
10+
td {
11+
padding: 12px 15px;
12+
text-align: left;
13+
border-bottom: 1px solid #ddd;
2714

28-
&:last-child {
29-
span, input {
30-
border-right-color: #cccccc;
31-
}
32-
}
15+
span,
16+
input {
17+
cursor: text;
18+
position: absolute;
19+
width: 100%;
20+
box-sizing: border-box;
21+
outline: none;
22+
top: 0;
23+
right: 0;
24+
bottom: 0;
25+
left: 0;
26+
display: inline-block;
27+
border-top: solid 1px transparent;
28+
border-right: solid 1px transparent;
29+
border-bottom: solid 1px transparent;
30+
border-left: solid 1px #cccccc;
31+
font-family: inherit;
32+
font-size: inherit;
33+
line-height: inherit;
34+
text-align: center;
35+
padding: 12px 15px;
3336
}
37+
}
3438

35-
&:last-of-type {
36-
td {
37-
span, input {
38-
border-bottom-color: #cccccc;
39-
}
40-
}
41-
}
39+
tr:hover {
40+
background-color: #f1f1f1;
4241
}
42+
43+
/*tr:nth-child(even) {
44+
background-color: #f9f9f9;
45+
}*/
4346
}

0 commit comments

Comments
 (0)