diff --git a/assets/javascripts/redmine-time-entries-report.js b/assets/javascripts/redmine-time-entries-report.js
index 84c3a0e..591528b 100644
--- a/assets/javascripts/redmine-time-entries-report.js
+++ b/assets/javascripts/redmine-time-entries-report.js
@@ -1,13 +1,21 @@
$(document).ready(function() {
const urlParams = new URLSearchParams(window.location.search);
var criteria = urlParams.getAll('criteria[]');
- // If urlParams are not set it's the first load of the page.
- if (criteria.length === 0 && $("input[name='criteria[]']").length) {
- $("input[name='criteria[]']").each(function() {
- criteria.push($(this).val());
- });
- // If it's the first page load, use project_id hidden field.
- setTimeout(function() {
+
+ setTimeout(function() {
+ // Add subproject operator.
+ if ($("#operators_project_id").length) {
+ $("#operators_project_id").append("");
+ if (!urlParams.get('op[project_id]') || urlParams.get('op[project_id]') === '=*') {
+ $('#operators_project_id').val('=*');
+ }
+ }
+ // If urlParams are not set it's the first load of the page.
+ if (criteria.length === 0 && $("input[name='criteria[]']").length) {
+ $("input[name='criteria[]']").each(function() {
+ criteria.push($(this).val());
+ });
+ // Use project_id hidden field if it's the first page load.
if ($('input[type=hidden][name=project_id]').length) {
var project_id = $('input[type=hidden][name=project_id]').val();
$('select[name="v[project_id][]"] option').each(function() {
@@ -18,8 +26,8 @@ $(document).ready(function() {
}
});
}
- }, 100);
- }
+ }
+ }, 100);
// Week title attribute.
if ($('#columns option:selected').val() == 'week') {
@@ -51,33 +59,6 @@ $(document).ready(function() {
}
}
- // Add subproject operator.
- setTimeout(function() {
- if ($("#operators_project_id").length) {
- $("#operators_project_id").append("");
- if (!urlParams.get('op[project_id]') || urlParams.get('op[project_id]') === '=*') {
- $('#operators_project_id').val('=*');
- }
- }
- }, 100);
-
- // Add tlm operator.
- setTimeout(function() {
- if ($("#operators_spent_on").length) {
- var threeToEnd = $('#operators_spent_on option').length - 4;
- $('#operators_spent_on option:nth(' + threeToEnd+ ')').after("");
- if (urlParams.get('op[spent_on]') === 'tlm') {
- $('#operators_spent_on').val('tlm');
- enableValues('spent_on', []);
- }
- $("#operators_spent_on").change(function() {
- if ($(this).val() === 'tlm') {
- enableValues('spent_on', []);
- }
- });
- }
- }, 100);
-
if (criteria.length) {
if ($('#time-report th')[criteria.length - 1]) {
var originalCriteria = [];
@@ -252,4 +233,4 @@ $(document).ready(function() {
}
makeLinksAbsolute();
-});
\ No newline at end of file
+});