fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12159] attempt a switch to inline tables in conditio


From: Sigurd Nes
Subject: [Fmsystem-commits] [12159] attempt a switch to inline tables in condition_survey
Date: Sun, 12 Oct 2014 17:46:08 +0000

Revision: 12159
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12159
Author:   sigurdne
Date:     2014-10-12 17:46:07 +0000 (Sun, 12 Oct 2014)
Log Message:
-----------
attempt a switch to inline tables in condition_survey

Modified Paths:
--------------
    branches/dev-syncromind/phpgwapi/js/jquery/common.js
    branches/dev-syncromind/property/inc/class.uicondition_survey.inc.php
    branches/dev-syncromind/property/templates/base/condition_survey.xsl

Modified: branches/dev-syncromind/phpgwapi/js/jquery/common.js
===================================================================
--- branches/dev-syncromind/phpgwapi/js/jquery/common.js        2014-10-10 
22:57:47 UTC (rev 12158)
+++ branches/dev-syncromind/phpgwapi/js/jquery/common.js        2014-10-12 
17:46:07 UTC (rev 12159)
@@ -12,14 +12,46 @@
        return '<a href="' + link + '">' + name + '</a>';
 };
 
-JqueryPortico.inlineTableHelper = function(container, url, colDefs, options, 
disablePagination) {
-       
-       var columns = [];
-       for (i=0; i<colDefs.length; i++) {
-               columns.push({"data":colDefs[i]['key']}); 
-       }
-       
+JqueryPortico.FormatterAmount0 = function(key, oData) {
+//     var amount = YAHOO.util.Number.format(oData, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
+       //FIXME...
+       var amount = parseInt(oData[key]);
+       return "<div class='nowrap' align=\"right\">"+amount+"</div>";
+};
+
+JqueryPortico.inlineTableHelper = function(container, ajax_url, columns, 
options, disablePagination) {
+//     var columns = [];
+//     for (i=0; i<colDefs.length; i++) {
+//             columns.push({"data":colDefs[i]['key']});
+//     }
+
        return {container:container, columns: columns, url: url};
+
+       $(document).ready(function ()
+       {
+               var oTable = $("#" + container).dataTable( {
+                       processing:             true,
+                       serverSide:             true,
+                       responsive:             true,
+                       deferRender:    true,
+                       ajax:                   {
+                               url: ajax_url,
+//                             data: { cat_id: '' },
+                               type: 'GET'
+                       },
+               //      lengthMenu:             JqueryPortico.i18n.lengthmenu(),
+               //      language:               JqueryPortico.i18n.datatable(),
+                       columns:                columns,
+               //      colVis: {
+               //                                      exclude: exclude_colvis
+               //      },
+               //      dom:                    
'lCT<"clear">f<"top"ip>rt<"bottom"><"clear">',
+               //      stateSave:              true,
+               //      stateDuration: -1, //sessionstorage
+               //      tabIndex:               1,
+               //      oTableTools: JqueryPortico.TableTools
+               } );
+       });
 };
 
 JqueryPortico.autocompleteHelper = function(baseUrl, field, hidden, container, 
label_attr) {

Modified: branches/dev-syncromind/property/inc/class.uicondition_survey.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uicondition_survey.inc.php       
2014-10-10 22:57:47 UTC (rev 12158)
+++ branches/dev-syncromind/property/inc/class.uicondition_survey.inc.php       
2014-10-12 17:46:07 UTC (rev 12159)
@@ -470,10 +470,10 @@
 //                             array('key' => 
'category','label'=>lang('category'),'sortable'=>false,'resizeable'=>true),
                                array('key' => 
'condition_degree','label'=>lang('condition 
degree'),'sortable'=>false,'resizeable'=>true),
                                array('key' => 
'score','label'=>lang('score'),'sortable'=>true,'resizeable'=>true),
-                               array('key' => 
'amount_investment','label'=>lang('investment'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 
'amount_operation','label'=>lang('operation'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 
'amount_potential_grants','label'=>lang('potential 
grants'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-//                             array('key' => 
'planned_budget','label'=>lang('planned 
budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
+                               array('key' => 
'amount_investment','label'=>lang('investment'),'sortable'=>true,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 
'amount_operation','label'=>lang('operation'),'sortable'=>true,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 
'amount_potential_grants','label'=>lang('potential 
grants'),'sortable'=>true,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+//                             array('key' => 
'planned_budget','label'=>lang('planned 
budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
                                array('key' => 
'recommended_year','label'=>lang('recommended 
year'),'sortable'=>true,'resizeable'=>true),
                                array('key' => 
'planned_year','label'=>lang('planned 
year'),'sortable'=>true,'resizeable'=>true),
                                array('key' => 
'related','label'=>lang('related'),'sortable'=>false,'resizeable'=>true),
@@ -490,13 +490,13 @@
                        (
                                array('key' => 
'building_part','label'=>lang('building 
part'),'sortable'=>false,'resizeable'=>true),
                                array('key' => 
'category','label'=>lang('category'),'sortable'=>true,'resizeable'=>true),
-                               array('key' => 'period_1','label'=>lang('year') 
. ':: < 1' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_2','label'=>lang('year') 
. ':: 1 - 5' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_3','label'=>lang('year') 
. ':: 6 - 10' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_4','label'=>lang('year') 
. ':: 11 - 15' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_5','label'=>lang('year') 
. ':: 16 - 20' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_6','label'=>lang('year') 
. ':: 21 +' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 
'sum','label'=>lang('sum'),'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: < 1' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_2','label'=>lang('year') 
. ':: 1 - 5' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_3','label'=>lang('year') 
. ':: 6 - 10' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_4','label'=>lang('year') 
. ':: 11 - 15' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_5','label'=>lang('year') 
. ':: 16 - 20' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_6','label'=>lang('year') 
. ':: 21 +' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 
'sum','label'=>lang('sum'),'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
                        );
 
                        $datatable_def[] = array
@@ -646,7 +646,7 @@
 
 //------ Start pagination
 
-                       $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
+                       $start = phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $total_records = count($files);
 
                        $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
@@ -678,7 +678,8 @@
                                        'delete_file' => "<input 
type='checkbox' name='file_action[]' value='{$_entry['name']}' 
title='$lang_delete'>",
                                );
                        }
-
+/*
+ * yui-result
                        $data = array(
                                 'ResultSet' => array(
                                        'totalResultsAvailable' => 
$total_records,
@@ -691,7 +692,14 @@
                                )
                        );
                        return $data;
-
+*/
+                       //Jquery result
+                       return array(
+                               'recordsTotal'          => $total_records,
+                               'recordsFiltered'       => $total_records,
+                               'draw'                          => 
phpgw::get_var('draw', 'int'),
+                               'data'                          => $values,
+                       );
                }
 
                function get_summation()
@@ -755,7 +763,7 @@
                        $total_records = count($values);
                        
                        $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
-                       $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
+                       $start = phpgw::get_var('start', 'int', 'REQUEST', 0);
 
                        $allrows = true;
                        $num_rows = $total_records;
@@ -771,17 +779,12 @@
                                $out = $values_part[$page];
                        }
                        
-
-                       $result_data = array('results' => $out);
-
-                       $result_data['total_records'] = $total_records;
-//                     $result_data['start'] = $params['start'];
-//                     $result_data['sort'] = $params['sort'];
-//                     $result_data['dir'] = $params['dir'];
-                       $result_data['draw'] = $draw;
-
-
-                       return $this->jquery_results($result_data);
+                       return array(
+                               'recordsTotal'          => $total_records,
+                               'recordsFiltered'       => $total_records,
+                               'draw'                          => 
phpgw::get_var('draw', 'int'),
+                               'data'                          => $out
+                       );
                        
                }
 
@@ -796,7 +799,7 @@
                        }
 
                        $borequest      = CreateObject('property.borequest');
-                       $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
+                       $start = phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $sortKey = phpgw::get_var('sort', 'string', 'REQUEST', 
'request_id');
                        $sortDir = phpgw::get_var('dir', 'string', 'REQUEST', 
'ASC');
 
@@ -818,6 +821,7 @@
                        }
 
                        $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;
+/* yui-data
                        $data = array(
                                 'ResultSet' => array(
                                        'totalResultsAvailable' => 
$total_records,
@@ -830,6 +834,14 @@
                                )
                        );
                        return $data;
+ *
+ */
+                       return array(
+                               'recordsTotal'          => $total_records,
+                               'recordsFiltered'       => $total_records,
+                               'draw'                          => 
phpgw::get_var('draw', 'int'),
+                               'data'                          => $values,
+                       );
                }
 
 
@@ -1514,13 +1526,13 @@
                        (
                                array('key' => 
'building_part','label'=>lang('building 
part'),'sortable'=>false,'resizeable'=>true),
                                array('key' => 
'category','label'=>lang('category'),'sortable'=>false,'resizeable'=>true),
-                               array('key' => 'period_1','label'=>lang('year') 
. ':: < 1' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_2','label'=>lang('year') 
. ':: 1 - 5' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_3','label'=>lang('year') 
. ':: 6 - 10' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_4','label'=>lang('year') 
. ':: 11 - 15' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_5','label'=>lang('year') 
. ':: 16 - 20' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 'period_6','label'=>lang('year') 
. ':: 21 +' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
-                               array('key' => 
'sum','label'=>lang('sum'),'sortable'=>false,'resizeable'=>true,'formatter'=>'YAHOO.portico.FormatterAmount0'),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: < 1' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_2','label'=>lang('year') 
. ':: 1 - 5' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_3','label'=>lang('year') 
. ':: 6 - 10' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_4','label'=>lang('year') 
. ':: 11 - 15' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_5','label'=>lang('year') 
. ':: 16 - 20' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
+                               array('key' => 'period_6','label'=>lang('year') 
. ':: 21 +' 
,'sortable'=>false,'resizeable'=>true,'formatter'=>'YJqueryPortico.FormatterAmount0'),
+                               array('key' => 
'sum','label'=>lang('sum'),'sortable'=>false,'resizeable'=>true,'formatter'=>'JqueryPortico.FormatterAmount0'),
                        );
 
                        $datatable_def = array();

Modified: branches/dev-syncromind/property/templates/base/condition_survey.xsl
===================================================================
--- branches/dev-syncromind/property/templates/base/condition_survey.xsl        
2014-10-10 22:57:47 UTC (rev 12158)
+++ branches/dev-syncromind/property/templates/base/condition_survey.xsl        
2014-10-12 17:46:07 UTC (rev 12159)
@@ -253,8 +253,17 @@
                             </label>
                         </dt>
                         <dd>
-                            <div style="clear:both;" 
id="datatable-container_0"></div>
-                        </dd>
+                            <!--div style="clear:both;" 
id="datatable-container_0"></div-->
+                                                       <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_0'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
  <xsl:with-param name="container" select ='container'/>
+                                                                               
  <xsl:with-param name="requestUrl" select ='requestUrl' />
+                                                                               
  <xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                       </xsl:for-each>
+                                               </dd>
 
                         <xsl:choose>
                             <xsl:when test="editable = 1">
@@ -295,8 +304,18 @@
                             </label>
                         </dt>
                         <dd>
-                            <div style="clear:both;" 
id="datatable-container_1"></div>
-                        </dd>
+                            <!--div style="clear:both;" 
id="datatable-container_1"></div-->
+                                                       <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_1'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
  <xsl:with-param name="container" select ='container'/>
+                                                                               
  <xsl:with-param name="requestUrl" select ='requestUrl' />
+                                                                               
  <xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                       </xsl:for-each>
+
+                                               </dd>
                     </dl>
                 </div>
                 <div id="summation">
@@ -307,7 +326,17 @@
                             </label>
                         </dt>
                         <dd>
-                            <div style="clear:both;" 
id="datatable-container_2"></div>
+                            <!--div style="clear:both;" 
id="datatable-container_2"></div-->
+                                                       <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_2'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
  <xsl:with-param name="container" select ='container'/>
+                                                                               
  <xsl:with-param name="requestUrl" select ='requestUrl' />
+                                                                               
  <xsl:with-param name="ColumnDefs" select ='ColumnDefs' />
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                       </xsl:for-each>
+
                         </dd>
                     </dl>
                 </div>
@@ -433,7 +462,7 @@
             </xsl:for-each>
             ];
                        
-            YAHOO.portico.inlineTableHelper("<xsl:value-of 
select="container"/>", <xsl:value-of select="requestUrl"/>, columnDefs);
+ //           YAHOO.portico.inlineTableHelper("<xsl:value-of 
select="container"/>", <xsl:value-of select="requestUrl"/>, columnDefs);
         </xsl:for-each>
 
         var PaginatorName2 = 'paginator_containerdatatable-container_2';
@@ -491,3 +520,83 @@
     </xsl:choose>
 </xsl:template>
 
+<xsl:template name="table_setup">
+       <xsl:param name="container" />
+       <xsl:param name="requestUrl" />
+       <xsl:param name="ColumnDefs" />
+       <table id="{$container}" class="display cell-border compact responsive 
no-wrap" width="100%">
+               <thead>
+                       <tr>
+                               <xsl:for-each select="$ColumnDefs">
+                                       <xsl:choose>
+                                               <xsl:when test="hidden">
+                                                       <xsl:if test="hidden 
=0">
+                                                               <th>
+                                                                       
<xsl:value-of select="label"/>
+                                                               </th>
+                                                               </xsl:if>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <th>
+                                                               <xsl:value-of 
select="label"/>
+                                                       </th>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:for-each>
+                       </tr>
+               </thead>
+       </table>
+       <script>
+               var PreColumns = [
+                               <xsl:for-each select="$ColumnDefs">
+                               {
+                                       data:                   "<xsl:value-of 
select="key"/>",
+                                       class:                  "<xsl:value-of 
select="className"/>",
+                                       orderable:              <xsl:value-of 
select="phpgw:conditional(not(sortable = 0), 'true', 'false')"/>,
+                                       <xsl:choose>
+                                               <xsl:when test="hidden">
+                                                       <xsl:if test="hidden 
=0">
+                                                               visible         
        :true,
+                                                       </xsl:if>
+                                                       <xsl:if test="hidden 
=1">
+                                                               class:          
        'none',
+                                                               visible         
        :false,
+                                                       </xsl:if>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                               visible         
        :true,
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                                       <xsl:if test="formatter">
+                                        render: function (dummy1, dummy2, 
oData) {
+                                                       try {
+                                                               var ret = 
<xsl:value-of select="formatter"/>("<xsl:value-of select="key"/>", oData);
+                                                       }
+                                                       catch(err) {
+                                                               return 
err.message;
+                                                       }
+                                                       return ret;
+                         },
+
+                                       </xsl:if>
+                                       defaultContent: "<xsl:value-of 
select="defaultContent"/>"
+                               }<xsl:value-of 
select="phpgw:conditional(not(position() = last()), ',', '')"/>
+                       </xsl:for-each>
+               ];
+<![CDATA[
+               columns = [];
+
+               for(i=0;i < PreColumns.length;i++)
+               {
+                       if ( PreColumns[i]['visible'] == true )
+                       {
+                               columns.push(PreColumns[i]);
+                       }
+               }
+]]>
+
+               JqueryPortico.inlineTableHelper2("<xsl:value-of 
select="$container"/>", <xsl:value-of select="$requestUrl"/>, columns);
+
+       </script>
+</xsl:template>
+




reply via email to

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