From 2bac4dfc903ba7953ec8c6da27351b01dfdb062e Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sat, 24 Jan 2026 21:51:49 +0100 Subject: [PATCH] fix: restore copy functionality for confirm modal code snippets Store code snippets as JS variables in components.js and reference them in the template. This avoids multi-line template literals in HTML attributes while still providing copy functionality. Co-Authored-By: Claude Opus 4.5 --- app/templates/admin/components.html | 42 +++++++++++------------------ static/admin/js/components.js | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/app/templates/admin/components.html b/app/templates/admin/components.html index c3b31701..91af3983 100644 --- a/app/templates/admin/components.html +++ b/app/templates/admin/components.html @@ -2626,34 +2626,24 @@ goToPage(n) { if (n !== '...' && n >= 1 && n <= this.totalPages) { this.paginati
-

Static Message (confirm_modal):

-
{% raw %}{% from 'shared/macros/modals.html' import confirm_modal %}
-
-{{ confirm_modal(
-    'deleteConfirm',
-    'Delete Item',
-    'Are you sure you want to delete this item?',
-    'deleteItem()',
-    'showDeleteModal',
-    'Delete',
-    'Cancel',
-    'danger'
-) }}{% endraw %}
+
+

Static Message (confirm_modal):

+ +
+
-

Dynamic Message (confirm_modal_dynamic):

-
{% raw %}{% from 'shared/macros/modals.html' import confirm_modal_dynamic %}
-
-{{ confirm_modal_dynamic(
-    'removePlatformModal',
-    'Remove Platform',
-    "'Are you sure you want to remove \"' + (item?.name || '') + '\" ?'",
-    'confirmRemove()',
-    'showConfirmModal',
-    'Remove',
-    'Cancel',
-    'warning'
-) }}{% endraw %}
+
+

Dynamic Message (confirm_modal_dynamic):

+ +
+
diff --git a/static/admin/js/components.js b/static/admin/js/components.js index fbd93a44..445011ef 100644 --- a/static/admin/js/components.js +++ b/static/admin/js/components.js @@ -435,6 +435,34 @@ function adminComponents() { showDynamicConfirmDemo: false, dynamicItemName: '', + // Code snippets for confirm modal macros + codeSnippets: { + confirmModal: `{% from 'shared/macros/modals.html' import confirm_modal %} + +{{ confirm_modal( + 'deleteConfirm', + 'Delete Item', + 'Are you sure you want to delete this item?', + 'deleteItem()', + 'showDeleteModal', + 'Delete', + 'Cancel', + 'danger' +) }}`, + confirmModalDynamic: `{% from 'shared/macros/modals.html' import confirm_modal_dynamic %} + +{{ confirm_modal_dynamic( + 'removePlatformModal', + 'Remove Platform', + "'Are you sure you want to remove \\\"' + (item?.name || '') + '\\\" ?'", + 'confirmRemove()', + 'showConfirmModal', + 'Remove', + 'Cancel', + 'warning' +) }}` + }, + // Example log data for demo showErrorLogDemo() { this.exampleLog = {