Skip to content

Commit

Permalink
Restore focussing behaviour on AR/AP and Orders/Quotes
Browse files Browse the repository at this point in the history
When we switched to being a Single Page Application (SPA) on the client
in version 1.5, we lost how the next data entry row was selected on
page refresh. This comit restores that for invoices, orders, quotes and
AR/AP transactions (but not GL transactions).

Re ledgersmb#1584
  • Loading branch information
ehuelsmann committed Jan 8, 2023
1 parent 9b4f9b7 commit 0fc2c02
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
7 changes: 5 additions & 2 deletions UI/journal/journal_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<body class="lsmb [% dojo_theme %]">
<div id="journal-entry">

<form data-dojo-type="lsmb/Form" method="post" action="[% form.script %]">
<form data-dojo-type="lsmb/Form"
data-lsmb-focus="[% form.focus %]"
method="post"
action="[% form.script %]">
<table width="100%">
<tr>
<th class="listtop" >[% form.title %]</th>
Expand All @@ -24,7 +27,7 @@
type = "text",
size = "20",
class = 'reference'
id = "ref_1"
id = "reference"
};
IF form.sequences;
PROCESS select element_data = {
Expand Down
13 changes: 13 additions & 0 deletions UI/src/components/ServerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default {
});
topic.publish("lsmb/page-fresh-content");
maindiv.setAttribute("data-lsmb-done", "true");
this._setFormFocus();
},
(e) => {
if (dismiss) {
Expand All @@ -102,6 +103,18 @@ export default {
this._report_error(e);
}
},
_setFormFocus() {
[ ...document.forms ].forEach(
(form) => {
if (form.hasAttribute('data-lsmb-focus')) {
let focus = form.getAttribute('data-lsmb-focus');
let elm = document.getElementById(focus);
if (elm) {
elm.select();
}
}
});
},
_recursively_resize(widget) {
widget.getChildren().forEach((child) => {
this._recursively_resize(child);
Expand Down
7 changes: 5 additions & 2 deletions old/bin/aa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ sub form_header {
print qq|
<body> | .
$form->open_status_div($status_div_id) . qq|
<form method="post" data-dojo-type="lsmb/Form" action=$form->{script}>
<form method="post"
data-dojo-type="lsmb/Form"
data-lsmb-focus="${focus}"
action=$form->{script}>
<input type=hidden name=type value="$form->{formname}">
<input type=hidden name=title value="$title">
Expand Down Expand Up @@ -728,7 +731,7 @@ sub form_header {
$taxformcheck=qq|<td><input type="checkbox" data-dojo-type="dijit/form/CheckBox" name="taxformcheck_$i" value="1" $taxchecked></td>|;
print qq|
<tr valign=top class="transaction-line $form->{ARAP}" id="line-$i">
<td><input data-dojo-type="dijit/form/TextBox" name="amount_$i" size=10 value="$form->{"amount_$i"}"></td>
<td><input data-dojo-type="dijit/form/TextBox" id="amount_$i" name="amount_$i" size=10 value="$form->{"amount_$i"}"></td>
<td>| . (($form->{currency} ne $form->{defaultcurrency})
? $form->format_amount(\%myconfig, $form->parse_amount( \%myconfig, $form->{"amount_$i"} )
* $form->{exchangerate}, $form->{_setting_decimal_places})
Expand Down
3 changes: 2 additions & 1 deletion old/bin/ir.pl
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,12 @@ sub form_header {
$form->header;

print qq|
<body class="lsmb $form->{dojo_theme}" onLoad="document.forms[0].${focus}.focus()" />
<body>
| . $form->open_status_div($status_div_id) . qq|
<form method="post"
id="invoice"
data-dojo-type="lsmb/Invoice"
data-lsmb-focus="${focus}"
action="$form->{script}" >
|;
if ($form->{notice}){
Expand Down
2 changes: 2 additions & 0 deletions old/bin/is.pl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ sub form_header {
| if $form->{selectemployee};

$i = ($form->{rowcount} // 0) + 1;
$focus = "partnumber_$i";

$form->header;

Expand All @@ -354,6 +355,7 @@ sub form_header {
<form method="post"
id="invoice"
data-dojo-type="lsmb/Invoice"
data-lsmb-focus="${focus}"
action="$form->{script}" >
|;

Expand Down
3 changes: 2 additions & 1 deletion old/bin/oe.pl
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,12 @@ sub form_header {
$form->header;

print qq|
<body class="lsmb $form->{dojo_theme}" onLoad="document.forms[0].${focus}.focus()" />
<body>
| . $form->open_status_div($status_div_id) . qq|
<form method="post"
id="invoice"
data-dojo-type="lsmb/Invoice"
data-lsmb-focus="${focus}"
action="$form->{script}" >
|;

Expand Down

0 comments on commit 0fc2c02

Please sign in to comment.