noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 46/219: Manage_Table : Improve Javascript for


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 46/219: Manage_Table : Improve Javascript for adding / removing row of table
Date: Mon, 18 Dec 2017 13:22:36 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 0e95617873b190be40c9d4f09e516804ddebb9fb
Author: Dany De Bontridder <address@hidden>
Date:   Wed Sep 13 00:06:37 2017 +0200

    Manage_Table : Improve Javascript for adding / removing row of table
---
 html/js/managetable.js                 |  8 +++++---
 include/lib/manage_table_sql.class.php | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/html/js/managetable.js b/html/js/managetable.js
index 84c2d88..fe125da 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -97,8 +97,10 @@ var ManageTable = function (p_table_name)
         // use the table
         //compute the length of row
         //if rows == 0 or the sort is not defined then append 
-        if ( sort_column=-1 || p_table.rows.length < 2 || 
p_table.rows[1].cells[sort_column] == undefined || 
p_table.rows[1].cells[sort_column].getAttribute('sort_value') == undefined ) {
-            p_table.appendChild(p_element_row);
+        if ( this.sort_column==-1 || p_table.rows.length < 2 || 
p_table.rows[1].cells[sort_column] == undefined || 
p_table.rows[1].cells[sort_column].getAttribute('sort_value') == undefined ) {
+             var row=p_table.insertRow(p_table.rows.length);
+            row.innerHTML=p_element_row.innerHTML;
+            row.id=p_element_row.id;
             return;
         }
         // loop for each row , compare the innerHTML of the column with the
@@ -262,7 +264,7 @@ var ManageTable = function (p_table_name)
                     var answer = here.parseXML(req);
                     if (answer['status'] == 'OK') {
                         var x=answer['ctl_row'];
-                        $(x).hide();
+                        $(x).remove();
                         alternate_row_color("tb"+answer['ctl']);
                         }else {
                              smoke.alert("Effacement impossible");
diff --git a/include/lib/manage_table_sql.class.php 
b/include/lib/manage_table_sql.class.php
index 4678b9e..087828e 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -114,6 +114,13 @@ class Manage_Table_SQL
         $this->col_sort=0;
     }
     /**
+     * send the XML headers for the ajax call 
+     */
+    function send_header()
+    {
+        header('Content-type:text/xml;charset="UTF-8"');
+    }
+    /**
      * When adding an element , it is column we checked to insert before,
      * @return none
      */
@@ -177,9 +184,34 @@ class Manage_Table_SQL
 
     /**
      * This function can be overrided to check the data before 
-     * inserting , updating or removing,
+     * inserting , updating or removing, above an example of an overidden check
      * @see set_error get_error
      * @return boolean
+     * @code 
+function check()
+    {
+        global $cn;
+        $table=$this->get_table();
+        $is_error=0;
+        $insert=false;
+        // sect_codename must be unique 
+        if ( $table->exist() > 0) {
+            $insert=1;
+        }
+        $count=$cn->get_value(" select count(*) from syndicat.treasurer where 
tr_login=$1 and sect_id=$2 and tr_id<>$3",
+                array(
+                    $table->tr_login,
+                    $table->section_full_name,
+                    $table->tr_id
+                ));
+        if ($count > 0 ) {
+            $this->set_error("section_full_name",_("Ce trésorier a déjà accès 
à cette section"));
+            $is_error++;
+        }
+        if ( $is_error > 0 ) return false;
+        return true;
+    }    
+     * @endcode
      */
     function check()
     {



reply via email to

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