turn Save, SaveAs and Execute into submit buttons. Put Id into the form action so that it shows up in the url bar. Disable putting the form contents into the url bar in parse_rows.

This commit is contained in:
Isaac Connor 2021-08-12 13:44:49 -04:00
parent a311455526
commit 92a924044a
2 changed files with 13 additions and 35 deletions

View File

@ -195,7 +195,7 @@ echo $navbar = getNavBarHTML();
<form name="selectForm" id="selectForm" method="get" action="?"> <form name="selectForm" id="selectForm" method="get" action="?">
<input type="hidden" name="view" value="filter"/> <input type="hidden" name="view" value="filter"/>
<hr/> <hr/>
<div id="filterSelector"><label for="<?php echo 'Id' ?>"><?php echo translate('UseFilter') ?></label> <div id="filterSelector"><label for="Id"><?php echo translate('UseFilter') ?></label>
<?php <?php
if ( count($filterNames) > 1 ) { if ( count($filterNames) > 1 ) {
echo htmlSelect('Id', $filterNames, $filter->Id(), array('data-on-change-this'=>'selectFilter')); echo htmlSelect('Id', $filterNames, $filter->Id(), array('data-on-change-this'=>'selectFilter'));
@ -210,8 +210,7 @@ if ( (null !== $filter->Concurrent()) and $filter->Concurrent() )
?> ?>
</div> </div>
</form> </form>
<form name="contentForm" id="contentForm" method="post" class="validateFormOnSubmit" action="?view=filter"> <form name="contentForm" id="contentForm" method="post" class="validateFormOnSubmit" action="?view=filter&Id=<?php echo $filter->Id() ?>">
<input type="hidden" name="Id" value="<?php echo $filter->Id() ?>"/>
<input type="hidden" name="action"/> <input type="hidden" name="action"/>
<input type="hidden" name="object" value="filter"/> <input type="hidden" name="object" value="filter"/>
@ -507,12 +506,12 @@ if ( ZM_OPT_EMAIL ) {
<button type="button" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button> <button type="button" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
<button type="button" data-on-click-this="submitToMontageReview"><?php echo translate('ViewMatches') ?></button> <button type="button" data-on-click-this="submitToMontageReview"><?php echo translate('ViewMatches') ?></button>
<button type="button" data-on-click-this="submitToExport"><?php echo translate('ExportMatches') ?></button> <button type="button" data-on-click-this="submitToExport"><?php echo translate('ExportMatches') ?></button>
<button type="button" name="executeButton" id="executeButton" data-on-click-this="executeFilter"><?php echo translate('Execute') ?></button> <button type="submit" name="action" value="execute" id="executeButton"><?php echo translate('Execute') ?></button>
<?php <?php
if ( canEdit('Events') ) { if ( canEdit('Events') ) {
?> ?>
<button type="submit" name="Save" value="Save" data-on-click-this="saveFilter"><?php echo translate('Save') ?></button> <button type="submit" name="action" value="Save" id="Save"><?php echo translate('Save') ?></button>
<button type="submit" name="SaveAs" value="SaveAs" data-on-click-this="saveFilter"><?php echo translate('SaveAs') ?></button> <button type="submit" name="action" value="SaveAs" id="SaveAs"><?php echo translate('SaveAs') ?></button>
<?php <?php
if ( $filter->Id() ) { if ( $filter->Id() ) {
?> ?>

View File

@ -97,13 +97,13 @@ function updateButtons(element) {
} else if ( form.elements['filter[UpdateDiskSpace]'].checked ) { } else if ( form.elements['filter[UpdateDiskSpace]'].checked ) {
canExecute = true; canExecute = true;
} }
form.elements['executeButton'].disabled = !canExecute; document.getElementById('executeButton').disabled = !canExecute;
if ( form.elements['filter[Name]'].value ) { if ( form.elements['filter[Name]'].value ) {
form.elements['Save'].disabled = false; document.getElementById('Save').disabled = false;
form.elements['SaveAs'].disabled = false; document.getElementById('SaveAs').disabled = false;
} else { } else {
form.elements['Save'].disabled = true; document.getElementById('Save').disabled = true;
form.elements['SaveAs'].disabled = true; document.getElementById('SaveAs').disabled = true;
} }
} }
@ -151,11 +151,6 @@ function resetFilter( element ) {
function submitToEvents(element) { function submitToEvents(element) {
var form = element.form; var form = element.form;
//form.action = '?view=events';
//form.submit();
//console.log(form);
//console.log($j(form).serialize());
//history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
window.location.assign('?view=events&'+$j(form).serialize()); window.location.assign('?view=events&'+$j(form).serialize());
} }
@ -171,23 +166,6 @@ function submitToExport(element) {
window.location.assign('?view=export&'+$j(form).serialize()); window.location.assign('?view=export&'+$j(form).serialize());
} }
function executeFilter( element ) {
var form = element.form;
form.action = thisUrl + '?view=filter';
form.elements['action'].value = 'execute';
form.submit();
//history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
}
function saveFilter( element ) {
var form = element.form;
form.target = window.name;
form.elements['action'].value = element.value;
form.action = thisUrl + '?view=filter';
//form.submit();
// Submit is done by the button type="submit"
}
function deleteFilter( element ) { function deleteFilter( element ) {
var form = element.form; var form = element.form;
if ( confirm( deleteSavedFilterString+" '"+form.elements['filter[Name]'].value+"'?" ) ) { if ( confirm( deleteSavedFilterString+" '"+form.elements['filter[Name]'].value+"'?" ) ) {
@ -350,7 +328,8 @@ function parseRows(rows) {
inputTds.eq(2).children().eq(0).attr('name', 'filter'+stringFilter(term)); inputTds.eq(2).children().eq(0).attr('name', 'filter'+stringFilter(term));
inputTds.eq(2).children().eq(0).attr('id', 'filter'+stringFilter(term)); inputTds.eq(2).children().eq(0).attr('id', 'filter'+stringFilter(term));
} //End for each term/row } //End for each term/row
history.replaceState(null, null, '?view=filter&' + $j('#contentForm').serialize()); // ICON This populates the url bar with contents of the form. I'm not sure why
// history.replaceState(null, null, '?view=filter&' + $j('#contentForm').serialize());
} // parseRows } // parseRows
function stringFilter(term) { function stringFilter(term) {
@ -415,4 +394,4 @@ function initPage() {
parseRows($j('#fieldsTable tbody').children()); parseRows($j('#fieldsTable tbody').children());
} }
$j(document).ready(initPage ); $j(document).ready(initPage);