fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12718] convert table on controller


From: Sigurd Nes
Subject: [Fmsystem-commits] [12718] convert table on controller
Date: Fri, 06 Feb 2015 19:27:24 +0000

Revision: 12718
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12718
Author:   sigurdne
Date:     2015-02-06 19:27:23 +0000 (Fri, 06 Feb 2015)
Log Message:
-----------
convert table on controller

Modified Paths:
--------------
    
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_location.inc.php
    branches/dev-syncromind/controller/js/controller/ajax_control_to_location.js
    
branches/dev-syncromind/controller/templates/base/control_location/register_control_to_location.xsl

Removed Paths:
-------------
    branches/dev-syncromind/controller/js/yahoo/register_control.js

Modified: 
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_location.inc.php
===================================================================
--- 
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_location.inc.php
 2015-02-06 19:26:27 UTC (rev 12717)
+++ 
branches/dev-syncromind/controller/inc/class.uicontrol_register_to_location.inc.php
 2015-02-06 19:27:23 UTC (rev 12718)
@@ -36,9 +36,9 @@
        */
        phpgw::import_class('phpgwapi.jquery');
 
-       phpgw::import_class('phpgwapi.uicommon');
+       phpgw::import_class('phpgwapi.uicommon_jquery');
                
-       class controller_uicontrol_register_to_location extends 
phpgwapi_uicommon
+       class controller_uicontrol_register_to_location extends 
phpgwapi_uicommon_jquery
        {
                var $cat_id;
                var $start;
@@ -132,8 +132,21 @@
                        (
                                'name'          => "0",
                                'values'        =>      json_encode(array())
-                       );      
+                       );
 
+                       $datatable_def = array();
+                       $datatable_def[] = array
+                       (
+                               'container'             => 
'datatable-container_0',
+                               'requestUrl'    => "''",
+                               'data'                  => json_encode(array()),
+                               'ColumnDefs'    => array(),
+                               'config'                => array(
+                                       array('disableFilter'   => true),
+                                       array('disablePagination'       => true)
+                               )
+                       );
+
                        $GLOBALS['phpgw']->translation->add_app('property');
 
                        $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
@@ -163,10 +176,11 @@
 
                        array_unshift ($control_area_list ,array 
('id'=>'','name'=>lang('select')));
 
-                       
+
                                        
                        $data = array
                        (
+                               'datatable_def'                                 
=> $datatable_def,
                                'td_count'                                      
        => '""',
                                'datatable'                                     
        => $datavalues,
                                'myColumnDefs'                                  
=> $myColumnDefs,
@@ -190,7 +204,7 @@
                        self::add_javascript('controller', 'controller', 
'ajax_control_to_location.js');
                        self::add_javascript('controller', 'yahoo', 
'register_control.js');
 
-                       
self::render_template_xsl(array('control_location/register_control_to_location' 
), $data);
+                       
self::render_template_xsl(array('control_location/register_control_to_location'),
 $data);
                }
 
                
@@ -269,37 +283,26 @@
 
                        $columndef = array();
 
-                       /*This one has to defined - chokes otherwise*/
                        $columndef[] = array
                        (
-                               'key'           => 'id',
-                               'label'         => '',
-                               'sortable'      => false,
+                               'data'          => 'select',
+                               'title'         => lang('select'),
+                               'orderable'     => false,
                                'formatter'     => false,
-                               'hidden'        => true,
-                               'className' => false
+                               'visible'       => true,
+                               'class' => ''
                        );
 
                        $columndef[] = array
                        (
-                               'key'           => 'select',
-                               'label'         => lang('select'),
-                               'sortable'      => false,
+                               'data'          => 'delete',
+                               'title'         => lang('delete'),
+                               'orderable'     => false,
                                'formatter'     => false,
-                               'hidden'        => false,
-                               'className' => ''
+                               'visible'       => true,
+                               'class' => ''
                        );
 
-                       $columndef[] = array
-                       (
-                               'key'           => 'delete',
-                               'label'         => lang('delete'),
-                               'sortable'      => false,
-                               'formatter'     => false,
-                               'hidden'        => false,
-                               'className' => ''
-                       );
-
                        $count_fields = count($uicols['name']);
 
                        for ($i=0;$i<$count_fields;$i++)
@@ -317,18 +320,36 @@
                                {
                                        $columndef[] = array
                                        (
-                                               'key'           => 
$uicols['name'][$i],
-                                               'label'         => 
$uicols['descr'][$i],
-                                               'sortable'      => 
!!$uicols['sortable'][$i],
+                                               'data'          => 
$uicols['name'][$i],
+                                               'title'         => 
$uicols['descr'][$i],
+                                               'orderable'     => 
!!$uicols['sortable'][$i],
                                                'formatter'     => $formatter,
-                                               'hidden'        => 
$uicols['input_type'][$i] == 'hidden' ? true : false ,               
-                                               'className'     => 
$uicols['classname'][$i],
+                                               'visible'       => 
$uicols['input_type'][$i] == 'hidden' ? false : true ,
+                                               'class' => 
$uicols['classname'][$i],
                                        );
                                }
                        }
 
+                       foreach($columndef as &$entry)
+                       {
+                               if($entry['formatter'])
+                               {
+                                       $render = <<<JS
+                                       function (dummy1, dummy2, oData) {
+                                                       try {
+                                                               var ret = 
{$entry['formatter']}("{$entry['data']}", oData);
+                                                       }
+                                                       catch(err) {
+                                                               return 
err.message;
+                                                       }
+                                                       return ret;
+                         }
+JS;
+                                                $entry['render'] = $render;
 
-//_debug_array($columndef);
+                               }
+                               unset($entry['formatter']);
+                       }
                        return $columndef;
                }
 
@@ -354,32 +375,37 @@
 
                public function query()
                {
-                       $type_id = phpgw::get_var('location_level', 'int', 
'REQUEST', 1);
-                       $district_id            = phpgw::get_var('district_id', 
'int');
-                       $part_of_town_id        = 
phpgw::get_var('part_of_town_id', 'int');
-                       $control_id                     = 
phpgw::get_var('control_id', 'int');
-                       $results                        = 
phpgw::get_var('results', 'int');
-                       $control_registered     = 
phpgw::get_var('control_registered', 'bool');
+                       
+                       $search = phpgw::get_var('search');
+                       $order = phpgw::get_var('order');
+                       $draw = phpgw::get_var('draw', 'int');
+                       $columns = phpgw::get_var('columns');
+                       $control_id = phpgw::get_var('control_id', 'int');
 
-                       $results = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : $results;
+                       $params = array(
+                               'start' => phpgw::get_var('start', 'int', 
'REQUEST', 0),
+                               'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
+                               'query' => $search['value'],
+                               'order' => 
$columns[$order[0]['column']]['data'],
+                               'sort' => $order[0]['dir'],
+                               'allrows' => phpgw::get_var('length', 'int') == 
-1,
+                               'control_registered' => 
phpgw::get_var('control_registered', 'bool'),
+                               'district_id' => phpgw::get_var('district_id', 
'int'),
+                               'cat_id' => phpgw::get_var('cat_id', 'int'),
+                               'status' => phpgw::get_var('status'),
+                               'part_of_town_id' => 
phpgw::get_var('part_of_town_id', 'int'),
+                               'location_code' => 
phpgw::get_var('location_code'),
+                               'type_id' => phpgw::get_var('location_level', 
'int', 'REQUEST', 1),
+                               'control_id' => $control_id
+                       );
 
-                       $this->bo->results = $results;                  
-            $this->bo->sort =  'ASC';
-            $this->bo->order =  'location_code';
-            $this->bo->start =  phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
+                       $values = $this->bo->read($params);
 
-                       $values = $this->bo->read(array('control_registered' => 
$control_registered,
-                                        'control_id' => $control_id,
-                                        'type_id'=>$type_id,
-                                        'allrows'=>$this->allrows,
-                                        'results' => $results
-                                       )
-                               );
-
-
-                       if($control_id)
+                       foreach($values as &$entry)
                        {
-                               foreach($values as &$entry)
+                               $entry['select'] = '';
+                               $entry['delete'] = '';
+                               if($control_id)
                                {
                                        $checked = '';
                                        if( 
$this->so_control->get_control_location($control_id, $entry['location_code']) )
@@ -390,20 +416,15 @@
                                        $entry['select'] = "<input class 
=\"mychecks_add\" type =\"checkbox\" $checked 
name=\"values[register_location][]\" 
value=\"{$control_id}_{$entry['location_code']}\">";
                                }
                        }
-                       
-                       $data = array(
-                                'ResultSet' => array(
-                                       'totalResultsAvailable' => 
$this->bo->total_records,
-                                       'startIndex' => $this->bo->start, 
-                                       'sortKey' => 'location_code', 
-                                       'sortDir' => "ASC", 
-                                       'Result' => $values,
-                                       'pageSize' => $results,
-                                       'activePage' => floor($this->bo->start 
/ $results) + 1
-                               )
+
+                       $result_data = array
+                       (
+                               'results'               => $values,
+                               'total_records' => $this->bo->total_records,
+                               'draw'                  => 
phpgw::get_var('draw', 'int')
                        );
 
-                       return $data;
+                       return $this->jquery_results($result_data);
                }
 
                public function edit_location()

Modified: 
branches/dev-syncromind/controller/js/controller/ajax_control_to_location.js
===================================================================
--- 
branches/dev-syncromind/controller/js/controller/ajax_control_to_location.js    
    2015-02-06 19:26:27 UTC (rev 12717)
+++ 
branches/dev-syncromind/controller/js/controller/ajax_control_to_location.js    
    2015-02-06 19:27:23 UTC (rev 12718)
@@ -1,3 +1,6 @@
+var myColumnDefs = new Array();
+var oTable = null;
+
 $(document).ready(function()
 {
 
@@ -53,7 +56,7 @@
 
                get_table_def();
 
-                var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_location_type_category',
 location_type: $(this).val()};
+               var oArgs = 
{menuaction:'controller.uicontrol_register_to_location.get_location_type_category',
 location_type: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
          var htmlString  = "<option value=''>Velg</option>";
@@ -302,8 +305,8 @@
                                if(obj.status == "updated")
                                {
                                        $(submitBnt).val("Lagret");
-
-                                           
YAHOO.portico.updateinlineTableHelper('datatable-container');
+                                       update_location_table();
+//                                     
JqueryPortico.updateinlineTableHelper(oTable0);
                                }
                                else
                                {
@@ -437,12 +440,11 @@
        var cat_id = $("#location_type_category").val() != null ? 
$("#location_type_category").val():'';
 
        var control_registered = 0;
-       if (typeof($($("#control_registered")).attr("checked")) != 'undefined' 
&& $($("#control_registered")).attr("checked") == 'checked')
+       if ($("#control_registered").prop("checked"))
        {
                control_registered = 1;
        }
 
-
        var location_code = '';
 
        if( $("#search-location_code").val() != null && 
$("#search-location_code").val())
@@ -470,10 +472,16 @@
        };
        var requestUrl = phpGWLink('index.php', oArgs, true);
 
-    YAHOO.portico.inlineTableHelper('datatable-container', requestUrl, 
myColumnDefs);
+       if(oTable)
+       {
+               api = oTable.api();
+               api.destroy();
+       }
+       $("#table_def").html( '<table cellpadding="0" cellspacing="0" 
border="0"  id="datatable-container_0"></table>' );
+       oTable = JqueryPortico.inlineTableHelper('datatable-container_0', 
requestUrl, myColumnDefs);
+
 }
 
-
 function update_location_table()
 {
        init_component_table();

Deleted: branches/dev-syncromind/controller/js/yahoo/register_control.js
===================================================================
--- branches/dev-syncromind/controller/js/yahoo/register_control.js     
2015-02-06 19:26:27 UTC (rev 12717)
+++ branches/dev-syncromind/controller/js/yahoo/register_control.js     
2015-02-06 19:27:23 UTC (rev 12718)
@@ -1,32 +0,0 @@
-       var FormatterRight = function(elCell, oRecord, oColumn, oData)
-       {
-               elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
-       }       
-
-       var FormatterCenter = function(elCell, oRecord, oColumn, oData)
-       {
-               elCell.innerHTML = "<center>"+oData+"</center>";
-       }
-
-
-       function checkAll(myclass)
-       {
-               controls = YAHOO.util.Dom.getElementsByClassName(myclass);
-
-               for(i=0;i<controls.length;i++)
-               {
-                       if(!controls[i].disabled)
-                       {
-                       
-                               if(controls[i].checked)
-                               {
-                                       controls[i].checked = false;
-                               }
-                               else
-                               {
-                                       controls[i].checked = true;
-                               }
-                       }
-               }
-       }
-

Modified: 
branches/dev-syncromind/controller/templates/base/control_location/register_control_to_location.xsl
===================================================================
--- 
branches/dev-syncromind/controller/templates/base/control_location/register_control_to_location.xsl
 2015-02-06 19:26:27 UTC (rev 12717)
+++ 
branches/dev-syncromind/controller/templates/base/control_location/register_control_to_location.xsl
 2015-02-06 19:27:23 UTC (rev 12718)
@@ -1,27 +1,9 @@
 <!-- $Id$ -->
 
-<func:function name="phpgw:conditional">
-       <xsl:param name="test"/>
-       <xsl:param name="true"/>
-       <xsl:param name="false"/>
-
-       <func:result>
-               <xsl:choose>
-                       <xsl:when test="$test">
-                               <xsl:value-of select="$true"/>
-                       </xsl:when>
-                       <xsl:otherwise>
-                               <xsl:value-of select="$false"/>
-                       </xsl:otherwise>
-               </xsl:choose>
-       </func:result>
-</func:function>
-
-<!-- separate tabs and  inline tables-->
-
 <xsl:template match="data" xmlns:php="http://php.net/xsl";>
-       <xsl:call-template name="yui_phpgw_i18n"/>
-       
+       <!--xsl:call-template name="yui_phpgw_i18n"/-->
+       <!--xsl:apply-template name="jquery_phpgw_i18n"/-->
+
 <div class="yui-navset yui-navset-top" id="control_location_tabview">
        <div class="identifier-header">
                <h1><xsl:value-of select="php:function('lang', 'locations for 
control')"/></h1>
@@ -55,10 +37,10 @@
                                        </div>
                                
                                        <div id="choose-location">
-                                                       <xsl:apply-templates 
select="filter_form" />
+                                               <xsl:apply-templates 
select="filter_form" />
                                        
                                                <form action="{update_action}" 
name="acl_form" id="acl_form" method="post">
-                                                                       
<xsl:apply-templates select="datatable"/>
+                                                               
<xsl:apply-templates select="datatable"/>
                                                </form>
                                        </div>
                                </div>
@@ -107,78 +89,24 @@
                          </select>
                        </div>
          </div>
-<!--           
-               <div class="select-box">
-                       <div class="filter">
-                               <label><xsl:value-of 
select="php:function('lang', 'property')" /></label>
-                               <select id="loc1" name="loc1">
-                                       <xsl:apply-templates 
select="loc1_list/options"/>
-                         </select>
-               </div>
-                 <div class="filter">
-                       <label><xsl:value-of select="php:function('lang', 
'building')" /></label>
-                         <select id="loc2" name="loc2">
-                                       <xsl:apply-templates 
select="loc2_list/options"/>
-                         </select>
-                       </div>
-         </div>
--->      
-         
-         <div class="select-box">
-                       <label>Søk etter eiendom/bygg/rom</label>
-                       <input type="text" value="" id="search-location-name" />
-                       <input id= "search-location_code" type="hidden" 
name="search-location_code"/>
-               </div>
-               
        </fieldset>
 </xsl:template>
 
 
 <xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
-       <div id="paging"></div>
-       <div id="datatable-container"></div>
-
-  <xsl:call-template name="datasource-definition" />
+       <div id="table_def" class="pure-custom" width="80%"></div>
+       
        <div id="receipt"></div>
   <xsl:variable name="label_submit"><xsl:value-of select="php:function('lang', 
'save')" /></xsl:variable>
        <input type="submit" name="update_acl" id="frm_update_acl" class="btn" 
value="{$label_submit}"/>
 
   <xsl:variable name="label_select_add"><xsl:value-of 
select="php:function('lang', 'select add')" /></xsl:variable>
-  <input type="button" name="select_add" id="frm_update_add" class="btn" 
value="{$label_select_add}" onclick="checkAll('mychecks_add')"/>
+  <input type="button" name="select_add" id="frm_update_add" class="btn" 
value="{$label_select_add}" onclick="JqueryPortico.checkAll('mychecks_add')"/>
        
   <xsl:variable name="label_select_delete"><xsl:value-of 
select="php:function('lang', 'select delete')" /></xsl:variable>
-       <input type="button" name="select_add" id="frm_update_delete" 
class="btn" value="{$label_select_delete}" 
onclick="checkAll('mychecks_delete')"/>
+       <input type="button" name="select_add" id="frm_update_delete" 
class="btn" value="{$label_select_delete}" 
onclick="JqueryPortico.checkAll('mychecks_delete')"/>
 </xsl:template>
 
-<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
-
-               <!--  DATATABLE DEFINITIONS-->
-               <script type="text/javascript">
-                       var datatable = new Array();
-                       var myColumnDefs = new Array();
-                       var myButtons = new Array();
-                       var td_count = <xsl:value-of select="//td_count"/>;
-
-                       <xsl:for-each select="//datatable">
-                               datatable[<xsl:value-of select="name"/>] = [
-                                       {
-                                               values:<xsl:value-of 
select="values"/>,
-                                               total_records: <xsl:value-of 
select="total_records"/>,
-                                               is_paginator:  <xsl:value-of 
select="is_paginator"/>,
-                                               edit_action:  <xsl:value-of 
select="edit_action"/>,
-                                               footer:<xsl:value-of 
select="footer"/>
-                                       }
-                               ]
-                       </xsl:for-each>
-                       <xsl:for-each select="//myColumnDefs">
-                               myColumnDefs[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
-                       </xsl:for-each>
-                       <xsl:for-each select="//myButtons">
-                               myButtons[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
-                       </xsl:for-each>
-               </script>
-</xsl:template>
-
 <!-- options for use with select-->
 <xsl:template match="options">
        <option value="{id}">




reply via email to

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