benresnic commited on
Commit
03d45a7
·
verified ·
1 Parent(s): ef329eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -81
app.py CHANGED
@@ -209,8 +209,7 @@ app_ui = ui.page_fluid(
209
  #add-btn:hover{ filter: brightness(.97); }
210
 
211
  .err{
212
- max-width: 1200px;
213
- margin: 0 auto 10px auto;
214
  padding: 10px 12px;
215
  border-radius: 10px;
216
  background: #fff1f2;
@@ -220,21 +219,21 @@ app_ui = ui.page_fluid(
220
  display:none;
221
  }
222
 
223
- /* GRID: 2 columns, bigger spacing, centered */
224
  .cards-grid{
225
  display:grid;
226
- grid-template-columns: repeat(2, minmax(480px, 1fr));
227
  gap: 22px;
228
  padding: 10px 16px 22px 16px;
229
- max-width: 1200px;
230
- margin: 0 auto;
231
  align-items:start;
232
  }
233
- @media (max-width: 1050px){
234
  .cards-grid{ grid-template-columns: 1fr; }
235
  }
236
 
237
- /* Card = true square & big */
238
  .card{
239
  background: var(--cardBg);
240
  border: 1px solid var(--cardBorder);
@@ -303,9 +302,9 @@ app_ui = ui.page_fluid(
303
  background: white;
304
  }
305
 
306
- /* Each textarea shows ~3-4 lines by default */
307
  textarea.ta{
308
- height: 92px; /* ~4 lines depending on font */
309
  line-height: 1.25;
310
  resize: none;
311
  overflow: auto;
@@ -318,8 +317,7 @@ app_ui = ui.page_fluid(
318
  }
319
 
320
  .empty{
321
- max-width: 1200px;
322
- margin: 0 auto;
323
  padding: 18px;
324
  background: white;
325
  border: 1px dashed #cfd9ea;
@@ -327,39 +325,40 @@ app_ui = ui.page_fluid(
327
  color: #41516b;
328
  }
329
 
330
- /* Delete modal */
331
- .modal-backdrop{
332
  position: fixed;
333
  inset: 0;
334
  background: rgba(0,0,0,.35);
335
  display:flex;
336
  align-items:center;
337
  justify-content:center;
338
- z-index: 99999;
339
  }
340
- .modal{
341
  width: min(560px, calc(100vw - 28px));
342
  background: white;
343
  border-radius: 14px;
344
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
345
  padding: 14px 14px 12px 14px;
 
346
  }
347
- .modal h3{
348
  margin: 0 0 8px 0;
349
  font-size: 16px;
350
  }
351
- .modal .muted{
352
  color: var(--muted);
353
  font-size: 13px;
354
  margin-bottom: 10px;
355
  }
356
- .modal .checks{
357
  display:flex;
358
  flex-direction:column;
359
  gap: 8px;
360
  margin: 10px 0;
361
  }
362
- .modal .checks label{
363
  margin: 0;
364
  font-weight: 650;
365
  font-size: 13px;
@@ -368,7 +367,7 @@ app_ui = ui.page_fluid(
368
  align-items:center;
369
  gap: 8px;
370
  }
371
- .modal .actions{
372
  display:flex;
373
  gap: 10px;
374
  justify-content:flex-end;
@@ -441,15 +440,6 @@ app_ui = ui.page_fluid(
441
  .replaceAll(">", ">");
442
  }
443
 
444
- function fallbackDelete(cardId){
445
- // 3 checks fallback (browser-native)
446
- if(!confirm("Delete this card? This is permanent.")) return;
447
- if(!confirm("Second check: confirm you REALLY want to delete.")) return;
448
- const typed = prompt('Final check: type DELETE to confirm');
449
- if(typed !== "DELETE") return;
450
- return doDelete(cardId);
451
- }
452
-
453
  async function doDelete(cardId){
454
  const data = await api(`/api/cards/${encodeURIComponent(cardId)}`, { method: "DELETE" });
455
  state.version = data.version;
@@ -459,69 +449,59 @@ app_ui = ui.page_fluid(
459
  }
460
 
461
  function openDeleteModal(cardId){
462
- try{
463
- const backdrop = document.createElement("div");
464
- backdrop.className = "modal-backdrop";
465
- backdrop.innerHTML = `
466
- <div class="modal" role="dialog" aria-modal="true">
467
- <h3>Delete card?</h3>
468
- <div class="muted">This is permanent and affects everyone viewing this Space.</div>
469
-
470
- <div class="checks">
471
- <label><input type="checkbox" id="chk1" /> I understand this is permanent</label>
472
- <label><input type="checkbox" id="chk2" /> I confirm I want to delete this card</label>
473
- </div>
474
 
475
- <label style="margin:8px 0 4px; color:#1f2a44; font-weight:800;">Type DELETE to confirm</label>
476
- <input type="text" id="typed" value="" />
477
 
478
- <div class="actions">
479
- <button class="btn" id="cancel" type="button">Cancel</button>
480
- <button class="btn btn-danger" id="confirm" type="button" disabled>Delete</button>
481
- </div>
482
  </div>
483
- `;
484
- document.body.appendChild(backdrop);
485
-
486
- const chk1 = backdrop.querySelector("#chk1");
487
- const chk2 = backdrop.querySelector("#chk2");
488
- const typed = backdrop.querySelector("#typed");
489
- const cancel = backdrop.querySelector("#cancel");
490
- const confirmBtn = backdrop.querySelector("#confirm");
 
 
 
 
 
 
 
 
491
 
492
- function updateEnabled(){
493
- confirmBtn.disabled = !(chk1.checked && chk2.checked && (typed.value || "") === "DELETE");
494
- }
495
- chk1.addEventListener("change", updateEnabled);
496
- chk2.addEventListener("change", updateEnabled);
497
- typed.addEventListener("input", updateEnabled);
498
 
499
- function close(){ backdrop.remove(); }
500
- cancel.addEventListener("click", (e) => { e.preventDefault(); close(); });
501
- backdrop.addEventListener("click", (e) => { if(e.target === backdrop) close(); });
502
 
503
- confirmBtn.addEventListener("click", async (e) => {
504
- e.preventDefault();
505
- try{
506
- await doDelete(cardId);
507
- close();
508
- }catch(err){
509
- showErr(String(err.message || err));
510
- close();
511
- }
512
- });
513
 
514
- typed.focus();
515
- }catch(e){
516
- // If anything about modal creation fails, use fallback popups
517
- fallbackDelete(cardId);
518
- }
519
  }
520
 
521
  function render(){
522
  if(state.cards.length === 0){
523
  grid.innerHTML = `<div class="empty"><b>No cards yet.</b><div>Click the + to add your first card.</div></div>`;
524
- // keep the grid as-is; empty block will just sit in first column
525
  return;
526
  }
527
 
 
209
  #add-btn:hover{ filter: brightness(.97); }
210
 
211
  .err{
212
+ margin: 0 16px 10px 16px;
 
213
  padding: 10px 12px;
214
  border-radius: 10px;
215
  background: #fff1f2;
 
219
  display:none;
220
  }
221
 
222
+ /* GRID: 2 columns, FULL WIDTH */
223
  .cards-grid{
224
  display:grid;
225
+ grid-template-columns: repeat(2, minmax(0, 1fr));
226
  gap: 22px;
227
  padding: 10px 16px 22px 16px;
228
+ width: 100%;
229
+ margin: 0;
230
  align-items:start;
231
  }
232
+ @media (max-width: 900px){
233
  .cards-grid{ grid-template-columns: 1fr; }
234
  }
235
 
236
+ /* Card = true square */
237
  .card{
238
  background: var(--cardBg);
239
  border: 1px solid var(--cardBorder);
 
302
  background: white;
303
  }
304
 
305
+ /* ~3–4 lines visible; scroll inside textarea if more */
306
  textarea.ta{
307
+ height: 92px;
308
  line-height: 1.25;
309
  resize: none;
310
  overflow: auto;
 
317
  }
318
 
319
  .empty{
320
+ margin: 0 16px;
 
321
  padding: 18px;
322
  background: white;
323
  border: 1px dashed #cfd9ea;
 
325
  color: #41516b;
326
  }
327
 
328
+ /* DELETE MODAL (renamed to avoid Bootstrap .modal conflicts) */
329
+ .del-backdrop{
330
  position: fixed;
331
  inset: 0;
332
  background: rgba(0,0,0,.35);
333
  display:flex;
334
  align-items:center;
335
  justify-content:center;
336
+ z-index: 999999;
337
  }
338
+ .del-dialog{
339
  width: min(560px, calc(100vw - 28px));
340
  background: white;
341
  border-radius: 14px;
342
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
343
  padding: 14px 14px 12px 14px;
344
+ display:block; /* force visible */
345
  }
346
+ .del-dialog h3{
347
  margin: 0 0 8px 0;
348
  font-size: 16px;
349
  }
350
+ .del-muted{
351
  color: var(--muted);
352
  font-size: 13px;
353
  margin-bottom: 10px;
354
  }
355
+ .del-checks{
356
  display:flex;
357
  flex-direction:column;
358
  gap: 8px;
359
  margin: 10px 0;
360
  }
361
+ .del-checks label{
362
  margin: 0;
363
  font-weight: 650;
364
  font-size: 13px;
 
367
  align-items:center;
368
  gap: 8px;
369
  }
370
+ .del-actions{
371
  display:flex;
372
  gap: 10px;
373
  justify-content:flex-end;
 
440
  .replaceAll(">", "&gt;");
441
  }
442
 
 
 
 
 
 
 
 
 
 
443
  async function doDelete(cardId){
444
  const data = await api(`/api/cards/${encodeURIComponent(cardId)}`, { method: "DELETE" });
445
  state.version = data.version;
 
449
  }
450
 
451
  function openDeleteModal(cardId){
452
+ const backdrop = document.createElement("div");
453
+ backdrop.className = "del-backdrop";
454
+ backdrop.innerHTML = `
455
+ <div class="del-dialog" role="dialog" aria-modal="true">
456
+ <h3>Delete card?</h3>
457
+ <div class="del-muted">This is permanent and affects everyone viewing this Space.</div>
458
+
459
+ <div class="del-checks">
460
+ <label><input type="checkbox" id="chk1" /> I understand this is permanent</label>
461
+ <label><input type="checkbox" id="chk2" /> I confirm I want to delete this card</label>
462
+ </div>
 
463
 
464
+ <label style="margin:8px 0 4px; color:#1f2a44; font-weight:800;">Type DELETE to confirm</label>
465
+ <input type="text" id="typed" value="" />
466
 
467
+ <div class="del-actions">
468
+ <button class="btn" id="cancel" type="button">Cancel</button>
469
+ <button class="btn btn-danger" id="confirm" type="button" disabled>Delete</button>
 
470
  </div>
471
+ </div>
472
+ `;
473
+ document.body.appendChild(backdrop);
474
+
475
+ const chk1 = backdrop.querySelector("#chk1");
476
+ const chk2 = backdrop.querySelector("#chk2");
477
+ const typed = backdrop.querySelector("#typed");
478
+ const cancel = backdrop.querySelector("#cancel");
479
+ const confirmBtn = backdrop.querySelector("#confirm");
480
+
481
+ function updateEnabled(){
482
+ confirmBtn.disabled = !(chk1.checked && chk2.checked && (typed.value || "") === "DELETE");
483
+ }
484
+ chk1.addEventListener("change", updateEnabled);
485
+ chk2.addEventListener("change", updateEnabled);
486
+ typed.addEventListener("input", updateEnabled);
487
 
488
+ function close(){ backdrop.remove(); }
 
 
 
 
 
489
 
490
+ cancel.addEventListener("click", (e) => { e.preventDefault(); close(); });
491
+ backdrop.addEventListener("click", (e) => { if(e.target === backdrop) close(); });
 
492
 
493
+ confirmBtn.addEventListener("click", async (e) => {
494
+ e.preventDefault();
495
+ try { await doDelete(cardId); } catch(err) { showErr(String(err.message || err)); }
496
+ close();
497
+ });
 
 
 
 
 
498
 
499
+ typed.focus();
 
 
 
 
500
  }
501
 
502
  function render(){
503
  if(state.cards.length === 0){
504
  grid.innerHTML = `<div class="empty"><b>No cards yet.</b><div>Click the + to add your first card.</div></div>`;
 
505
  return;
506
  }
507