627 lines
18 KiB
HTML
627 lines
18 KiB
HTML
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
|
/>
|
|
<title>HouseHub - Planning Repas</title>
|
|
<style>
|
|
/* --- VARIABLES --- */
|
|
:root {
|
|
--primary: #3b82f6;
|
|
--bg-page: #f8fafc;
|
|
--bg-panel: #ffffff;
|
|
--bg-subtle: #f1f5f9;
|
|
--text-main: #0f172a;
|
|
--text-muted: #64748b;
|
|
--border-light: #e2e8f0;
|
|
--border-strong: #cbd5e1;
|
|
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
|
--shadow-lg: 0 -4px 20px rgba(0, 0, 0, 0.15);
|
|
--alert-success-bg: #dcfce7;
|
|
}
|
|
|
|
body {
|
|
font-family:
|
|
"Inter",
|
|
-apple-system,
|
|
sans-serif;
|
|
background: var(--bg-page);
|
|
color: var(--text-main);
|
|
margin: 0;
|
|
padding: 10px;
|
|
overscroll-behavior-y: none;
|
|
padding-bottom: 70px; /* Espace pour la toolbar fixe */
|
|
}
|
|
|
|
/* --- EN-TÊTE --- */
|
|
.header-bar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 12px;
|
|
}
|
|
.header-bar h1 {
|
|
margin: 0;
|
|
font-size: 1.3rem;
|
|
color: var(--text-main);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.pf-btn {
|
|
background: var(--bg-panel);
|
|
color: var(--text-main);
|
|
border: 1px solid var(--border-strong);
|
|
padding: 8px 12px;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
font-size: 0.85rem;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
.pf-btn.primary {
|
|
background: var(--primary);
|
|
color: white;
|
|
border-color: var(--primary);
|
|
}
|
|
|
|
/* --- MATRICE ULTRA-COMPACTE --- */
|
|
.meals-wrapper {
|
|
background: var(--bg-panel);
|
|
border-radius: 8px;
|
|
border: 1px solid var(--border-strong);
|
|
box-shadow: var(--shadow-sm);
|
|
overflow: hidden;
|
|
}
|
|
.meals-table {
|
|
width: 100%;
|
|
table-layout: fixed;
|
|
border-collapse: collapse;
|
|
}
|
|
.meals-table th,
|
|
.meals-table td {
|
|
border: 1px solid var(--border-light);
|
|
padding: 0;
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
}
|
|
.meals-table th {
|
|
background: var(--bg-subtle);
|
|
font-size: 0.6rem;
|
|
font-weight: 800;
|
|
color: var(--text-muted);
|
|
padding: 6px 2px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.col-sticky {
|
|
width: 40px;
|
|
background: var(--bg-subtle);
|
|
border-right: 2px solid var(--border-strong) !important;
|
|
padding: 4px 2px !important;
|
|
}
|
|
.day-label {
|
|
font-size: 0.65rem;
|
|
font-weight: 800;
|
|
color: var(--text-main);
|
|
text-transform: uppercase;
|
|
display: block;
|
|
margin-bottom: 2px;
|
|
}
|
|
.day-label.invisible {
|
|
visibility: hidden;
|
|
height: 0;
|
|
margin: 0;
|
|
}
|
|
.service-icon {
|
|
background: white;
|
|
border: 1px solid var(--border-strong);
|
|
border-radius: 6px;
|
|
font-size: 1rem;
|
|
width: 26px;
|
|
height: 26px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto;
|
|
cursor: pointer;
|
|
box-shadow: var(--shadow-sm);
|
|
transition: transform 0.1s;
|
|
}
|
|
.service-icon:active {
|
|
transform: scale(0.9);
|
|
}
|
|
|
|
.row-lunch td {
|
|
border-top: 2px solid var(--border-strong) !important;
|
|
}
|
|
.row-dinner td {
|
|
border-top: 1px dashed var(--border-light);
|
|
}
|
|
|
|
.meal-input-cell {
|
|
position: relative;
|
|
height: 100%;
|
|
background: var(--bg-panel);
|
|
}
|
|
.meal-input {
|
|
width: 100%;
|
|
height: 44px;
|
|
border: none;
|
|
background: transparent;
|
|
text-align: center;
|
|
font-size: 0.75rem;
|
|
padding: 4px;
|
|
color: var(--text-main);
|
|
font-family: inherit;
|
|
resize: none;
|
|
box-sizing: border-box;
|
|
outline: none;
|
|
}
|
|
.meal-input:focus {
|
|
background: #eff6ff;
|
|
}
|
|
|
|
/* --- BARRE CONTEXTUELLE (FIXE EN BAS) --- */
|
|
.context-toolbar {
|
|
position: fixed;
|
|
bottom: -80px;
|
|
left: 0;
|
|
right: 0;
|
|
height: 60px;
|
|
background: var(--bg-panel);
|
|
border-top: 1px solid var(--border-strong);
|
|
box-shadow: var(--shadow-lg);
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 12px;
|
|
transition: bottom 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
z-index: 1000;
|
|
padding: 0 10px;
|
|
}
|
|
.context-toolbar.active {
|
|
bottom: 0;
|
|
}
|
|
.ctx-btn {
|
|
background: var(--bg-subtle);
|
|
border: 1px solid var(--border-strong);
|
|
border-radius: 8px;
|
|
padding: 10px 16px;
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
color: var(--text-main);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
.ctx-btn.primary {
|
|
background: var(--primary);
|
|
color: white;
|
|
border-color: var(--primary);
|
|
}
|
|
|
|
/* --- MODALE : COPIER VERS (DESIGN GRILLE) --- */
|
|
.pf-modal {
|
|
display: none;
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(15, 23, 42, 0.6);
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 2000;
|
|
}
|
|
.pf-modal.open {
|
|
display: flex;
|
|
animation: fadeInBg 0.2s;
|
|
}
|
|
.pf-modal-content {
|
|
background: var(--bg-panel);
|
|
width: 95%;
|
|
max-width: 600px;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
box-sizing: border-box;
|
|
box-shadow: var(--shadow-lg);
|
|
max-height: 90vh;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 8px;
|
|
}
|
|
.modal-title {
|
|
margin: 0;
|
|
font-size: 1.1rem;
|
|
color: var(--text-main);
|
|
font-weight: 800;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.modal-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 1.8rem;
|
|
cursor: pointer;
|
|
color: var(--text-muted);
|
|
line-height: 1;
|
|
margin-top: -5px;
|
|
}
|
|
.modal-source {
|
|
font-size: 0.85rem;
|
|
color: var(--text-muted);
|
|
font-weight: 600;
|
|
margin: 0 0 20px 0;
|
|
}
|
|
|
|
/* Grille des Jours */
|
|
.week-section-title {
|
|
background: var(--bg-subtle);
|
|
text-align: center;
|
|
padding: 6px;
|
|
font-weight: 700;
|
|
font-size: 0.85rem;
|
|
color: var(--text-muted);
|
|
border-radius: 4px;
|
|
margin: 15px 0 10px 0;
|
|
text-transform: uppercase;
|
|
border: 1px solid var(--border-light);
|
|
}
|
|
|
|
.days-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(4, 1fr);
|
|
gap: 10px;
|
|
}
|
|
|
|
.day-card {
|
|
background: var(--bg-panel);
|
|
border: 1px solid var(--border-light);
|
|
border-radius: 8px;
|
|
padding: 8px 4px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8px;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
.day-card-title {
|
|
font-size: 0.8rem;
|
|
font-weight: 700;
|
|
color: var(--text-main);
|
|
}
|
|
.day-card-actions {
|
|
display: flex;
|
|
gap: 6px;
|
|
justify-content: center;
|
|
width: 100%;
|
|
}
|
|
.day-action-btn {
|
|
background: var(--bg-page);
|
|
border: 1px solid var(--border-strong);
|
|
border-radius: 6px;
|
|
width: 30px;
|
|
height: 30px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 1rem;
|
|
cursor: pointer;
|
|
transition: 0.1s;
|
|
}
|
|
.day-action-btn:active {
|
|
transform: scale(0.9);
|
|
background: #e2e8f0;
|
|
}
|
|
|
|
@media (max-width: 380px) {
|
|
.days-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
}
|
|
}
|
|
@keyframes fadeInBg {
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header-bar">
|
|
<h1>
|
|
<span style="opacity: 0.5">🍽️</span>
|
|
<span data-i18n="meals_board_title">Planning Repas</span>
|
|
</h1>
|
|
<button class="pf-btn" title="Générer les courses">
|
|
🛒 <span data-i18n="btn_groceries">Courses</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- BARRE CONTEXTUELLE FIXE (Évite le conflit avec le clavier mobile) -->
|
|
<div class="context-toolbar" id="contextToolbar">
|
|
<button
|
|
class="ctx-btn"
|
|
onmousedown="
|
|
event.preventDefault();
|
|
applyToAllInRow();
|
|
"
|
|
>
|
|
➡️ <span data-i18n="btn_apply_all">Tous</span>
|
|
</button>
|
|
<button
|
|
class="ctx-btn primary"
|
|
onmousedown="
|
|
event.preventDefault();
|
|
openCopySheetFromCell();
|
|
"
|
|
>
|
|
🔄 <span data-i18n="btn_copy_to">Copier vers...</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="meals-wrapper">
|
|
<table class="meals-table" id="mealsTable">
|
|
<thead>
|
|
<tr>
|
|
<th class="col-sticky"></th>
|
|
<th>PAPA</th>
|
|
<th>MAMAN</th>
|
|
<th>E1</th>
|
|
<th>E2</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<!-- Injecté via JS -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- MODALE DE COPIE (GRILLE LUNDI-DIMANCHE) -->
|
|
<div id="copyModal" class="pf-modal">
|
|
<div class="pf-modal-content">
|
|
<div class="modal-header">
|
|
<h3 class="modal-title">
|
|
🔄 <span data-i18n="modal_copy_title">Copier vers...</span>
|
|
</h3>
|
|
<button class="modal-close" onclick="closeCopyModal()">
|
|
×
|
|
</button>
|
|
</div>
|
|
<div id="copySourceLabel" class="modal-source">
|
|
Source : Plat individuel (Lundi Midi)
|
|
</div>
|
|
|
|
<div class="week-section-title" data-i18n="week_current">
|
|
Semaine actuelle
|
|
</div>
|
|
<div class="days-grid" id="currentWeekGrid"></div>
|
|
|
|
<div class="week-section-title" data-i18n="week_next">
|
|
Semaine prochaine
|
|
</div>
|
|
<div class="days-grid" id="nextWeekGrid"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// --- I18N MOCKUP ---
|
|
window.I18N = {
|
|
meals_board_title: "Planning Repas",
|
|
btn_groceries: "Courses",
|
|
btn_apply_all: "Tous",
|
|
btn_copy_to: "Copier vers...",
|
|
modal_copy_title: "Copier vers...",
|
|
source_individual: "Plat individuel",
|
|
source_row: "Repas complet",
|
|
week_current: "Semaine actuelle",
|
|
week_next: "Semaine prochaine",
|
|
};
|
|
document
|
|
.querySelectorAll("[data-i18n]")
|
|
.forEach(
|
|
(el) => (el.innerHTML = window.I18N[el.getAttribute("data-i18n")]),
|
|
);
|
|
|
|
const days = ["Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"];
|
|
const fullDays = [
|
|
"Lundi",
|
|
"Mardi",
|
|
"Mercredi",
|
|
"Jeudi",
|
|
"Vendredi",
|
|
"Samedi",
|
|
"Dimanche",
|
|
];
|
|
const membersCount = 4;
|
|
const tbody = document.querySelector("#mealsTable tbody");
|
|
|
|
let copyState = {
|
|
type: null,
|
|
dayIdx: null,
|
|
service: null,
|
|
personIdx: null,
|
|
sourceElements: [],
|
|
};
|
|
|
|
// --- 1. GÉNÉRATION DE LA GRILLE PRINCIPALE ---
|
|
days.forEach((day, index) => {
|
|
let trLunch = document.createElement("tr");
|
|
trLunch.className = "row-lunch";
|
|
trLunch.innerHTML = `
|
|
<td class="col-sticky">
|
|
<span class="day-label">${day}</span>
|
|
<div class="service-icon" onclick="openCopySheetFromRow(${index}, 'lunch')" title="Copier la ligne">☀️</div>
|
|
</td>`;
|
|
for (let p = 0; p < membersCount; p++) {
|
|
trLunch.innerHTML += `<td class="meal-input-cell"><textarea class="meal-input js-meal-input" data-d="${index}" data-s="lunch" data-p="${p}" placeholder="-"></textarea></td>`;
|
|
}
|
|
tbody.appendChild(trLunch);
|
|
|
|
let trDinner = document.createElement("tr");
|
|
trDinner.className = "row-dinner";
|
|
trDinner.innerHTML = `
|
|
<td class="col-sticky">
|
|
<span class="day-label invisible">${day}</span>
|
|
<div class="service-icon" onclick="openCopySheetFromRow(${index}, 'dinner')" title="Copier la ligne">🌙</div>
|
|
</td>`;
|
|
for (let p = 0; p < membersCount; p++) {
|
|
trDinner.innerHTML += `<td class="meal-input-cell"><textarea class="meal-input js-meal-input" data-d="${index}" data-s="dinner" data-p="${p}" placeholder="-"></textarea></td>`;
|
|
}
|
|
tbody.appendChild(trDinner);
|
|
});
|
|
|
|
// --- 2. GÉNÉRATION DES GRILLES DE LA MODALE COPIE ---
|
|
function buildModalGrid(containerId, weekTarget) {
|
|
const container = document.getElementById(containerId);
|
|
let html = "";
|
|
fullDays.forEach((dayName, idx) => {
|
|
html += `
|
|
<div class="day-card">
|
|
<div class="day-card-title">${dayName}</div>
|
|
<div class="day-card-actions">
|
|
<button type="button" class="day-action-btn" onclick="executeCopy(${idx}, 'lunch', '${weekTarget}')">☀️</button>
|
|
<button type="button" class="day-action-btn" onclick="executeCopy(${idx}, 'dinner', '${weekTarget}')">🌙</button>
|
|
</div>
|
|
</div>`;
|
|
});
|
|
container.innerHTML = html;
|
|
}
|
|
buildModalGrid("currentWeekGrid", "current");
|
|
buildModalGrid("nextWeekGrid", "next");
|
|
|
|
// --- 3. GESTION DU FOCUS & DE LA TOOLBAR ---
|
|
document.addEventListener("focusin", (e) => {
|
|
if (e.target.classList.contains("js-meal-input")) {
|
|
copyState = {
|
|
type: "cell",
|
|
dayIdx: e.target.getAttribute("data-d"),
|
|
service: e.target.getAttribute("data-s"),
|
|
personIdx: e.target.getAttribute("data-p"),
|
|
sourceElements: [e.target],
|
|
};
|
|
document.getElementById("contextToolbar").classList.add("active");
|
|
}
|
|
});
|
|
|
|
document.addEventListener("focusout", (e) => {
|
|
setTimeout(() => {
|
|
if (!document.activeElement.classList.contains("js-meal-input")) {
|
|
document
|
|
.getElementById("contextToolbar")
|
|
.classList.remove("active");
|
|
}
|
|
}, 150);
|
|
});
|
|
|
|
function flashSuccess(input) {
|
|
input.style.transition = "background 0.3s";
|
|
input.style.background = "var(--alert-success-bg)";
|
|
setTimeout(() => (input.style.background = "transparent"), 400);
|
|
}
|
|
|
|
// --- 4. ACTIONS DE COPIE ---
|
|
function applyToAllInRow() {
|
|
if (
|
|
copyState.type !== "cell" ||
|
|
!copyState.sourceElements[0].value.trim()
|
|
)
|
|
return;
|
|
const val = copyState.sourceElements[0].value;
|
|
const inputs = document.querySelectorAll(
|
|
`.js-meal-input[data-d="${copyState.dayIdx}"][data-s="${copyState.service}"]`,
|
|
);
|
|
inputs.forEach((inp) => {
|
|
if (inp !== copyState.sourceElements[0]) {
|
|
inp.value = val;
|
|
flashSuccess(inp);
|
|
}
|
|
});
|
|
}
|
|
|
|
function openCopySheetFromCell() {
|
|
if (
|
|
!copyState.sourceElements[0] ||
|
|
!copyState.sourceElements[0].value.trim()
|
|
)
|
|
return;
|
|
document.getElementById("contextToolbar").classList.remove("active");
|
|
document.activeElement.blur(); // Masque le clavier mobile
|
|
|
|
const svcLabel = copyState.service === "lunch" ? "Midi" : "Soir";
|
|
document.getElementById("copySourceLabel").innerText =
|
|
`Source : ${window.I18N.source_individual} (${fullDays[copyState.dayIdx]} ${svcLabel})`;
|
|
document.getElementById("copyModal").classList.add("open");
|
|
document.body.classList.add("no-scroll");
|
|
}
|
|
|
|
function openCopySheetFromRow(dIdx, service) {
|
|
const inputs = document.querySelectorAll(
|
|
`.js-meal-input[data-d="${dIdx}"][data-s="${service}"]`,
|
|
);
|
|
const hasContent = Array.from(inputs).some(
|
|
(inp) => inp.value.trim() !== "",
|
|
);
|
|
if (!hasContent) return;
|
|
|
|
copyState = {
|
|
type: "row",
|
|
dayIdx: dIdx,
|
|
service: service,
|
|
sourceElements: Array.from(inputs),
|
|
};
|
|
const svcLabel = service === "lunch" ? "Midi" : "Soir";
|
|
document.getElementById("copySourceLabel").innerText =
|
|
`Source : ${window.I18N.source_row} (${fullDays[dIdx]} ${svcLabel})`;
|
|
document.getElementById("copyModal").classList.add("open");
|
|
document.body.classList.add("no-scroll");
|
|
}
|
|
|
|
function closeCopyModal() {
|
|
document.getElementById("copyModal").classList.remove("open");
|
|
document.body.classList.remove("no-scroll");
|
|
}
|
|
|
|
function executeCopy(targetDayIdx, targetService, targetWeek) {
|
|
if (targetWeek === "next") {
|
|
alert("Simulation : Copié avec succès vers la SEMAINE PROCHAINE !");
|
|
closeCopyModal();
|
|
return;
|
|
}
|
|
|
|
if (copyState.type === "cell") {
|
|
const val = copyState.sourceElements[0].value;
|
|
const targetInput = document.querySelector(
|
|
`.js-meal-input[data-d="${targetDayIdx}"][data-s="${targetService}"][data-p="${copyState.personIdx}"]`,
|
|
);
|
|
if (targetInput) {
|
|
targetInput.value = val;
|
|
flashSuccess(targetInput);
|
|
}
|
|
} else if (copyState.type === "row") {
|
|
const targetInputs = document.querySelectorAll(
|
|
`.js-meal-input[data-d="${targetDayIdx}"][data-s="${targetService}"]`,
|
|
);
|
|
copyState.sourceElements.forEach((inp, idx) => {
|
|
if (inp.value.trim() !== "") {
|
|
targetInputs[idx].value = inp.value;
|
|
flashSuccess(targetInputs[idx]);
|
|
}
|
|
});
|
|
}
|
|
closeCopyModal();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|