diff options
author | zeripath <art27@cantab.net> | 2021-08-27 03:57:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 22:57:40 -0400 |
commit | e37342db0c102ef12ae70072d9f4bbef89338085 (patch) | |
tree | 50598f0627960e60aec866568a29e3cffa378c5b /web_src/js | |
parent | 3289aceec2b760e690fe7505d22ff685950cd0e7 (diff) | |
download | gitea-e37342db0c102ef12ae70072d9f4bbef89338085.tar.gz gitea-e37342db0c102ef12ae70072d9f4bbef89338085.zip |
Add modals to Organization and Team remove/leave (#16471)
* Add modals to Organization and Team remove/leave
Add confirmation modals to Organization and Team remove and leave.
Fix #16215
Signed-off-by: Andrew Thornton <art27@cantab.net>
* avoid for-in
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Revert "avoid for-in"
This reverts commit 2af9a6f9d46ed31b6fc6e3a29e695577dcf09f75.
* Apply suggestions from code review
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src/js')
-rw-r--r-- | web_src/js/index.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js index d349092717..7e4970c3a0 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2956,13 +2956,19 @@ $(() => { function showDeletePopup() { const $this = $(this); + const dataArray = $this.data(); let filter = ''; - if ($this.attr('id')) { - filter += `#${$this.attr('id')}`; + if ($this.data('modal-id')) { + filter += `#${$this.data('modal-id')}`; } const dialog = $(`.delete.modal${filter}`); dialog.find('.name').text($this.data('name')); + for (const [key, value] of Object.entries(dataArray)) { + if (key && key.startsWith('data')) { + dialog.find(`.${key}`).text(value); + } + } dialog.modal({ closable: false, @@ -2972,10 +2978,19 @@ function showDeletePopup() { return; } - $.post($this.data('url'), { + const postData = { _csrf: csrf, - id: $this.data('id') - }).done((data) => { + }; + for (const [key, value] of Object.entries(dataArray)) { + if (key && key.startsWith('data')) { + postData[key.substr(4)] = value; + } + if (key === 'id') { + postData['id'] = value; + } + } + + $.post($this.data('url'), postData).done((data) => { window.location.href = data.redirect; }); } |