Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #27690: Switching from details to spent time report should have is or subproject operator. #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions assets/javascripts/redmine-time-entries-report.js
Original file line number Diff line number Diff line change
@@ -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("<option value='=*'>is or subproject</option>");
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() {
Expand All @@ -18,8 +26,8 @@ $(document).ready(function() {
}
});
}
}, 100);
}
}
}, 100);

// Week title attribute.
if ($('#columns option:selected').val() == 'week') {
Expand Down Expand Up @@ -51,33 +59,6 @@ $(document).ready(function() {
}
}

// Add subproject operator.
setTimeout(function() {
if ($("#operators_project_id").length) {
$("#operators_project_id").append("<option value='=*'>is or subproject</option>");
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("<option value='tlm'>this month and last month</option>");
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 = [];
Expand Down Expand Up @@ -252,4 +233,4 @@ $(document).ready(function() {
}
makeLinksAbsolute();

});
});