mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-18 02:20:37 -05:00
- IssueMileageListener removed: redmine_qbo_vehicles answers qbo_billing_issue_values with mileage. - New hook qbo_billing_build_issue sets plugins' fields on issues created from an estimate; the vehicle lookup by VIN moved to redmine_qbo_vehicles. - New hook qbo_billing_vin_options gives the VIN box's suggestions (RedmineQboBilling.vin_options) instead of reading customer.vehicles. - The customer page's New issue link script is generic: any checkbox with data-new-issue-param="issue[field]" fills that field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
46 lines
1.7 KiB
ERB
46 lines
1.7 KiB
ERB
<%#
|
|
Adds what's ticked on the customer page to the "New issue" link (#dynamic-new-issue-link in the contextual
|
|
area). Any checkbox with data-new-issue-param="issue[field]" takes part, one ticked per field: this plugin's
|
|
estimates (issue[estimate_id]), and other plugins' lists (e.g. redmine_qbo_vehicles' issue[vehicle_id]).
|
|
%>
|
|
<script>
|
|
function newIssueParamBoxes(param) {
|
|
return Array.prototype.filter.call(document.querySelectorAll('input[data-new-issue-param]'), function (cb) {
|
|
return !param || cb.getAttribute('data-new-issue-param') === param;
|
|
});
|
|
}
|
|
|
|
// One box per field: ticking one unticks the others for the same field
|
|
document.addEventListener('change', function (event) {
|
|
var box = event.target;
|
|
if (!box.matches || !box.matches('input[data-new-issue-param]')) return;
|
|
if (box.checked) {
|
|
newIssueParamBoxes(box.getAttribute('data-new-issue-param')).forEach(function (cb) {
|
|
if (cb !== box) cb.checked = false;
|
|
});
|
|
}
|
|
updateLink();
|
|
});
|
|
|
|
function updateLink() {
|
|
var link = document.getElementById('dynamic-new-issue-link');
|
|
if (!link) return;
|
|
|
|
// Cache the pristine base URL on first run
|
|
if (!link.dataset.baseUrl) link.dataset.baseUrl = link.getAttribute('href');
|
|
var url = new URL(link.dataset.baseUrl, window.location.origin);
|
|
|
|
newIssueParamBoxes().forEach(function (cb) {
|
|
var param = cb.getAttribute('data-new-issue-param');
|
|
var ticked = newIssueParamBoxes(param).filter(function (b) { return b.checked; })[0];
|
|
if (ticked) {
|
|
url.searchParams.set(param, ticked.value);
|
|
} else {
|
|
url.searchParams.delete(param);
|
|
}
|
|
});
|
|
|
|
link.setAttribute('href', url.toString());
|
|
}
|
|
</script>
|