mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Subtotal from the keyboard: sub, subtotal or = in a product box
Typing sub, subtotal or = in a line's product box, then Tab or Enter, adds a subtotal there: an otherwise empty line becomes the subtotal; a line with a description, quantity or rate keeps them and gets the subtotal after it. The next line's product box gets the focus. Lines with a product are left alone. Tabbing into a box now selects its text right away, so the first key typed already replaces it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
2 files changed
+41
-3
No files matched your search
@@ -103,7 +103,7 @@ Estimates and invoices keep their number, date, customer, total and **man-hours*
|
|||||||
|
|
||||||
* **New estimate** from the customer page: Create Estimate opens the Redmine editor. The customer page no longer links to QuickBooks' estimate or payment screens; the customer's name still opens their QuickBooks account page as a fallback.
|
* **New estimate** from the customer page: Create Estimate opens the Redmine editor. The customer page no longer links to QuickBooks' estimate or payment screens; the customer's name still opens their QuickBooks account page as a fallback.
|
||||||
* **Edit** any estimate from the Edit link next to it on the customer page or the issue page.
|
* **Edit** any estimate from the Edit link next to it on the customer page or the issue page.
|
||||||
* **Keyboard entry**: in a line's product box, Tab picks the product the text points to (an exact name, the only match, or the only name starting with it, e.g. "lab" → Labor) and fills the line. Tabbing into the description, quantity or rate selects it, so typing replaces it. The quantity, rate and amount boxes take simple math (e.g. `33*1.3`, `(120+15)/2`; `+ - * /`, `x` for times, parentheses), worked out when you leave the box; math in the rate or amount is rounded to the nearest penny, and an amount sets the rate from the quantity.
|
* **Keyboard entry**: in a line's product box, Tab picks the product the text points to (an exact name, the only match, or the only name starting with it, e.g. "lab" → Labor) and fills the line. Tabbing into the description, quantity or rate selects it, so typing replaces it. The quantity, rate and amount boxes take simple math (e.g. `33*1.3`, `(120+15)/2`; `+ - * /`, `x` for times, parentheses), worked out when you leave the box; math in the rate or amount is rounded to the nearest penny, and an amount sets the rate from the quantity. Typing `sub`, `subtotal` or `=` in a product box, then Tab or Enter, adds a subtotal there (an empty line becomes the subtotal; a line with a description keeps it and gets the subtotal after it) and moves on to the next line.
|
||||||
* **Duplicate** an estimate to start a similar one: same customer, lines, subtotals, custom fields and messages, dated today, with the current user as sales person.
|
* **Duplicate** an estimate to start a similar one: same customer, lines, subtotals, custom fields and messages, dated today, with the current user as sales person.
|
||||||
* **Read-only once linked to an issue**: an estimate that an issue is linked to can be viewed, emailed and duplicated, but not changed, so the work doesn't drift from what was quoted. The list shows a View link for these instead of Edit.
|
* **Read-only once linked to an issue**: an estimate that an issue is linked to can be viewed, emailed and duplicated, but not changed, so the work doesn't drift from what was quoted. The list shows a View link for these instead of Edit.
|
||||||
* **Read-only once billed**: an estimate that's Converted or Closed in QuickBooks, or linked to an invoice, can't be changed here either (including redmine_qbo_lineitems' estimates once they're invoiced). Its page lists the invoices it's on; it can still be viewed, emailed and duplicated, and it shows View instead of Edit in lists.
|
* **Read-only once billed**: an estimate that's Converted or Closed in QuickBooks, or linked to an invoice, can't be changed here either (including redmine_qbo_lineitems' estimates once they're invoiced). Its page lists the invoices it's on; it can still be viewed, emailed and duplicated, and it shows View instead of Edit in lists.
|
||||||
|
|||||||
@@ -197,6 +197,30 @@ $(function () {
|
|||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keyboard subtotal: typed in a line's product box, then Tab or Enter
|
||||||
|
var SUBTOTAL_SHORTCUTS = ['sub', 'subtotal', '='];
|
||||||
|
|
||||||
|
// Puts a subtotal where the shortcut was typed: an otherwise empty line becomes the subtotal; a line with a
|
||||||
|
// description, quantity or rate keeps them (the shortcut text is cleared) and the subtotal goes after it.
|
||||||
|
// Then the next line's product box gets the focus, to carry on typing.
|
||||||
|
function insertSubtotalAt($row) {
|
||||||
|
var $subtotal = $(subtotalTemplate.replace(/__KEY__/g, String(nextKey++)));
|
||||||
|
var $product = $row.find('.qbo-line-item-name');
|
||||||
|
var otherwiseEmpty = !$row.find('.qbo-line-description-input').val().trim() &&
|
||||||
|
!$row.find('.qbo-line-qty-input').val().trim() && !$row.find('.qbo-line-rate-input').val().trim();
|
||||||
|
if (otherwiseEmpty) {
|
||||||
|
$row.replaceWith($subtotal);
|
||||||
|
} else {
|
||||||
|
$product.val('');
|
||||||
|
$row.removeClass('qbo-line-unmatched').after($subtotal);
|
||||||
|
}
|
||||||
|
renumber();
|
||||||
|
changed();
|
||||||
|
var $next = $subtotal.nextAll('tr.qbo-line').not('.qbo-line-subtotal').first();
|
||||||
|
if (!$next.length) $next = addRow();
|
||||||
|
$next.find('.qbo-line-item-name').trigger('focus');
|
||||||
|
}
|
||||||
|
|
||||||
// The product typed text points to: an exact name match, else the only result, else the only one whose name
|
// The product typed text points to: an exact name match, else the only result, else the only one whose name
|
||||||
// starts with the text (e.g. "lab" -> Labor). Nothing when it's ambiguous.
|
// starts with the text (e.g. "lab" -> Labor). Nothing when it's ambiguous.
|
||||||
function bestItem(term, items) {
|
function bestItem(term, items) {
|
||||||
@@ -230,6 +254,20 @@ $(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Typing "sub", "subtotal" or "=" then Tab or Enter makes a subtotal here (see insertSubtotalAt)
|
||||||
|
$input.on('keydown', function (event) {
|
||||||
|
if ((event.key !== 'Tab' && event.key !== 'Enter') || event.shiftKey) return;
|
||||||
|
var $row = $input.closest('tr');
|
||||||
|
if (SUBTOTAL_SHORTCUTS.indexOf($input.val().trim().toLowerCase()) < 0 || $row.find('.qbo-line-item-id').val()) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
var search = $input.autocomplete('instance');
|
||||||
|
clearTimeout(search.searching);
|
||||||
|
search.cancelSearch = true;
|
||||||
|
$input.autocomplete('close');
|
||||||
|
insertSubtotalAt($row);
|
||||||
|
});
|
||||||
|
|
||||||
// Tab picks the product the text points to (an item highlighted in the list is picked by the
|
// Tab picks the product the text points to (an item highlighted in the list is picked by the
|
||||||
// autocomplete itself). If the search hasn't come back yet, the line is filled in when it does.
|
// autocomplete itself). If the search hasn't come back yet, the line is filled in when it does.
|
||||||
$input.on('keydown', function (event) {
|
$input.on('keydown', function (event) {
|
||||||
@@ -301,8 +339,8 @@ $(function () {
|
|||||||
$(document).on('mousedown touchstart', function () { tabbedAt = 0; });
|
$(document).on('mousedown touchstart', function () { tabbedAt = 0; });
|
||||||
$tbody.on('focus', '.qbo-line-description-input, .qbo-line-qty-input, .qbo-line-rate-input', function () {
|
$tbody.on('focus', '.qbo-line-description-input, .qbo-line-qty-input, .qbo-line-rate-input', function () {
|
||||||
if (Date.now() - tabbedAt > 500) return;
|
if (Date.now() - tabbedAt > 500) return;
|
||||||
var box = this;
|
// Right away, so the first key typed already replaces the text
|
||||||
setTimeout(function () { if (document.activeElement === box) box.select(); }, 0);
|
this.select();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---- line events ----
|
// ---- line events ----
|
||||||
|
|||||||
Reference in new issue
Block a user