Refactor eviction and rent collection features; migrate logic from Mietobjekt to Mietverhältnis; update localization and UI handlers
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
define('custom:handlers/mietverhaeltnis/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');
|
||||
const model = this.view.model;
|
||||
|
||||
// Confirmation Dialog
|
||||
this.view.confirm(
|
||||
this.view.translate('confirmEviction', 'messages', 'CVmhMietverhltnis'),
|
||||
() => {
|
||||
console.log('Confirmation accepted, initiating eviction');
|
||||
this.initiateEviction(model.id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX Request zum Backend
|
||||
*/
|
||||
initiateEviction(mietverhaeltnisId) {
|
||||
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
|
||||
|
||||
Espo.Ajax.postRequest('CVmhMietverhltnis/action/initiateEviction', {
|
||||
id: mietverhaeltnisId
|
||||
})
|
||||
.then(response => {
|
||||
Espo.Ui.success(
|
||||
this.view.translate('evictionCreated', 'messages', 'CVmhMietverhltnis')
|
||||
);
|
||||
|
||||
// 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', '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 EvictionActionHandler;
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
define('custom:handlers/mietverhaeltnis/rent-collection-action', [], function () {
|
||||
|
||||
class RentCollectionActionHandler {
|
||||
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup-Methode wird automatisch aufgerufen
|
||||
*/
|
||||
initInitiateRentCollection() {
|
||||
// Optional: Button-Logik nach Render
|
||||
}
|
||||
|
||||
/**
|
||||
* Action-Handler (wird bei Button-Click aufgerufen)
|
||||
*/
|
||||
actionInitiateRentCollection() {
|
||||
console.log('actionInitiateRentCollection called');
|
||||
const model = this.view.model;
|
||||
|
||||
// Confirmation Dialog
|
||||
this.view.confirm(
|
||||
this.view.translate('confirmRentCollection', 'messages', 'CVmhMietverhltnis'),
|
||||
() => {
|
||||
console.log('Confirmation accepted, initiating rent collection');
|
||||
this.initiateRentCollection(model.id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX Request zum Backend
|
||||
*/
|
||||
initiateRentCollection(mietverhaeltnisId) {
|
||||
Espo.Ui.notify(this.view.translate('pleaseWait', 'messages'));
|
||||
|
||||
Espo.Ajax.postRequest('CVmhMietverhltnis/action/initiateRentCollection', {
|
||||
id: mietverhaeltnisId
|
||||
})
|
||||
.then(response => {
|
||||
Espo.Ui.success(
|
||||
this.view.translate('rentCollectionCreated', 'messages', 'CVmhMietverhltnis')
|
||||
);
|
||||
|
||||
// Navigation zum erstellten Mietinkasso
|
||||
this.view.getRouter().navigate(
|
||||
'#CMietinkasso/view/' + response.id,
|
||||
{trigger: true}
|
||||
);
|
||||
})
|
||||
.catch(xhr => {
|
||||
console.error('Rent collection initiation failed:', xhr);
|
||||
|
||||
let errorMessage = this.view.translate('rentCollectionError', '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 RentCollectionActionHandler;
|
||||
});
|
||||
Reference in New Issue
Block a user