Skip to content

Commit 7c98d56

Browse files
DiogoABastosalep85
authored andcommitted
AAE-27107 Improve logic
1 parent 54f20b7 commit 7c98d56

File tree

7 files changed

+192
-96
lines changed

7 files changed

+192
-96
lines changed

lib/core/src/lib/form/components/form-renderer.component.html

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,24 @@
8181
<div
8282
class="adf-grid-list-container"
8383
[class.adf-grid-list-container-multiple]="hasMultipleRows"
84-
>
85-
<h4 class="adf-grid-list-container-label">{{ 'FORM.FORM_RENDERER.ROW_LABEL' | translate: {number: rowIndex + 1} }}</h4>
84+
[class.adf-grid-list-container-disabled]="currentRootElement.field.readOnly"
85+
>
86+
<div class="adf-grid-list-row">
87+
<span class="adf-grid-list-row-label">{{ 'FORM.FORM_RENDERER.ROW_LABEL' | translate: {number: rowIndex + 1} }}</span>
88+
89+
@let shouldDisplayRemoveRowButton = !currentRootElement.field.rows[rowIndex].isInitial || (currentRootElement.field.rows[rowIndex].isInitial && currentRootElement.field.params.allowInitialRowsDelete);
90+
@if (shouldDisplayRemoveRowButton) {
91+
<button
92+
mat-icon-button
93+
class="adf-grid-list-row-remove-button"
94+
[disabled]="currentRootElement.field.readOnly"
95+
[matTooltip]="'FORM.FORM_RENDERER.DELETE_ROW' | translate"
96+
(click)="displayDialogToRemoveRow(currentRootElement.field, rowIndex)"
97+
>
98+
<mat-icon>close</mat-icon>
99+
</button>
100+
}
101+
</div>
86102
<section class="adf-grid-list-column-view">
87103
@for (column of row.columns; track $index) {
88104
<div
@@ -100,17 +116,6 @@ <h4 class="adf-grid-list-container-label">{{ 'FORM.FORM_RENDERER.ROW_LABEL' | tr
100116
}
101117
</div>
102118
}
103-
104-
@let shouldDisplayRemoveRowButton = !currentRootElement.field.rows[rowIndex].isInitial || (currentRootElement.field.rows[rowIndex].isInitial && currentRootElement.field.params.allowInitialRowsDelete);
105-
@if (shouldDisplayRemoveRowButton) {
106-
<button
107-
mat-icon-button
108-
class="adf-grid-list-remove-row-button"
109-
(click)="displayDialogToRemoveRow(currentRootElement.field, rowIndex)"
110-
>
111-
<mat-icon>close</mat-icon>
112-
</button>
113-
}
114119
</section>
115120
</div>
116121
}

lib/core/src/lib/form/components/form-renderer.component.scss

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,48 @@
9898
padding-right: 3px;
9999
}
100100

101-
&-remove-row-button {
102-
margin-top: 20px;
103-
104-
#{ms.$mat-icon} {
101+
&-row {
102+
display: flex;
103+
flex-direction: row;
104+
align-items: center;
105+
justify-content: space-between;
106+
107+
&-remove-button {
108+
padding: 0;
109+
width: 30px;
110+
height: 30px;
105111
display: flex;
106-
justify-content: center;
107112
align-items: center;
108-
font-size: 20px;
113+
justify-content: center;
114+
115+
#{ms.$mat-icon} {
116+
display: flex;
117+
justify-content: center;
118+
align-items: center;
119+
font-size: 18px;
120+
}
109121
}
110122
}
111123

112124
&-container {
113-
padding: 0 10px;
114-
115-
&-label {
116-
margin: 5px 0 5px -10px;
117-
}
125+
padding: 0 15px;
118126

119127
&-multiple {
120128
border-bottom: 1px solid rgba(0, 0, 0, 0.54);
121129
margin-bottom: 25px;
122130
}
131+
132+
&-disabled {
133+
&.adf-grid-list-container-multiple {
134+
border-bottom: 1px solid
135+
var(--mdc-text-button-disabled-label-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));
136+
}
137+
138+
.adf-grid-list-row-label {
139+
color: var(--mdc-text-button-disabled-label-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));
140+
cursor: default;
141+
}
142+
}
123143
}
124144
}
125145

lib/core/src/lib/form/components/form-renderer.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { FormSectionComponent } from './form-section/form-section.component';
3232
import { DecimalRenderMiddlewareService } from './middlewares/decimal-middleware.service';
3333
import { MatDialog } from '@angular/material/dialog';
3434
import { ConfirmDialogComponent } from '../../../lib/dialogs/confirm-dialog/confirm.dialog';
35+
import { MatTooltipModule } from '@angular/material/tooltip';
3536

3637
@Component({
3738
selector: 'adf-form-renderer',
@@ -63,7 +64,8 @@ import { ConfirmDialogComponent } from '../../../lib/dialogs/confirm-dialog/conf
6364
NgClass,
6465
HeaderWidgetComponent,
6566
FormSectionComponent,
66-
RepeatWidgetComponent
67+
RepeatWidgetComponent,
68+
MatTooltipModule
6769
],
6870
encapsulation: ViewEncapsulation.None
6971
})

0 commit comments

Comments
 (0)