Skip to content

Commit

Permalink
#202 [TimeSpent] fix: form submission load
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo David committed Apr 7, 2023
1 parent 1901798 commit 23939b7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
61 changes: 60 additions & 1 deletion js/dolisirh.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,4 +1356,63 @@ window.eoxiaJS.dashboard.selectDatasetDashboardInfo = function() {
},
error: function() {}
});
};
};

/**
* Initialise l'objet "form" ainsi que la méthode "init" obligatoire pour la bibliothèque EoxiaJS.
*
* @since 1.1.0
* @version 1.1.0
*/
window.eoxiaJS.form = {};

/**
* La méthode appelée automatiquement par la bibliothèque EoxiaJS.
*
* @since 1.1.0
* @version 1.1.0
*
* @return {void}
*/
window.eoxiaJS.form.init = function() {
window.eoxiaJS.form.event();
};

/**
* La méthode contenant tous les événements pour les buttons.
*
* @since 1.1.0
* @version 1.1.0
*
* @return {void}
*/
window.eoxiaJS.form.event = function() {
$( document ).on( 'submit', '#addtimeform', window.eoxiaJS.form.searchForm );
};

window.eoxiaJS.form.searchForm = function(event) {
event.preventDefault()

var addTimeForm = document.getElementById('addtimeform');
var formData = new FormData(addTimeForm);
let newFormData = new FormData();

for (const pair of formData.entries()) {
if (pair[1] != '') {
newFormData.append(pair[0], pair[1])
}
}
window.eoxiaJS.loader.display($('#addtimeform'));

$.ajax({
url: document.URL,
type: "POST",
data: newFormData,
processData: false,
contentType: false,
success: function (resp) {
$('.wpeo-loader').removeClass('wpeo-loader');
$('#addtimeform').html($(resp).find('#addtimeform').children())
},
});
}
2 changes: 1 addition & 1 deletion view/timespent_week.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
$nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, 'addtime', 1, 1).' ';
$nav .= ' <button type="submit" name="submitdateselect" value="x" class="bordertransp"><span class="fa fa-search"></span></button>';

print '<form name="addtime" method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<form name="addtime" id="addtimeform" method="POST" action="'.$_SERVER['PHP_SELF'].'>';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="addtime">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
Expand Down

0 comments on commit 23939b7

Please sign in to comment.