feat: Implement eviction lawsuit initiation from Kündigung with related data handling

This commit is contained in:
2026-01-25 14:10:50 +01:00
parent 146a046a0e
commit c92dbf7191
9 changed files with 603 additions and 81 deletions

View File

@@ -0,0 +1,70 @@
define('custom:handlers/kuendigung/eviction-action', [], function () {
class EvictionActionHandler {
constructor(view) {
this.view = view;
}
/**
* Setup-Methode wird automatisch aufgerufen
*/
initInitiateEviction() {
// Optional: Button-Logik nach Render
}
/**
* Action-Handler (wird bei Button-Click aufgerufen)
*/
actionInitiateEviction() {
console.log('actionInitiateEviction called from Kündigung');
const model = this.view.model;
// Confirmation Dialog
this.view.confirm(
this.view.translate('confirmEviction', 'messages', 'CKuendigung'),
() => {
console.log('Confirmation accepted, initiating eviction from Kündigung');
this.initiateEviction(model.id);
}
);
}
/**
* AJAX Request zum Backend
*/
initiateEviction(kuendigungId) {
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
Espo.Ajax.postRequest('CKuendigung/action/initiateEviction', {
id: kuendigungId
})
.then(response => {
Espo.Ui.success(
this.view.translate('evictionCreated', 'messages', 'CKuendigung')
);
// Navigation zur erstellten Räumungsklage
this.view.getRouter().navigate(
'#CVmhRumungsklage/view/' + response.id,
{trigger: true}
);
})
.catch(xhr => {
console.error('Eviction initiation failed:', xhr);
let errorMessage = this.view.translate('evictionError', 'messages', 'CKuendigung');
if (xhr.status === 403) {
errorMessage = this.view.translate('Access denied', 'messages');
} else if (xhr.status === 404) {
errorMessage = this.view.translate('Not found', 'messages');
}
Espo.Ui.error(errorMessage);
});
}
}
return EvictionActionHandler;
});