noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 07/10: Improve ManageTable : input can return


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 07/10: Improve ManageTable : input can return a value + cosmetic
Date: Sun, 28 Mar 2021 09:22:05 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit b607bb138ec2882517101c0f20bfab7714702970
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Mar 25 17:44:30 2021 +0100

    Improve ManageTable : input can return a value + cosmetic
---
 html/js/managetable.js                 | 12 +++++++++++-
 include/lib/manage_table_sql.class.php | 27 +++++++++++++++++++--------
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/html/js/managetable.js b/html/js/managetable.js
index ba54f18..5d8081b 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -128,7 +128,17 @@ var ManageTable = function (p_table_name)
         // value if less than insert before
         var i = 0;
         for (i = 1;i<p_table.rows.length;i++) {
-            if (p_table.rows[i].cells[sort_column].getAttribute('sort_value') 
> p_element_row.cells[sort_column].getAttribute('sort_value')) {
+            var 
table_value=p_table.rows[i].cells[sort_column].getAttribute('sort_value') ;
+            var 
element_value=p_element_row.cells[sort_column].getAttribute('sort_value');
+            
+                // if both are numeric so we force a numeric comparison
+            if ( ! isNaN(parseFloat(table_value))  && ! 
isNaN(parseFloat(element_value)) ) {
+                table_value=parseFloat(table_value);
+                element_value=parseFloat(element_value);
+            }
+            
+            if (table_value > element_value) {
+                
                 var row=p_table.insertRow(i);
                 row.innerHTML=p_element_row.innerHTML;
                 row.id=p_element_row.id;
diff --git a/include/lib/manage_table_sql.class.php 
b/include/lib/manage_table_sql.class.php
index fc14cb0..5b9ea64 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -997,7 +997,10 @@ function check()
      * to be appended or modified. Can be override if you need
      * a more complex form or add elements with "set_order" before 
      * calling this function. 
-     * This function does not add the form , only the table, 
+     * This function does not add the form , only the table. 
+     * 
+     * It returns true , if it is not readyonly and the form will have a 
"save" button, if it returns nothing or false
+     * then there is no save button, nor form, the content is then readonly
      *  
      */
     function input()
@@ -1089,6 +1092,7 @@ function check()
             echo "</tr>";
         }
         echo "</table>";
+        return true;
     }
     /**
      * @brief this function let you create your own input , for example for a 
ITEXT , a IRADIO , ...
@@ -1179,7 +1183,10 @@ function check()
     }
 
     /**
-     * @brief send an xml with input of the object, create an xml answer.
+     * @brief send an xml with input of the object, create an xml answer. It 
will call Manage_Table_SQL.input to
+     * display the  input , but if that function returns false, the "save" 
button will disappear but the form can be
+     * submitted with enter.
+     * 
      * XML Tag 
      *   - status  : OK , NOK 
      *   - ctl     : Dom id to update 
@@ -1201,7 +1208,8 @@ function check()
                     $this->object_name, $this->table->get_pk_value(),
                     $this->object_name, $this->object_name,
                     $this->table->get_pk_value());
-            $this->input();
+            $can_update=$this->input();
+            $can_update =(  $can_update===false) ? false:true;
             // JSON param to hidden
             echo HtmlInput::json_to_hidden($this->json_parameter);
             echo HtmlInput::hidden("p_id", $this->table->get_pk_value());
@@ -1209,11 +1217,14 @@ function check()
             $close=sprintf("\$('%s').remove()", $this->dialog_box);
             // display error if any
             $this->display_error();
-            echo '<ul class="aligned-block">',
-            '<li>',
-            HtmlInput::submit('update', _("Sauver")),
-            '</li>',
-            '<li>',
+            echo '<ul class="aligned-block">';
+            // form readonly
+            if ( $can_update ) {
+                echo '<li>',
+                    HtmlInput::submit('update', _("Sauver")),
+               '</li>';
+            }
+            echo '<li>',
             HtmlInput::button_action(_("Annuler"), $close, "", "smallbutton"),
             '</li>',
             '</ul>';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]