mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 15:11:58 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1febdc3e04 | |||
| d1f8f027c0 |
@@ -23,9 +23,10 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td data-label="<%= t :label_price %>">
|
<td data-label="<%= t :label_price %>">
|
||||||
<%= f.number_field :unit_price,
|
<%= f.text_field :unit_price,
|
||||||
step: 0.01,
|
|
||||||
class: "price-field",
|
class: "price-field",
|
||||||
|
inputmode: "decimal",
|
||||||
|
autocomplete: "off",
|
||||||
no_label: true,
|
no_label: true,
|
||||||
disabled: readonly %>
|
disabled: readonly %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
33
assets/javascripts/blur.js
Normal file
33
assets/javascripts/blur.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
function evaluateMathExpression(expr) {
|
||||||
|
if (!expr) return null;
|
||||||
|
|
||||||
|
// allow only digits, decimal, operators, parentheses, spaces
|
||||||
|
if (!/^[0-9+\-*/().\s]+$/.test(expr)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Function('"use strict"; return (' + expr + ')')();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("blur", function(e) {
|
||||||
|
|
||||||
|
if (!e.target.classList.contains("price-field")) return;
|
||||||
|
|
||||||
|
const field = e.target;
|
||||||
|
const value = field.value.trim();
|
||||||
|
|
||||||
|
const result = evaluateMathExpression(value);
|
||||||
|
|
||||||
|
if (result !== null && !isNaN(result)) {
|
||||||
|
field.value = Number(result).toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof updateLineItemTotals === "function") {
|
||||||
|
updateLineItemTotals();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, true);
|
||||||
2
init.rb
2
init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
|
|||||||
name 'Redmine QBO Line Items plugin'
|
name 'Redmine QBO Line Items plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to attach billable line items to an isuue'
|
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to attach billable line items to an isuue'
|
||||||
version '2026.3.4'
|
version '2026.3.5'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
|
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '6.1.0'
|
requires_redmine version_or_higher: '6.1.0'
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ module RedmineQboLineItems
|
|||||||
javascript_include_tag( 'nested_form_controller', plugin: :redmine_qbo_lineitems),
|
javascript_include_tag( 'nested_form_controller', plugin: :redmine_qbo_lineitems),
|
||||||
javascript_include_tag("line_items", plugin: :redmine_qbo_lineitems),
|
javascript_include_tag("line_items", plugin: :redmine_qbo_lineitems),
|
||||||
javascript_include_tag("autocomplete", plugin: :redmine_qbo_lineitems),
|
javascript_include_tag("autocomplete", plugin: :redmine_qbo_lineitems),
|
||||||
|
javascript_include_tag("blur", plugin: :redmine_qbo_lineitems),
|
||||||
stylesheet_link_tag("line_items", plugin: :redmine_qbo_lineitems)
|
stylesheet_link_tag("line_items", plugin: :redmine_qbo_lineitems)
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user