From 8d03f705ebbc891e216d509d4de0419842ebd317 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 9 Feb 2019 17:59:53 +0100 Subject: Bulk action: set visibility Added 2 buttons when link checkboxes are checked to set them either public or private. Related to #572 #1160 --- assets/default/js/base.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'assets') diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 99e03370..d5c29c69 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js @@ -466,6 +466,28 @@ function init(description) { }); } + const changeVisibilityButtons = document.querySelectorAll('.actions-change-visibility'); + if (changeVisibilityButtons != null && token != null) { + [...changeVisibilityButtons].forEach((button) => { + button.addEventListener('click', (event) => { + event.preventDefault(); + const visibility = event.target.getAttribute('data-visibility'); + + const links = []; + const linkCheckedCheckboxes = document.querySelectorAll('.link-checkbox:checked'); + [...linkCheckedCheckboxes].forEach((checkbox) => { + links.push({ + id: checkbox.value, + title: document.querySelector(`.linklist-item[data-id="${checkbox.value}"] .linklist-link`).innerHTML, + }); + }); + + const ids = links.map(item => item.id); + window.location = `?change_visibility&token=${token.value}&newVisibility=${visibility}&ids=${ids.join('+')}`; + }); + }); + } + /** * Select all button */ -- cgit v1.2.3