From f9430f7b13b5169bec9eedde9c89fa5891a0b2da Mon Sep 17 00:00:00 2001 From: HesterG Date: Thu, 20 Apr 2023 13:33:26 +0800 Subject: [PATCH] use data- attributes to pass data --- templates/base/page_dimmer_buttons.tmpl | 4 ++-- templates/projects/view.tmpl | 14 +++++++------- templates/repo/projects/view.tmpl | 14 +++++++------- web_src/js/features/repo-projects.js | 12 ++++++++---- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/templates/base/page_dimmer_buttons.tmpl b/templates/base/page_dimmer_buttons.tmpl index 330c1d754295..1c3e78f456cd 100644 --- a/templates/base/page_dimmer_buttons.tmpl +++ b/templates/base/page_dimmer_buttons.tmpl @@ -1,9 +1,9 @@
- - diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index a79f7e363773..9a6d6951e255 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -115,7 +115,10 @@ {{$.locale.Tr "repo.projects.column.unset_default"}} {{end}} - + {{svg "octicon-trash"}} {{$.locale.Tr "repo.projects.column.delete"}} @@ -171,12 +174,9 @@ {{$.locale.Tr "repo.projects.column.deletion_desc"}}
-
- {{$DataUrl := printf "%s/%d" $.Link .ID}} - {{$ModalNoText := $.locale.Tr "settings.cancel"}} - {{$ModalYesText := $.locale.Tr "repo.projects.column.delete"}} - {{template "base/page_dimmer_buttons" (dict "." $ "ExtendedClasses" "delete-project-board" "DataUrl" $DataUrl "ModalNoText" $ModalNoText "ModalYesText" $ModalYesText)}} -
+ {{$ModalNoText := $.locale.Tr "settings.cancel"}} + {{$ModalYesText := $.locale.Tr "repo.projects.column.delete"}} + {{template "base/page_dimmer_buttons" (dict "." $ "ModalNoText" $ModalNoText "ModalYesText" $ModalYesText)}} diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 663eb3ab4996..29d7eebcd02c 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -121,7 +121,10 @@ {{$.locale.Tr "repo.projects.column.unset_default"}} {{end}} - + {{svg "octicon-trash"}} {{$.locale.Tr "repo.projects.column.delete"}} @@ -177,12 +180,9 @@ {{$.locale.Tr "repo.projects.column.deletion_desc"}} -
- {{$DataUrl := printf "%s/projects/%d/%d" $.RepoLink $.Project.ID .ID}} - {{$ModalNoText := $.locale.Tr "settings.cancel"}} - {{$ModalYesText := $.locale.Tr "repo.projects.column.delete"}} - {{template "base/page_dimmer_buttons" (dict "." $ "ExtendedClasses" "delete-project-board" "DataUrl" $DataUrl "ModalNoText" $ModalNoText "ModalYesText" $ModalYesText)}} -
+ {{$ModalNoText := $.locale.Tr "settings.cancel"}} + {{$ModalYesText := $.locale.Tr "repo.projects.column.delete"}} + {{template "base/page_dimmer_buttons" (dict "." $ "ModalNoText" $ModalNoText "ModalYesText" $ModalYesText)}} diff --git a/web_src/js/features/repo-projects.js b/web_src/js/features/repo-projects.js index 63ef541c7451..a2a6ff148594 100644 --- a/web_src/js/features/repo-projects.js +++ b/web_src/js/features/repo-projects.js @@ -147,12 +147,16 @@ export function initRepoProject() { }); }); - $('.delete-project-board').each(function () { - $(this).click(function (e) { + $('.show-delete-column-modal').each(function () { + const deleteColumnModal = $(`${$(this).attr('data-modal')}`); + const deleteColumnButton = deleteColumnModal.find('.confirm-button'); + const deleteUrl = $(this).attr('data-url'); + + deleteColumnButton.on('click', function (e) { e.preventDefault(); $.ajax({ - url: $(this).data('url'), + url: deleteUrl, headers: { 'X-Csrf-Token': csrfToken, }, @@ -162,7 +166,7 @@ export function initRepoProject() { window.location.reload(); }); }); - }); + }) $('#new_board_submit').click(function (e) { e.preventDefault();