added faulty owner view

This commit is contained in:
Luca Haid
2025-05-20 13:44:55 +02:00
parent 90987baec0
commit 288727f465
9 changed files with 506 additions and 4 deletions
@@ -0,0 +1,200 @@
Vue.component('construction-consent-faulty-entries', {
//language=Vue
template: `
<div>
<tt-card>
<tt-table :data="window['TT_CONFIG']['FAULTY_ENTRIES']" :config="FaultyEntriesTableConfig" excel-export>
<template v-slot:project_name="{ row }">
{{ row.project_name }}
</template>
<template v-slot:building_info="{ row }">
<div>
<strong>Name:</strong> {{ row.building_name || 'N/A' }} <br>
<strong>Typ:</strong> {{ formatObjectType(row.object_type) }}
</div>
</template>
<template v-slot:owner_info="{ row }">
<div>
<div v-if="row.company" :class="{'text-danger': row.errors.includes('company')}">
<strong>Firma:</strong> {{ row.company }}
</div>
<div v-else>
<div :class="{'text-danger': row.errors.includes('firstname')}">
<strong>Vorname:</strong> {{ row.firstname || '⚠️ Fehlt' }}
</div>
<div :class="{'text-danger': row.errors.includes('lastname')}">
<strong>Nachname:</strong> {{ row.lastname || '⚠️ Fehlt' }}
</div>
</div>
</div>
</template>
<template v-slot:address_info="{ row }">
<div>
<div>
<strong>Straße:</strong> {{ row.street || 'N/A' }}
</div>
<div :class="{'text-danger': row.errors.includes('zip')}">
<strong>PLZ:</strong> {{ row.zip || '⚠️ Fehlt' }}
<span v-if="row.errors.includes('zip') && isAustria(row)" class="badge badge-warning">
Muss 4-stellig sein
</span>
</div>
<div :class="{'text-danger': row.errors.includes('city')}">
<strong>Stadt:</strong> {{ row.city || '⚠️ Fehlt' }}
</div>
<div>
<strong>Land:</strong> {{ row.country || 'N/A' }}
</div>
</div>
</template>
<template v-slot:contact_info="{ row }">
<div>
<div>
<strong>Email:</strong> {{ row.email || 'N/A' }}
</div>
<div>
<strong>Telefon:</strong> {{ row.phone || 'N/A' }}
</div>
</div>
</template>
<template v-slot:status="{ row }">
<span :class="getStatusBadgeClass(row.status)">
{{ formatStatus(row.status) }}
</span>
<br>
<span v-if="row.result" :class="getResultBadgeClass(row.result)">
{{ formatResult(row.result) }}
</span>
</template>
<template v-slot:errors="{ row }">
<div class="error-list">
<ul class="mb-0 pl-3">
<li v-for="error in row.errors" :key="error">
{{ formatErrorType(error) }}
</li>
</ul>
</div>
</template>
<template v-slot:actions="{ row }">
<div class="btn-group btn-group-sm">
<a :href="window['TT_CONFIG']['BASE_URL'] + '/ConstructionConsent/View?id=' + row.consent_id + '&highlight_owner_id=' + row.owner_id"
class="btn btn-primary"
target="_blank"
title="Zustimmungserklärung bearbeiten">
<i class="fas fa-edit"></i>
</a>
</div>
</template>
</tt-table>
</tt-card>
</div>
`,
data() {
return {
window: window,
selectedProject: window['TT_CONFIG']['SELECTED_PROJECT'] || '',
FaultyEntriesTableConfig: {
key: 'FaultyEntriesTable',
tableHeader: 'Fehlerhafte Eigentümer-Einträge',
defaultPageSize: 20,
headers: [
{text: 'Projekt', key: 'project_name', sortable: true, class: 'text-nowrap', priority: 10},
{text: 'Objekt', key: 'building_info', sortable: true, sortKey: 'building_name', class: 'text-nowrap', priority: 9},
{text: 'Eigentümer', key: 'owner_info', sortable: true, sortKey: 'lastname', class: '', priority: 8},
{text: 'Adresse', key: 'address_info', sortable: true, sortKey: 'city', class: '', priority: 7},
{text: 'Kontakt', key: 'contact_info', sortable: false, class: '', priority: 6},
{text: 'Status', key: 'status', sortable: true, class: 'text-center', priority: 5, filter: 'select', filterOptions: [
{text: 'Neu', value: 'new'},
{text: 'Gesendet', value: 'sent'},
{text: 'Zurückgekehrt', value: 'returned'},
{text: 'Ausstehend', value: 'outstanding'},
]},
{text: 'Fehler', key: 'errors', sortable: false, class: '', priority: 4},
{text: 'Aktionen', key: 'actions', sortable: false, class: 'text-center', filter: false, priority: 3},
],
},
}
},
methods: {
formatDate(timestamp) {
if (!timestamp) return 'N/A';
return this.window.moment.unix(timestamp).format('DD.MM.YYYY HH:mm:ss');
},
formatObjectType(type) {
const types = {
'building': 'Gebäude',
'street': 'Straße'
};
return types[type] || type;
},
formatStatus(status) {
const statuses = {
'new': 'Neu',
'sent': 'Gesendet',
'returned': 'Zurückgekehrt',
'outstanding': 'Ausstehend'
};
return statuses[status] || status;
},
formatResult(result) {
const results = {
'open': 'Offen',
'accepted': 'Akzeptiert',
'denied': 'Abgelehnt',
'unresolvable': 'Nicht lösbar',
'moved': 'Umgezogen'
};
return results[result] || result;
},
formatErrorType(error) {
const errors = {
'company': 'Fehlende Firma',
'firstname': 'Fehlender Vorname',
'lastname': 'Fehlender Nachname',
'city': 'Fehlende Stadt',
'zip': 'Ungültige PLZ'
};
return errors[error] || error;
},
getStatusBadgeClass(status) {
const classes = {
'new': 'badge badge-secondary',
'sent': 'badge badge-primary',
'returned': 'badge badge-success',
'outstanding': 'badge badge-warning'
};
return classes[status] || 'badge badge-secondary';
},
getResultBadgeClass(result) {
const classes = {
'open': 'badge badge-info',
'accepted': 'badge badge-success',
'denied': 'badge badge-danger',
'unresolvable': 'badge badge-dark',
'moved': 'badge badge-warning'
};
return classes[result] || 'badge badge-secondary';
},
isAustria(row) {
return row.country && (row.country.toLowerCase() === 'österreich' || row.country.toLowerCase() === 'austria');
},
filterByProject() {
// Redirect to same page with project filter
window.location.href = this.window['TT_CONFIG']['BASE_URL'] +
'/ConstructionConsent/faultyEntries' +
(this.selectedProject ? '?project_id=' + this.selectedProject : '');
},
refreshData() {
// Reload the current page
window.location.reload();
}
}
})