From 16efa9dbb24b338b09adb89469f3897e4d061b12 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 18 Aug 2020 11:17:22 -0400 Subject: [PATCH] Add extra checks for Deleting without an Archived State term and Running in the background without any actions. --- web/skins/classic/views/js/filter.js | 38 ++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index 10064d6ef..a77b757ec 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -7,7 +7,7 @@ function validateForm( form ) { var obrCount = 0; var cbrCount = 0; for ( var i = 0; i < rows.length; i++ ) { - if (rows.length > 2) { + if ( rows.length > 2 ) { obrCount += parseInt(form.elements['filter[Query][terms][' + i + '][obr]'].value); cbrCount += parseInt(form.elements['filter[Query][terms][' + i + '][cbr]'].value); } @@ -22,9 +22,43 @@ function validateForm( form ) { } var numbers_reg = /\D/; if ( numbers_reg.test(form.elements['filter[Query][limit]'].value) ) { - alert("There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty."); + alert('There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty.'); return false; } + if ( form.elements['filter[AutoDelete]'].checked ) { + // if Delete action is Enabled should also have an unarchived term + var have_archivestatus_term = false; + for ( var i = 0; i < rows.length; i++ ) { + if ( form.elements['filter[Query][terms][' + i + '][attr]'].value == 'Archived' ) { + have_archivestatus_term = true; + } + } + if ( ! have_archivestatus_term ) { + return confirm('You have enabled deleting events but do not have a term referencing the archived status of the event. This filter may delete events that you want to save! Are you sure?'); + } + } else if ( form.elements['filter[Background]'].checked ) { + if ( ! ( + form.elements['filter[AutoArchive]'].checked + || + form.elements['filter[UpdateDiskSpace]'].checked + || + form.elements['filter[AutoVideo]'].checked + || + form.elements['filter[AutoEmail]'].checked + || + form.elements['filter[AutoMessage]'].checked + || + form.elements['filter[AutoExecute]'].checked + || + form.elements['filter[AutoDelete]'].checked + || + form.elements['filter[AutoCopy]'].checked + || + form.elements['filter[AutoMove]'].checked + ) ) { + alert('You have chosen to run this filter in the background but not selected any actions.'); + } + } return true; }