Implement eviction lawsuit initiation feature for Mietobjekt; add related UI and backend logic; update localization and configuration
This commit is contained in:
57
client/custom/src/handlers/mietobjekt/eviction-action.js
Normal file
57
client/custom/src/handlers/mietobjekt/eviction-action.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define('custom:handlers/mietobjekt/eviction-action', [], function () {
|
||||
|
||||
/**
|
||||
* Handler for initiating eviction lawsuit from Mietobjekt
|
||||
*/
|
||||
return class {
|
||||
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the handler
|
||||
*/
|
||||
initEvictionAction() {
|
||||
// Initialization if needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to initiate eviction (Räumungsklage)
|
||||
*/
|
||||
initiateEviction() {
|
||||
const model = this.view.model;
|
||||
|
||||
// Confirm dialog
|
||||
this.view.confirm(
|
||||
this.view.translate('initiateEvictionConfirmation', 'messages', 'CMietobjekt'),
|
||||
() => {
|
||||
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
|
||||
|
||||
// POST request to backend
|
||||
Espo.Ajax.postRequest('CMietobjekt/action/initiateEviction', {
|
||||
id: model.id
|
||||
}).then(response => {
|
||||
Espo.Ui.success(
|
||||
this.view.translate('evictionCreatedSuccess', 'messages', 'CMietobjekt')
|
||||
);
|
||||
|
||||
// Navigate to the newly created Räumungsklage
|
||||
this.view.getRouter().navigate(
|
||||
'#CVmhRumungsklage/view/' + response.id,
|
||||
{trigger: true}
|
||||
);
|
||||
}).catch(xhr => {
|
||||
let message = this.view.translate('evictionCreatedError', 'messages', 'CMietobjekt');
|
||||
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
message = xhr.responseJSON.message;
|
||||
}
|
||||
|
||||
Espo.Ui.error(message);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user