CQ fixes
This commit is contained in:
@@ -63,12 +63,8 @@ def create_child(
|
||||
@router.get("", response_model=list[ChildResponse])
|
||||
def get_user_children(
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
user_repo: Annotated[
|
||||
UserRepositoryInterface, Depends(get_user_repository)
|
||||
],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
user_repo: Annotated[UserRepositoryInterface, Depends(get_user_repository)],
|
||||
) -> list[ChildResponse]:
|
||||
"""Get all children for the authenticated user."""
|
||||
children = child_repo.get_by_user_id(user_id)
|
||||
|
||||
@@ -371,7 +371,9 @@
|
||||
|
||||
content.innerHTML = `
|
||||
<div class="controls">
|
||||
${allChildren.length === 1 ? `
|
||||
${
|
||||
allChildren.length === 1
|
||||
? `
|
||||
<label for="childDisplay">Child:</label>
|
||||
<input
|
||||
type="text"
|
||||
@@ -380,12 +382,14 @@
|
||||
readonly
|
||||
style="background-color: #f5f5f5; cursor: default; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;"
|
||||
/>
|
||||
` : `
|
||||
`
|
||||
: `
|
||||
<label for="childFilter">Child:</label>
|
||||
<select id="childFilter" onchange="onChildChange(event)">
|
||||
${childOptions}
|
||||
</select>
|
||||
`}
|
||||
`
|
||||
}
|
||||
|
||||
<label for="daysRange">Time Range:</label>
|
||||
<select id="daysRange" onchange="onDaysRangeChange(event)">
|
||||
|
||||
@@ -409,7 +409,9 @@
|
||||
|
||||
content.innerHTML = `
|
||||
<div class="controls">
|
||||
${allChildren.length === 1 ? `
|
||||
${
|
||||
allChildren.length === 1
|
||||
? `
|
||||
<label for="childDisplay">Child:</label>
|
||||
<input
|
||||
type="text"
|
||||
@@ -418,12 +420,14 @@
|
||||
readonly
|
||||
style="background-color: #f5f5f5; cursor: default; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;"
|
||||
/>
|
||||
` : `
|
||||
`
|
||||
: `
|
||||
<label for="childFilter">Child:</label>
|
||||
<select id="childFilter" onchange="onChildChange(event)">
|
||||
${childOptions}
|
||||
</select>
|
||||
`}
|
||||
`
|
||||
}
|
||||
|
||||
<label for="daysRange">Time Range:</label>
|
||||
<select id="daysRange" onchange="onDaysRangeChange(event)">
|
||||
|
||||
@@ -252,11 +252,11 @@
|
||||
// Determine return URL based on referrer
|
||||
function getReturnUrl() {
|
||||
const referrer = document.referrer;
|
||||
if (referrer.includes('/diapers.html')) {
|
||||
return '/diapers.html';
|
||||
if (referrer.includes("/diapers.html")) {
|
||||
return "/diapers.html";
|
||||
}
|
||||
// Default to home page
|
||||
return '/';
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Check if we're in edit mode
|
||||
@@ -305,7 +305,7 @@
|
||||
`;
|
||||
} else {
|
||||
// Multiple children: show dropdown (clear the placeholder first)
|
||||
select.innerHTML = '';
|
||||
select.innerHTML = "";
|
||||
children.forEach((child) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = child.id;
|
||||
|
||||
@@ -209,11 +209,11 @@
|
||||
// Determine return URL based on referrer
|
||||
function getReturnUrl() {
|
||||
const referrer = document.referrer;
|
||||
if (referrer.includes('/feedings.html')) {
|
||||
return '/feedings.html';
|
||||
if (referrer.includes("/feedings.html")) {
|
||||
return "/feedings.html";
|
||||
}
|
||||
// Default to home page
|
||||
return '/';
|
||||
return "/";
|
||||
}
|
||||
|
||||
const form = document.getElementById("logFeedingForm");
|
||||
@@ -287,7 +287,7 @@
|
||||
`;
|
||||
} else {
|
||||
// Multiple children: show dropdown (clear placeholder first)
|
||||
childSelect.innerHTML = '';
|
||||
childSelect.innerHTML = "";
|
||||
children.forEach((child) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = child.id;
|
||||
|
||||
@@ -199,11 +199,11 @@
|
||||
// Determine return URL based on referrer
|
||||
function getReturnUrl() {
|
||||
const referrer = document.referrer;
|
||||
if (referrer.includes('/sleep.html')) {
|
||||
return '/sleep.html';
|
||||
if (referrer.includes("/sleep.html")) {
|
||||
return "/sleep.html";
|
||||
}
|
||||
// Default to home page
|
||||
return '/';
|
||||
return "/";
|
||||
}
|
||||
|
||||
const form = document.getElementById("logSleepForm");
|
||||
@@ -277,7 +277,7 @@
|
||||
`;
|
||||
} else {
|
||||
// Multiple children: show dropdown (clear placeholder first)
|
||||
childSelect.innerHTML = '';
|
||||
childSelect.innerHTML = "";
|
||||
children.forEach((child) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = child.id;
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
|
||||
.shared-badge {
|
||||
display: inline-block;
|
||||
background: #4CAF50;
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
@@ -510,20 +510,30 @@
|
||||
<div style="margin-bottom: 20px">
|
||||
<h3 style="color: #333; margin-bottom: 10px" id="editChildName"></h3>
|
||||
<div style="color: #666; font-size: 14px">
|
||||
<p><strong>Birth Date:</strong> <span id="editChildBirthDate"></span></p>
|
||||
<p><strong>Birth Weight:</strong> <span id="editChildBirthWeight"></span>g</p>
|
||||
<p>
|
||||
<strong>Birth Date:</strong> <span id="editChildBirthDate"></span>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Birth Weight:</strong>
|
||||
<span id="editChildBirthWeight"></span>g
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sharedUsersSection" style="margin-bottom: 20px; display: none">
|
||||
<h3 style="color: #333; font-size: 16px; margin-bottom: 10px">👥 Shared With</h3>
|
||||
<div id="sharedUsersList" style="
|
||||
<h3 style="color: #333; font-size: 16px; margin-bottom: 10px">
|
||||
👥 Shared With
|
||||
</h3>
|
||||
<div
|
||||
id="sharedUsersList"
|
||||
style="
|
||||
background: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
"></div>
|
||||
"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@@ -607,7 +617,7 @@
|
||||
<div class="child-card">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<h3 style="margin: 0;">👶 ${child.name}</h3>
|
||||
${child.parent_count > 1 ? '<span class="shared-badge">Shared</span>' : ''}
|
||||
${child.parent_count > 1 ? '<span class="shared-badge">Shared</span>' : ""}
|
||||
</div>
|
||||
<div class="child-info">
|
||||
<p><strong>Birth Date:</strong> ${formatDate(child.birth_time)}</p>
|
||||
@@ -644,9 +654,13 @@
|
||||
if (!child) return;
|
||||
|
||||
// Populate modal with child information
|
||||
document.getElementById("editChildName").textContent = `👶 ${child.name}`;
|
||||
document.getElementById("editChildBirthDate").textContent = formatDate(child.birth_time);
|
||||
document.getElementById("editChildBirthWeight").textContent = child.birth_weight;
|
||||
document.getElementById("editChildName").textContent =
|
||||
`👶 ${child.name}`;
|
||||
document.getElementById("editChildBirthDate").textContent = formatDate(
|
||||
child.birth_time,
|
||||
);
|
||||
document.getElementById("editChildBirthWeight").textContent =
|
||||
child.birth_weight;
|
||||
|
||||
// Show shared users if child is shared
|
||||
const sharedSection = document.getElementById("sharedUsersSection");
|
||||
@@ -654,13 +668,18 @@
|
||||
|
||||
if (child.parent_usernames && child.parent_usernames.length > 1) {
|
||||
// Filter out current user and show other users
|
||||
const otherUsers = child.parent_usernames.filter(username => username !== currentUser.username);
|
||||
const otherUsers = child.parent_usernames.filter(
|
||||
(username) => username !== currentUser.username,
|
||||
);
|
||||
|
||||
if (otherUsers.length > 0) {
|
||||
sharedSection.style.display = "block";
|
||||
sharedList.innerHTML = otherUsers.map(username =>
|
||||
`<div style="padding: 5px 0;">• ${username}</div>`
|
||||
).join("");
|
||||
sharedList.innerHTML = otherUsers
|
||||
.map(
|
||||
(username) =>
|
||||
`<div style="padding: 5px 0;">• ${username}</div>`,
|
||||
)
|
||||
.join("");
|
||||
} else {
|
||||
sharedSection.style.display = "none";
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@
|
||||
}
|
||||
|
||||
// Populate child filter or show single child
|
||||
const childFilterContainer = document.querySelector('.controls');
|
||||
const childFilterContainer = document.querySelector(".controls");
|
||||
if (allChildren.length === 1) {
|
||||
// Single child: show as read-only text
|
||||
const child = allChildren[0];
|
||||
@@ -401,7 +401,7 @@
|
||||
} else {
|
||||
// Multiple children: show dropdown
|
||||
const childFilter = document.getElementById("childFilter");
|
||||
childFilter.innerHTML = '';
|
||||
childFilter.innerHTML = "";
|
||||
allChildren.forEach((child) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = child.id;
|
||||
|
||||
Reference in New Issue
Block a user