|
301 | 301 | for_el_with_class( |
302 | 302 | script, |
303 | 303 | class_name, |
304 | | - (el) => (el.style.display = "hidden"), |
| 304 | + (el) => (el.style.display = "none"), |
305 | 305 | ); |
306 | 306 | } |
307 | 307 | </script> |
|
375 | 375 | </div> |
376 | 376 |
|
377 | 377 | <div |
| 378 | + class="manage-notes" |
378 | 379 | style=" |
379 | 380 | padding: 1.5em 0; |
380 | 381 | display: flex; |
|
408 | 409 | class="suggested-action" |
409 | 410 | onclick=" |
410 | 411 | { |
411 | | - const on_add_note = () => { |
412 | | -
|
| 412 | + const on_add_new_note = () => { |
| 413 | + this.closest('.manage-notes').update_manage_notes(); |
413 | 414 | }; |
| 415 | + {{ fn_add_new_note | replace(from="<js_callback>", to="on_add_new_note") | safe }} |
414 | 416 | } |
415 | | -
|
416 | | - {{ fn_add_new_note | safe }} |
417 | 417 | " |
418 | 418 | > |
419 | 419 | <svg class="icon"> |
|
428 | 428 | <div style="flex: 1; position: relative"> |
429 | 429 | <button |
430 | 430 | title="{{ config.s_add_duplicate_note }}" |
431 | | - onclick="{{ fn_add_duplicate_note | safe }}" |
| 431 | + onclick=" |
| 432 | + { |
| 433 | + const on_add_new_note = () => { |
| 434 | + this.closest('.manage-notes').update_manage_notes(); |
| 435 | + }; |
| 436 | + {{ fn_add_duplicate_note | replace(from="<js_callback>", to="on_add_new_note") | safe }} |
| 437 | + } |
| 438 | + " |
432 | 439 | style="flex: 1; position: relative" |
433 | 440 | > |
434 | 441 | <svg class="icon"> |
|
454 | 461 | <script> |
455 | 462 | { |
456 | 463 | const script = document.currentScript; |
457 | | - |
458 | | - const on_num_existing_notes = (num) => { |
459 | | - hide_with_class(script, "add-note"); |
460 | | - hide_with_class(script, "note-actions"); |
461 | | - hide_with_class(script, "multiple-notes"); |
462 | | - |
463 | | - if (num > 0) { |
464 | | - show_with_class(script, "note-actions"); |
465 | | - if (num > 1) { |
466 | | - for_el_with_class(script, "multiple-notes", (el) => { |
467 | | - el.style.display = "flex"; |
468 | | - el.innerHTML = `${num}`; |
469 | | - }); |
| 464 | + function update_manage_notes() { |
| 465 | + const on_num_existing_notes = (num) => { |
| 466 | + hide_with_class(script, "add-note"); |
| 467 | + hide_with_class(script, "note-actions"); |
| 468 | + hide_with_class(script, "multiple-notes"); |
| 469 | + |
| 470 | + if (num > 0) { |
| 471 | + show_with_class(script, "note-actions"); |
| 472 | + if (num > 1) { |
| 473 | + for_el_with_class(script, "multiple-notes", (el) => { |
| 474 | + el.style.display = "flex"; |
| 475 | + el.innerHTML = `${num}`; |
| 476 | + }); |
| 477 | + } |
| 478 | + } else { |
| 479 | + show_with_class(script, "add-note"); |
470 | 480 | } |
471 | | - } else { |
472 | | - show_with_class(script, "add-note"); |
473 | | - } |
474 | | - }; |
| 481 | + }; |
475 | 482 |
|
476 | | - // prettier-ignore |
477 | | - {{ fn_num_existing_notes | replace(from="<js_callback>", to="on_num_existing_notes") | safe }} |
| 483 | + // prettier-ignore |
| 484 | + {{ fn_num_existing_notes | replace(from="<js_callback>", to="on_num_existing_notes") | safe }} |
| 485 | + } |
| 486 | + script.parentElement.update_manage_notes = update_manage_notes; |
| 487 | + update_manage_notes(); |
478 | 488 | } |
479 | 489 | </script> |
480 | 490 | </div> |
|
0 commit comments