Add form validation to KontoTable and KreditorTable components. Disable save button when form is invalid. Clean up console logs in TextHeaderWithFilter and dataUtils.

This commit is contained in:
sebseb7
2025-08-01 10:44:17 +02:00
parent 976c802b11
commit 481f4db389
4 changed files with 25 additions and 10 deletions

View File

@@ -98,6 +98,12 @@ class KontoTable extends Component {
}); });
}; };
isFormValid = () => {
const { formData } = this.state;
return formData.konto.trim() !== '' &&
formData.name.trim() !== '';
};
handleSave = async () => { handleSave = async () => {
const { editingKonto, formData } = this.state; const { editingKonto, formData } = this.state;
@@ -257,7 +263,11 @@ class KontoTable extends Component {
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.handleCloseDialog}>Abbrechen</Button> <Button onClick={this.handleCloseDialog}>Abbrechen</Button>
<Button onClick={this.handleSave} variant="contained"> <Button
onClick={this.handleSave}
variant="contained"
disabled={!this.isFormValid()}
>
Speichern Speichern
</Button> </Button>
</DialogActions> </DialogActions>

View File

@@ -102,6 +102,13 @@ class KreditorTable extends Component {
}); });
}; };
isFormValid = () => {
const { formData } = this.state;
return formData.iban.trim() !== '' &&
formData.name.trim() !== '' &&
formData.kreditorId.trim() !== '';
};
handleSave = async () => { handleSave = async () => {
const { editingKreditor, formData } = this.state; const { editingKreditor, formData } = this.state;
@@ -270,7 +277,11 @@ class KreditorTable extends Component {
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.handleCloseDialog}>Abbrechen</Button> <Button onClick={this.handleCloseDialog}>Abbrechen</Button>
<Button onClick={this.handleSave} variant="contained"> <Button
onClick={this.handleSave}
variant="contained"
disabled={!this.isFormValid()}
>
Speichern Speichern
</Button> </Button>
</DialogActions> </DialogActions>

View File

@@ -290,13 +290,10 @@ export default class TextHeaderWithFilter {
this.eGui.style.height = '100%'; this.eGui.style.height = '100%';
this.eGui.style.display = 'flex'; this.eGui.style.display = 'flex';
this.eGui.style.flexDirection = 'column'; this.eGui.style.flexDirection = 'column';
console.log('TextHeaderWithFilter constructor');
} }
init(params) { init(params) {
this.params = params; this.params = params;
console.log('TextHeaderWithFilter init params:', params);
// Listen for menu close events to keep state in sync // Listen for menu close events to keep state in sync
if (params.api) { if (params.api) {
@@ -312,7 +309,6 @@ export default class TextHeaderWithFilter {
} }
getGui() { getGui() {
console.log('TextHeaderWithFilter getGui called');
return this.eGui; return this.eGui;
} }

View File

@@ -13,8 +13,6 @@ export const getRowStyle = (params, selectedRows) => {
const rowId = params.data?.id || params.rowIndex; const rowId = params.data?.id || params.rowIndex;
const isSelected = selectedRows && selectedRows.has && selectedRows.has(rowId); const isSelected = selectedRows && selectedRows.has && selectedRows.has(rowId);
console.log('getRowStyle called for row:', rowId, 'isSelected:', isSelected, 'selectedRows size:', selectedRows?.size);
if (params.data.isJTLOnly) { if (params.data.isJTLOnly) {
return { return {
backgroundColor: isSelected ? '#e3f2fd' : '#ffebee', backgroundColor: isSelected ? '#e3f2fd' : '#ffebee',