Board: all people visible in the name picker, PIN enters itself, no number before shopping items
build-container / build (push) Successful in 3m35s
build-container / build (push) Successful in 3m35s
- Name picker wraps in a wider box so five or more people fit - The board knows each PIN's length and submits when the last digit is typed - Shopping items typed in are added with no quantity and shown without Mealie's leading 1 - Test updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96b00108bb
commit
a45fc1b89c
6 files changed
+13
-12
No files matched your search
+3
-3
@@ -53,7 +53,7 @@ const whoFile = () => path.join(process.env.DATA_DIR || path.join(__dirname, 'da
|
||||
let whoMap = null; const whoAll = () => whoMap || (whoMap = (() => { try { return JSON.parse(fs.readFileSync(whoFile(), 'utf8')); } catch { return {}; } })());
|
||||
const whoKey = t => String(t || '').toLowerCase().replace(/\s+/g, ' ').trim();
|
||||
const rememberWho = (text, name) => { const m = whoAll(), k = whoKey(text); m[k] = { by: name, at: Date.now() }; const keys = Object.keys(m); if (keys.length > 500) for (const o of keys.sort((a, b) => m[a].at - m[b].at).slice(0, keys.length - 400)) delete m[o]; try { fs.mkdirSync(path.dirname(whoFile()), { recursive: true }); require('./atomic')(whoFile(), JSON.stringify(m)); } catch {} };
|
||||
const itemOut0 = i => ({ id: i.id, text: String(i.display || i.note || (i.food && i.food.name) || '').trim(), checked: !!i.checked, label: (i.label && i.label.name) || '', position: i.position || 0 });
|
||||
const itemOut0 = i => ({ id: i.id, text: String((i.food ? i.display || i.note : i.note || i.display) || (i.food && i.food.name) || '').trim() /* (something typed in has no food: show just the words, without the "1" Mealie puts in front) */, checked: !!i.checked, label: (i.label && i.label.name) || '', position: i.position || 0 });
|
||||
const itemOut = i => { const o = itemOut0(i); o.by = (whoAll()[whoKey(o.text)] || {}).by || ''; return o; };
|
||||
async function mainList() { // the first shopping list (the one called "Shopping List" if there is more than one)
|
||||
const l = await shop('/lists?perPage=50'), items = Array.isArray(l) ? l : l.items || [];
|
||||
@@ -90,7 +90,7 @@ async function sync() {
|
||||
for (const t of mine) {
|
||||
if (t.mealieId && !ids.has(t.mealieId)) { d.tasks = d.tasks.filter(x => x !== t); out.removed++; continue; } // gone from Mealie
|
||||
if (!t.mealieId && !t.done && t.title) { // typed straight into the Shopping list in Tasks
|
||||
const n = await shop('/items', { method: 'POST', body: { shoppingListId: list.id, note: t.title, quantity: 1, checked: false } }), made = n && (n.createdItems ? n.createdItems[0] : n);
|
||||
const n = await shop('/items', { method: 'POST', body: { shoppingListId: list.id, note: t.title, quantity: 0, checked: false } }), made = n && (n.createdItems ? n.createdItems[0] : n);
|
||||
if (made && made.id) { t.mealieId = made.id; t.mealieChecked = false; ids.add(made.id); } out.sent++;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ async function handle(req, res) {
|
||||
}
|
||||
if (p === '/shopping/add' && req.method === 'POST') {
|
||||
const b = JSON.parse(await readBody(req, 1e4) || '{}'), text = String(b.text || '').trim().slice(0, 200); if (!text) throw fail(400, 'Type what to buy');
|
||||
const list = await mainList(); await shop('/items', { method: 'POST', body: { shoppingListId: list.id, note: text, quantity: 1, checked: false } }); rememberWho(text, users.current().name); await sync(); return json(res, 200, { ok: true });
|
||||
const list = await mainList(); await shop('/items', { method: 'POST', body: { shoppingListId: list.id, note: text, quantity: 0, checked: false } }); rememberWho(text, users.current().name); await sync(); return json(res, 200, { ok: true });
|
||||
}
|
||||
if (p === '/shopping/check' && req.method === 'POST') {
|
||||
const b = JSON.parse(await readBody(req, 1e4) || '{}'); if (!idOk(b.id)) throw fail(400, 'Bad item');
|
||||
|
||||
Reference in new issue
Block a user