From e37342db0c102ef12ae70072d9f4bbef89338085 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 27 Aug 2021 03:57:40 +0100 Subject: 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 * avoid for-in Signed-off-by: Andrew Thornton * Revert "avoid for-in" This reverts commit 2af9a6f9d46ed31b6fc6e3a29e695577dcf09f75. * Apply suggestions from code review Co-authored-by: silverwind Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: silverwind Co-authored-by: techknowlogick --- web_src/js/index.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'web_src') 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; }); } -- cgit v1.2.3