feat: Add termination functionality for rental agreements
- Introduced new entity `CKuendigung` for managing terminations. - Added fields for termination details including date, reason, type, and status. - Implemented backend service to initiate terminations from rental agreements. - Created frontend handler for termination actions with confirmation dialog. - Updated metadata and layouts for `CKuendigung` to support new functionality. - Added internationalization support for English and German languages. - Enhanced existing entities to establish relationships with terminations.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
define('custom:handlers/mietverhaeltnis/termination-action', [], function () {
|
||||
|
||||
class TerminationActionHandler {
|
||||
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup-Methode wird automatisch aufgerufen
|
||||
*/
|
||||
initInitiateTermination() {
|
||||
// Optional: Button-Logik nach Render
|
||||
}
|
||||
|
||||
/**
|
||||
* Action-Handler (wird bei Button-Click aufgerufen)
|
||||
*/
|
||||
actionInitiateTermination() {
|
||||
console.log('actionInitiateTermination called');
|
||||
const model = this.view.model;
|
||||
|
||||
// Confirmation Dialog
|
||||
this.view.confirm(
|
||||
this.view.translate('confirmTermination', 'messages', 'CVmhMietverhltnis'),
|
||||
() => {
|
||||
console.log('Confirmation accepted, initiating termination');
|
||||
this.initiateTermination(model.id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX Request zum Backend
|
||||
*/
|
||||
initiateTermination(mietverhaeltnisId) {
|
||||
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
|
||||
|
||||
Espo.Ajax.postRequest('CVmhMietverhltnis/action/initiateTermination', {
|
||||
id: mietverhaeltnisId
|
||||
})
|
||||
.then(response => {
|
||||
Espo.Ui.success(
|
||||
this.view.translate('terminationCreated', 'messages', 'CVmhMietverhltnis')
|
||||
);
|
||||
|
||||
// Navigation zur erstellten Kündigung
|
||||
this.view.getRouter().navigate(
|
||||
'#CKuendigung/view/' + response.id,
|
||||
{trigger: true}
|
||||
);
|
||||
})
|
||||
.catch(xhr => {
|
||||
console.error('Termination initiation failed:', xhr);
|
||||
|
||||
let errorMessage = this.view.translate('terminationError', 'messages', 'CVmhMietverhltnis');
|
||||
|
||||
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 TerminationActionHandler;
|
||||
});
|
||||
Reference in New Issue
Block a user