Implement debtors prison features across the application: Enhance FalukantController to include debtors prison logic in various service methods. Update FalukantService to manage debtors prison state and integrate it into user data retrieval. Modify frontend components, including DashboardWidget, StatusBar, and BankView, to display debtors prison status and warnings. Add localization for debtors prison messages in English, German, and Spanish, ensuring clarity in user notifications and actions.
This commit is contained in:
@@ -108,7 +108,7 @@ export default {
|
||||
},
|
||||
setupSocketListeners() {
|
||||
this.teardownSocketListeners();
|
||||
const daemonEvents = ['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'];
|
||||
const daemonEvents = ['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'falukantUpdateDebt', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'];
|
||||
if (this.daemonSocket) {
|
||||
this._daemonMessageHandler = (event) => {
|
||||
if (event.data === 'ping') return;
|
||||
@@ -129,6 +129,9 @@ export default {
|
||||
this._churchSocketHandler = (data) => {
|
||||
if (this.matchesCurrentUser(data)) this.queueFetchData();
|
||||
};
|
||||
this._debtSocketHandler = (data) => {
|
||||
if (this.matchesCurrentUser(data)) this.queueFetchData();
|
||||
};
|
||||
this._childrenSocketHandler = (data) => {
|
||||
if (this.matchesCurrentUser(data)) this.queueFetchData();
|
||||
};
|
||||
@@ -140,6 +143,7 @@ export default {
|
||||
this.socket.on('falukantUpdateStatus', this._statusSocketHandler);
|
||||
this.socket.on('falukantUpdateFamily', this._familySocketHandler);
|
||||
this.socket.on('falukantUpdateChurch', this._churchSocketHandler);
|
||||
this.socket.on('falukantUpdateDebt', this._debtSocketHandler);
|
||||
this.socket.on('children_update', this._childrenSocketHandler);
|
||||
this.socket.on('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
|
||||
this.socket.on('falukantBranchUpdate', this._branchSocketHandler);
|
||||
@@ -154,6 +158,7 @@ export default {
|
||||
if (this._statusSocketHandler) this.socket.off('falukantUpdateStatus', this._statusSocketHandler);
|
||||
if (this._familySocketHandler) this.socket.off('falukantUpdateFamily', this._familySocketHandler);
|
||||
if (this._churchSocketHandler) this.socket.off('falukantUpdateChurch', this._churchSocketHandler);
|
||||
if (this._debtSocketHandler) this.socket.off('falukantUpdateDebt', this._debtSocketHandler);
|
||||
if (this._childrenSocketHandler) this.socket.off('children_update', this._childrenSocketHandler);
|
||||
if (this._productionCertificateSocketHandler) this.socket.off('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
|
||||
if (this._branchSocketHandler) this.socket.off('falukantBranchUpdate', this._branchSocketHandler);
|
||||
|
||||
@@ -18,15 +18,19 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="openCreateBranchDialog">
|
||||
<button
|
||||
@click="openCreateBranchDialog"
|
||||
:disabled="blocked"
|
||||
>
|
||||
{{ $t('falukant.branch.actions.create') }}
|
||||
</button>
|
||||
<button
|
||||
@click="$emit('upgradeBranch')"
|
||||
:disabled="!localSelectedBranch"
|
||||
:disabled="!localSelectedBranch || blocked"
|
||||
>
|
||||
{{ $t('falukant.branch.actions.upgrade') }}
|
||||
</button>
|
||||
<span v-if="blocked && blockedReason" class="blocked-hint">{{ blockedReason }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,6 +55,8 @@ export default {
|
||||
props: {
|
||||
branches: { type: Array, required: true },
|
||||
selectedBranch: { type: Object, default: null },
|
||||
blocked: { type: Boolean, default: false },
|
||||
blockedReason: { type: String, default: '' },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -82,6 +88,7 @@ export default {
|
||||
},
|
||||
|
||||
openCreateBranchDialog() {
|
||||
if (this.blocked) return;
|
||||
this.$refs.createBranchDialog.open();
|
||||
},
|
||||
|
||||
@@ -131,4 +138,13 @@ button {
|
||||
.weather-value {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.blocked-hint {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 8px;
|
||||
color: #8b2f23;
|
||||
font-size: 0.88rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -36,6 +36,18 @@
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="debtorsPrison.active" class="statusbar-warning" :class="{ 'is-prison': debtorsPrison.inDebtorsPrison }">
|
||||
<strong>
|
||||
{{ debtorsPrison.inDebtorsPrison
|
||||
? $t('falukant.bank.debtorsPrison.titlePrison')
|
||||
: $t('falukant.bank.debtorsPrison.titleWarning') }}
|
||||
</strong>
|
||||
<span>
|
||||
{{ debtorsPrison.inDebtorsPrison
|
||||
? $t('falukant.debtorsPrison.globalLocked')
|
||||
: $t('falukant.debtorsPrison.globalWarning') }}
|
||||
</span>
|
||||
</div>
|
||||
<MessagesDialog ref="msgs" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -60,6 +72,10 @@ export default {
|
||||
{ key: "children", icon: "👶", value: null },
|
||||
],
|
||||
unreadCount: 0,
|
||||
debtorsPrison: {
|
||||
active: false,
|
||||
inDebtorsPrison: false
|
||||
},
|
||||
pendingStatusRefresh: null,
|
||||
};
|
||||
},
|
||||
@@ -146,6 +162,10 @@ export default {
|
||||
const childCount = Number(response.data.childrenCount) || 0;
|
||||
const unbaptisedCount = Number(response.data.unbaptisedChildrenCount) || 0;
|
||||
this.unreadCount = Number(response.data.unreadNotifications) || 0;
|
||||
this.debtorsPrison = response.data.debtorsPrison || {
|
||||
active: false,
|
||||
inDebtorsPrison: false
|
||||
};
|
||||
const childrenDisplay = `${childCount}${unbaptisedCount > 0 ? `(${unbaptisedCount})` : ''}`;
|
||||
let healthStatus = '';
|
||||
if (health > 90) {
|
||||
@@ -177,6 +197,7 @@ export default {
|
||||
this._statusSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateStatus', ...data });
|
||||
this._familySocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateFamily', ...data });
|
||||
this._churchSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateChurch', ...data });
|
||||
this._debtSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateDebt', ...data });
|
||||
this._childrenSocketHandler = (data) => this.handleEvent({ event: 'children_update', ...data });
|
||||
this._productionCertificateSocketHandler = (data) => this.handleEvent({ event: 'falukantUpdateProductionCertificate', ...data });
|
||||
this._stockSocketHandler = (data) => this.handleEvent({ event: 'stock_change', ...data });
|
||||
@@ -185,6 +206,7 @@ export default {
|
||||
this.socket.on('falukantUpdateStatus', this._statusSocketHandler);
|
||||
this.socket.on('falukantUpdateFamily', this._familySocketHandler);
|
||||
this.socket.on('falukantUpdateChurch', this._churchSocketHandler);
|
||||
this.socket.on('falukantUpdateDebt', this._debtSocketHandler);
|
||||
this.socket.on('children_update', this._childrenSocketHandler);
|
||||
this.socket.on('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
|
||||
this.socket.on('stock_change', this._stockSocketHandler);
|
||||
@@ -195,6 +217,7 @@ export default {
|
||||
if (this._statusSocketHandler) this.socket.off('falukantUpdateStatus', this._statusSocketHandler);
|
||||
if (this._familySocketHandler) this.socket.off('falukantUpdateFamily', this._familySocketHandler);
|
||||
if (this._churchSocketHandler) this.socket.off('falukantUpdateChurch', this._churchSocketHandler);
|
||||
if (this._debtSocketHandler) this.socket.off('falukantUpdateDebt', this._debtSocketHandler);
|
||||
if (this._childrenSocketHandler) this.socket.off('children_update', this._childrenSocketHandler);
|
||||
if (this._productionCertificateSocketHandler) this.socket.off('falukantUpdateProductionCertificate', this._productionCertificateSocketHandler);
|
||||
if (this._stockSocketHandler) this.socket.off('stock_change', this._stockSocketHandler);
|
||||
@@ -207,7 +230,7 @@ export default {
|
||||
this._daemonHandler = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
if (['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'].includes(data.event)) {
|
||||
if (['falukantUpdateStatus', 'falukantUpdateFamily', 'falukantUpdateChurch', 'falukantUpdateDebt', 'children_update', 'falukantUpdateProductionCertificate', 'stock_change', 'familychanged'].includes(data.event)) {
|
||||
this.handleEvent(data);
|
||||
}
|
||||
} catch (_) {}
|
||||
@@ -247,6 +270,7 @@ export default {
|
||||
case 'falukantUpdateStatus':
|
||||
case 'falukantUpdateFamily':
|
||||
case 'falukantUpdateChurch':
|
||||
case 'falukantUpdateDebt':
|
||||
case 'children_update':
|
||||
case 'falukantUpdateProductionCertificate':
|
||||
case 'stock_change':
|
||||
@@ -294,6 +318,25 @@ export default {
|
||||
box-shadow: var(--shadow-soft);
|
||||
}
|
||||
|
||||
.statusbar-warning {
|
||||
flex: 1 1 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid rgba(180, 120, 40, 0.35);
|
||||
background: rgba(255, 244, 223, 0.92);
|
||||
color: #8a5411;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.statusbar-warning.is-prison {
|
||||
border-color: rgba(146, 57, 40, 0.42);
|
||||
background: rgba(255, 232, 225, 0.94);
|
||||
color: #8b2f23;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
<dd>{{ falukantData.unreadNotificationsCount }}</dd>
|
||||
<dt>{{ $t('falukant.statusbar.children') }}</dt>
|
||||
<dd>{{ falukantData.childrenCount }}</dd>
|
||||
<template v-if="falukantData.debtorsPrison?.active">
|
||||
<dt>{{ $t('falukant.bank.debtorsPrison.titlePrison') }}</dt>
|
||||
<dd class="falukant-debt" :class="{ 'falukant-debt--warning': !falukantData.debtorsPrison?.inDebtorsPrison }">
|
||||
{{ falukantData.debtorsPrison?.inDebtorsPrison
|
||||
? $t('falukant.bank.debtorsPrison.titlePrison')
|
||||
: $t('falukant.bank.debtorsPrison.titleWarning') }}
|
||||
</dd>
|
||||
</template>
|
||||
</dl>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
@@ -43,6 +51,7 @@ export default {
|
||||
money: pick(raw, 'money', 'money'),
|
||||
unreadNotificationsCount: pick(raw, 'unreadNotificationsCount', 'unread_notifications_count'),
|
||||
childrenCount: pick(raw, 'childrenCount', 'children_count'),
|
||||
debtorsPrison: pick(raw, 'debtorsPrison', 'debtors_prison'),
|
||||
// keep all original keys as fallback for any other usage
|
||||
...raw
|
||||
};
|
||||
@@ -173,4 +182,13 @@ export default {
|
||||
color: #198754;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dashboard-widget__falukant dd.falukant-debt {
|
||||
color: #8b2f23;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.dashboard-widget__falukant dd.falukant-debt--warning {
|
||||
color: #9a5a08;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user