mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Fixed user not clickable after creation, fixed missing data attributes for created user
This commit is contained in:
@@ -586,6 +586,10 @@
|
|||||||
data-user-title="${data.Title || ''}"
|
data-user-title="${data.Title || ''}"
|
||||||
data-user-name="${data.Cn || ''}"
|
data-user-name="${data.Cn || ''}"
|
||||||
data-user-surname="${data.Sn || ''}"
|
data-user-surname="${data.Sn || ''}"
|
||||||
|
data-user-birthdate="${data.BirthDate}"
|
||||||
|
data-user-address-city="${data.Description.Address.City}"
|
||||||
|
data-user-address-street="${data.Description.Address.Street}"
|
||||||
|
data-user-address-streetnr="${data.Description.Address.StreetNr}"
|
||||||
data-user-workplace="${data.Description?.Workplace || ''}"
|
data-user-workplace="${data.Description?.Workplace || ''}"
|
||||||
data-user-groups='${JSON.stringify(data.Description?.Groups || [])}'
|
data-user-groups='${JSON.stringify(data.Description?.Groups || [])}'
|
||||||
data-bs-toggle="modal"
|
data-bs-toggle="modal"
|
||||||
@@ -602,6 +606,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
|
newRow.setAttribute("data-asset-id", result.Uid);
|
||||||
|
newRow.classList.toggle("user-row");
|
||||||
|
registerRowDetailviewClick(newRow);
|
||||||
tbody.appendChild(newRow);
|
tbody.appendChild(newRow);
|
||||||
} else {
|
} else {
|
||||||
showToast(`${result.Exception || '@T["Create failed"]'}`, 'danger');
|
showToast(`${result.Exception || '@T["Create failed"]'}`, 'danger');
|
||||||
@@ -699,52 +706,53 @@
|
|||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const rows = document.querySelectorAll('table tbody tr');
|
const rows = document.querySelectorAll('table tbody tr');
|
||||||
|
|
||||||
|
rows.forEach(row => registerRowDetailviewClick(row));
|
||||||
|
});
|
||||||
|
function registerRowDetailviewClick(row) {
|
||||||
const detailModalEl = document.getElementById('detailModal');
|
const detailModalEl = document.getElementById('detailModal');
|
||||||
const detailModal = new bootstrap.Modal(detailModalEl);
|
const detailModal = new bootstrap.Modal(detailModalEl);
|
||||||
|
row.addEventListener('click', (e) => {
|
||||||
|
// Don’t trigger when clicking inside the action buttons
|
||||||
|
if (e.target.closest('button')) return;
|
||||||
|
|
||||||
rows.forEach(row => {
|
const updateBtn = row.querySelector('.btn-warning[data-user-id]');
|
||||||
row.addEventListener('click', (e) => {
|
if (!updateBtn) return;
|
||||||
// Don’t trigger when clicking inside the action buttons
|
|
||||||
if (e.target.closest('button')) return;
|
|
||||||
|
|
||||||
const updateBtn = row.querySelector('.btn-warning[data-user-id]');
|
// Extract data from update button
|
||||||
if (!updateBtn) return;
|
const data = {
|
||||||
|
uid: updateBtn.dataset.userId,
|
||||||
// Extract data from update button
|
title: updateBtn.dataset.userTitle,
|
||||||
const data = {
|
name: updateBtn.dataset.userName,
|
||||||
uid: updateBtn.dataset.userId,
|
surname: updateBtn.dataset.userSurname,
|
||||||
title: updateBtn.dataset.userTitle,
|
workplace: updateBtn.dataset.userWorkplace,
|
||||||
name: updateBtn.dataset.userName,
|
birthdate: updateBtn.dataset.userBirthdate,
|
||||||
surname: updateBtn.dataset.userSurname,
|
city: updateBtn.dataset.userAddressCity,
|
||||||
workplace: updateBtn.dataset.userWorkplace,
|
street: updateBtn.dataset.userAddressStreet,
|
||||||
birthdate: updateBtn.dataset.userBirthdate,
|
streetNr: updateBtn.dataset.userAddressStreetnr,
|
||||||
city: updateBtn.dataset.userAddressCity,
|
groups: JSON.parse(updateBtn.dataset.userGroups || '[]'),
|
||||||
street: updateBtn.dataset.userAddressStreet,
|
};
|
||||||
streetNr: updateBtn.dataset.userAddressStreetnr,
|
|
||||||
groups: JSON.parse(updateBtn.dataset.userGroups || '[]'),
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Fill modal fields
|
// Fill modal fields
|
||||||
document.getElementById('detailUid').value = data.uid || '';
|
document.getElementById('detailUid').value = data.uid || '';
|
||||||
document.getElementById('detailTitle').value = data.title || '';
|
document.getElementById('detailTitle').value = data.title || '';
|
||||||
document.getElementById('detailName').value = data.name || '';
|
document.getElementById('detailName').value = data.name || '';
|
||||||
document.getElementById('detailSurname').value = data.surname || '';
|
document.getElementById('detailSurname').value = data.surname || '';
|
||||||
document.getElementById('detailBirthdate').value = data.birthdate || '';
|
document.getElementById('detailBirthdate').value = data.birthdate || '';
|
||||||
document.getElementById('detailCity').value = data.city || '';
|
document.getElementById('detailCity').value = data.city || '';
|
||||||
document.getElementById('detailStreet').value = data.street || '';
|
document.getElementById('detailStreet').value = data.street || '';
|
||||||
document.getElementById('detailStreetNr').value = data.streetNr || '';
|
document.getElementById('detailStreetNr').value = data.streetNr || '';
|
||||||
document.getElementById('detailWorkplace').value = data.workplace || '';
|
document.getElementById('detailWorkplace').value = data.workplace || '';
|
||||||
document.getElementById('detailGroups').value = data.groups.join(', ') || '';
|
document.getElementById('detailGroups').value = data.groups.join(', ') || '';
|
||||||
|
|
||||||
// Photo
|
// Photo
|
||||||
const imgEl = row.querySelector('td:first-child img');
|
const imgEl = row.querySelector('td:first-child img');
|
||||||
const detailPhoto = document.getElementById('detailPhoto');
|
const detailPhoto = document.getElementById('detailPhoto');
|
||||||
detailPhoto.src = `/Home/UserPhoto?uid=${data.uid}&size=256`;
|
detailPhoto.src = `/Home/UserPhoto?uid=${data.uid}&size=256`;
|
||||||
detailModal.show();
|
detailModal.show();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in New Issue
Block a user