Add 'beruecksichtigtePersonen' field and implement dynamic text updates in CVmhErstgespraech entity; enhance templates and localization
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
define('custom:views/c-vmh-erstgespraech/fields/beruecksichtigte-personen', ['views/fields/text'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
detailTemplate: 'custom:c-vmh-erstgespraech/fields/beruecksichtigte-personen/detail',
|
||||
editTemplate: 'custom:c-vmh-erstgespraech/fields/beruecksichtigte-personen/edit',
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.listenTo(this.model, 'change:anzahlVermieter change:anzahlMieter change:anzahlSonstigeVolljhrigeBewohner', () => {
|
||||
this.updateText();
|
||||
});
|
||||
|
||||
// Initial update when model is synced
|
||||
this.listenTo(this.model, 'sync', () => {
|
||||
this.updateText();
|
||||
});
|
||||
|
||||
// Update immediately if data already exists
|
||||
if (this.model.id) {
|
||||
this.updateText();
|
||||
}
|
||||
},
|
||||
|
||||
updateText: function () {
|
||||
if (this.calculating) return;
|
||||
this.calculating = true;
|
||||
|
||||
const vermieter = this.model.get('anzahlVermieter') || 0;
|
||||
const mieter = this.model.get('anzahlMieter') || 0;
|
||||
const sonstige = this.model.get('anzahlSonstigeVolljhrigeBewohner') || 0;
|
||||
|
||||
const text = `${vermieter} Vermieter, ${mieter} Mieter, ${sonstige} Dritte`;
|
||||
|
||||
this.model.set('beruecksichtigtePersonen', text, {silent: true});
|
||||
|
||||
this.calculating = false;
|
||||
|
||||
if (this.isRendered()) {
|
||||
this.reRender();
|
||||
}
|
||||
},
|
||||
|
||||
data: function () {
|
||||
const data = Dep.prototype.data.call(this);
|
||||
data.value = this.model.get('beruecksichtigtePersonen') || '';
|
||||
return data;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -13,8 +13,13 @@ define('custom:views/c-vmh-erstgespraech/fields/rvg-calculated', [
|
||||
// Listen to changes on relevant fields (combined listener)
|
||||
this.listenTo(this.model, 'change:streitwert change:anzahlVermieter change:anzahlMieter change:anzahlSonstigeVolljhrigeBewohner change:ustSatz', this.calculate.bind(this));
|
||||
|
||||
// Initial calculation
|
||||
this.calculate();
|
||||
// Initial calculation when model is synced
|
||||
this.listenTo(this.model, 'sync', this.calculate.bind(this));
|
||||
|
||||
// Immediate calculation if data already exists
|
||||
if (this.model.id) {
|
||||
this.calculate();
|
||||
}
|
||||
},
|
||||
|
||||
calculate: function () {
|
||||
|
||||
Reference in New Issue
Block a user