mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-02-13 09:13:58 -05:00
simplified appointment link javascript
This commit is contained in:
@@ -1,31 +1,22 @@
|
||||
function updateLink() {
|
||||
console.log("updateLink called");
|
||||
const linkElement = document.getElementById("appointment_link");
|
||||
const regex = /((?:<br\/>|%3Cbr\/?%3E))([\s\S]*?)(&dates)/gi;
|
||||
linkElement.href = linkElement.href.replace(regex, `$1${getSelectedDocs()}$3`);
|
||||
}
|
||||
|
||||
function getSelectedDocs() {
|
||||
const invoices = document.querySelectorAll('.invoice-checkbox');
|
||||
const estimates = document.querySelectorAll('.estimate-checkbox');
|
||||
const appointent_extras = document.querySelectorAll('.appointment');
|
||||
|
||||
let output = '';
|
||||
|
||||
for (const i of invoices) {
|
||||
if (i.checked) {
|
||||
console.log(i.value);
|
||||
console.log(i.dataset.doc);
|
||||
output += `%0A<a href="${window.location.origin}/invoices/${i.dataset.id}">Invoice:%20${i.dataset.doc}</a>%0A`;
|
||||
}
|
||||
}
|
||||
|
||||
for (const e of estimates) {
|
||||
if (e.checked) {
|
||||
console.log(e.value);
|
||||
console.log(e.dataset.doc);
|
||||
output += `%0A<a href="${window.location.origin}/estimates/${e.value}">Estimate:%20${e.dataset.doc}</a>%0A`;
|
||||
for (const item of appointent_extras) {
|
||||
if (item.checked) {
|
||||
console.log(`Checked item: ${item.dataset.text} with URL: ${item.dataset.url}`);
|
||||
output += `%0A`+ encodeURIComponent(`<a href="${window.location.origin}${item.dataset.url}">${item.dataset.text}</a>`) +`%0A`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// You can return the array or use it as needed
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user