[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4328] branches/1.3



Revision: 4328
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4328&view=rev
Author:   einhverfr
Date:     2012-02-17 12:38:12 +0000 (Fri, 17 Feb 2012)
Log Message:
-----------
Tuning ajaxselect elements so that data entry without Javascript enabled is possible, and so that they accept full account numbers.  This means no need to wait for the lookup to complete

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/UI/ajax/helpers.js
    branches/1.3/UI/lib/elements.html
    branches/1.3/bin/gl.pl
    branches/1.3/scripts/journal.pl

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-02-17 11:13:40 UTC (rev 4327)
+++ branches/1.3/Changelog	2012-02-17 12:38:12 UTC (rev 4328)
@@ -5,7 +5,9 @@
 Changelog for 1.3.12
 * Corrected processing of <?lsmb tags in order/invoice numbers (Chris T)
 * Corrected handling of accounts in dropdowns where () are present (Chris T)
-* Corrected erroneous log messages from bebugging 1.3.11 (Chris T)
+* Corrected erroneous log messages from debugging 1.3.11 (Chris T)
+* Autocomplete ajaxselect now work (degraded) without Javascript (Chris T)
+* Autocomplete ajaxselect now accept full entry without waiting (Chris T)
 
 Changelog for 1.3.11
 * Fixed outstanding report for payment reversal and partial payments (Chris T)

Modified: branches/1.3/UI/ajax/helpers.js
===================================================================
--- branches/1.3/UI/ajax/helpers.js	2012-02-17 11:13:40 UTC (rev 4327)
+++ branches/1.3/UI/ajax/helpers.js	2012-02-17 12:38:12 UTC (rev 4328)
@@ -1,6 +1,6 @@
 function post_ajax_setter(text,li)
 {
-	hidden_field_to_update = text.id.substring(0,text.id.length-10);
+	hidden_field_to_update = text.id;
 	$(hidden_field_to_update).value = li.id;
 	text.blur();
 }

Modified: branches/1.3/UI/lib/elements.html
===================================================================
--- branches/1.3/UI/lib/elements.html	2012-02-17 11:13:40 UTC (rev 4327)
+++ branches/1.3/UI/lib/elements.html	2012-02-17 12:38:12 UTC (rev 4328)
@@ -123,37 +123,34 @@
 	    custom_attribute_data=element_data.attributes 
 	  ?>
 	  <?lsmb PROCESS auto_label  # Process element label. ?>
-	  <input type="text" class="autocomplete" size="60" value="<?lsmb element_data.initial_value ?>" id="<?lsmb attribute_data.id ?>-ac-search" name="<?lsmb attribute_data.id ?>-ac-search" onclick="this.value='';" onblur="this.value = $('<?lsmb attribute_data.id ?>').value" />
-	  <input type="hidden" id="<?lsmb attribute_data.id ?>" name="<?lsmb element_data.name ?>"  value="<?lsmb element_data.initial_value?>" />
+	  <input type="text" 
+                class="autocomplete ajaxselect" 
+                 size="60" 
+                value="<?lsmb element_data.initial_value ?>" 
+                   id="<?lsmb attribute_data.id ?>" 
+                 name="<?lsmb element_data.name ?>" 
+              onclick="this.value='';" 
+          />
+	  <input type="hidden" 
+                   id="<?lsmb attribute_data.id ?>" 
+                 name="<?lsmb element_data.name ?>-old"  
+                value="<?lsmb element_data.initial_value?>" 
+          />
 	  <span class="indicator" id="<?lsmb attribute_data.id ?>-ac-indicator" style="display: none">Working...</span>
 	  <div id="<?lsmb attribute_data.id ?>-ac-choices" class="autocomplete"></div>
 	  <script language="javascript" type="text/javascript"><!--
-	    function post_ajax_setter(text,li)
-	    {
-	      hidden_field_to_update = text.id.substring(0,text.id.length-10);
-	      $(hidden_field_to_update).value = li.id;
-	      text.blur();
-	    }
-	    new Ajax.Autocompleter('<?lsmb attribute_data.id ?>-ac-search', 
+	    new Ajax.Autocompleter('<?lsmb attribute_data.id ?>', 
                                    '<?lsmb attribute_data.id ?>-ac-choices', 
                                    '<?lsmb element_data.ajax_target ?>', 
                                    {"afterUpdateElement":post_ajax_setter,
-                                   <?lsmb IF attribute_data.params ?>
-                                   'parameters' : <?lsmb SET params=""; FOR k
+                                   'parameters' : 
+                                                <?lsmb SET params="search_field=" _ attribute_data.id; 
+                                               FOR k
                                                IN attribute_data.params.keys();
-                                                IF params == "";
-                                                    params = "$k=" _ attribute_data.params.$k;
-                                                ELSE;
-                                                    params = params _ "&$k=" _ attribute_data.params.$k;
-                                                END;
-                                                
+                                                  params = params _ "&$k=" _ attribute_data.params.$k;
                                                END;
-                                               #"<?lsmb k >" : <?lsmb
-                                               #   attribute_data.params.$k
-                                               #->
                                                ?>
                                                <?lsmb '"' _ params _ '"'?>
-                                               <?lsmb END -?>
                                                
                                    })
 	  //--></script>

Modified: branches/1.3/bin/gl.pl
===================================================================
--- branches/1.3/bin/gl.pl	2012-02-17 11:13:40 UTC (rev 4327)
+++ branches/1.3/bin/gl.pl	2012-02-17 12:38:12 UTC (rev 4328)
@@ -1053,6 +1053,7 @@
          $form->{oldtransdate} = $form->{transdate};
      }
 
+    GL->get_all_acc_dep_pro( \%myconfig, \%$form );
     @a     = ();
     $count = 0;
     @flds  = qw(accno debit credit projectnumber fx_transaction source memo);
@@ -1061,6 +1062,19 @@
         unless ( ( $form->{"debit_$i"} eq "" )
             && ( $form->{"credit_$i"} eq "" ) )
         {
+            my $found_acc = 0;
+            for my $acc(@{ $form->{all_accno} }){
+                if ($form->{"accno_$i"} eq $acc->{accstyle}){
+                    $found_acc = 1;
+                } elsif ($form->{"accno_$i"} eq $acc->{accno}){
+                    $form->{"accno_$i"} = $acc->{accstyle};
+                    $found_acc = 1;
+                }
+
+           }
+           if (not $found_acc){
+               $form->error($locale->text('Account [_1] not found.', $form->{"accno_$i"}));
+           }
             for (qw(debit credit)) {
                 $form->{"${_}_$i"} =
                   $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
@@ -1085,7 +1099,6 @@
 
     $form->{rowcount} = $count;
  
-    GL->get_all_acc_dep_pro( \%myconfig, \%$form );
     
     
     &display_form;

Modified: branches/1.3/scripts/journal.pl
===================================================================
--- branches/1.3/scripts/journal.pl	2012-02-17 11:13:40 UTC (rev 4327)
+++ branches/1.3/scripts/journal.pl	2012-02-17 12:38:12 UTC (rev 4328)
@@ -47,15 +47,11 @@
     
     my $funcname = 'chart_list_search';
     my %results_hash;
-    foreach my $r (keys %{$request})
-    {
-       
-      if ($r =~ m/-ac-search$/)
-      {
-        my @call_args = ($request->{$r}, $request->{link_desc});
-        my @results = $request->call_procedure( procname => $funcname, args => ..hidden.., order_by => 'accno' );
-        foreach (@results) { $results_hash{$_->{'accno'}.'--'.$_->{'description'}} = $_->{'accno'}.'--'.$_->{'description'}; }
-      }
+    my $search_field = $request->{search_field};
+    $search_field =~ s/-/_/g;
+    my @call_args = ($request->{$search_field}, $request->{link_desc});
+    my @results = $request->call_procedure( procname => $funcname, args => ..hidden.., order_by => 'accno' );
+    foreach (@results) { $results_hash{$_->{'accno'}.'--'.$_->{'description'}} = $_->{'accno'}.'--'.$_->{'description'}; 
     }
     
     $request->{results} = \%results_hash;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.