fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12000] api / property: custom javascript action for


From: Sigurd Nes
Subject: [Fmsystem-commits] [12000] api / property: custom javascript action for custom field listing
Date: Tue, 03 Jun 2014 11:20:33 +0000

Revision: 12000
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12000
Author:   sigurdne
Date:     2014-06-03 11:20:32 +0000 (Tue, 03 Jun 2014)
Log Message:
-----------
api / property: custom javascript action for custom field listing

Modified Paths:
--------------
    trunk/phpgwapi/inc/class.custom_fields.inc.php
    trunk/phpgwapi/setup/setup.inc.php
    trunk/phpgwapi/setup/tables_current.inc.php
    trunk/phpgwapi/setup/tables_update.inc.php
    trunk/property/inc/class.boentity.inc.php
    trunk/property/inc/class.uiadmin_entity.inc.php
    trunk/property/inc/class.uientity.inc.php

Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php      2014-06-03 09:12:04 UTC 
(rev 11999)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php      2014-06-03 11:20:32 UTC 
(rev 12000)
@@ -755,7 +755,8 @@
                                        'get_list_function_input' => 
$attrib['get_list_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_list_function_input'])) : '',
                                        'get_single_function'           => 
$attrib['get_single_function'],
                                        'get_single_function_input' => 
$attrib['get_single_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_single_function_input'])) : '',
-                                       'short_description'                     
=> isset($attrib['short_description']) && $attrib['short_description'] ? (int) 
$attrib['short_description'] : false
+                                       'short_description'                     
=> isset($attrib['short_description']) && $attrib['short_description'] ? (int) 
$attrib['short_description'] : false,
+                                       'javascript_action'             => 
$this->_db->db_addslashes($attrib['javascript_action']),
                                );
 
                                if($OldGroup != $attrib['group_id'])
@@ -1143,8 +1144,8 @@
                                        'get_list_function_input' => 
$this->_db->f('get_list_function_input') ? 
unserialize($this->_db->f('get_list_function_input', true)) : '',
                                        'get_single_function'           => 
$this->_db->f('get_single_function'),
                                        'get_single_function_input' => 
$this->_db->f('get_single_function_input') ? 
unserialize($this->_db->f('get_single_function_input', true)) : '',
-                                       'short_description'                     
=> $this->_db->f('short_description')
-
+                                       'short_description'                     
=> $this->_db->f('short_description'),
+                                       'javascript_action'                     
=>$this->_db->f('javascript_action',true),
                                );
                        }
 
@@ -1395,6 +1396,7 @@
                                'get_single_function'           
=>$this->_db->f('get_single_function',true),
                                'get_single_function_input' => 
$this->_db->f('get_single_function_input') ? 
unserialize($this->_db->f('get_single_function_input', true)) : '',
                                'short_description'                     => 
$this->_db->f('short_description'),
+                               'javascript_action'                     
=>$this->_db->f('javascript_action'),
                                'column_info'                           => array
                                                                                
        (
                                                                                
                'precision'     => $this->_db->f('precision_'),

Modified: trunk/phpgwapi/setup/setup.inc.php
===================================================================
--- trunk/phpgwapi/setup/setup.inc.php  2014-06-03 09:12:04 UTC (rev 11999)
+++ trunk/phpgwapi/setup/setup.inc.php  2014-06-03 11:20:32 UTC (rev 12000)
@@ -12,7 +12,7 @@
        // Basic information about this app
        $setup_info['phpgwapi']['name']      = 'phpgwapi';
        $setup_info['phpgwapi']['title']     = 'phpgwapi';
-       $setup_info['phpgwapi']['version']   = '0.9.17.544';
+       $setup_info['phpgwapi']['version']   = '0.9.17.545';
        $setup_info['phpgwapi']['versions']['current_header'] = '1.31';
        $setup_info['phpgwapi']['versions']['system'] = '1.0';
        $setup_info['phpgwapi']['enable']    = 3;

Modified: trunk/phpgwapi/setup/tables_current.inc.php
===================================================================
--- trunk/phpgwapi/setup/tables_current.inc.php 2014-06-03 09:12:04 UTC (rev 
11999)
+++ trunk/phpgwapi/setup/tables_current.inc.php 2014-06-03 11:20:32 UTC (rev 
12000)
@@ -598,7 +598,8 @@
                                'get_list_function_input' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
                                'get_single_function' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
                                'get_single_function_input' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
-                               'short_description' => array('type' => 
'int','precision' => 2,'nullable' => true)
+                               'short_description' => array('type' => 
'int','precision' => 2,'nullable' => true),
+                               'javascript_action' => array('type' => 
'text','nullable' => true)
                        ),
                        'pk' => array('location_id', 'id'),
                        'fk' => array(),

Modified: trunk/phpgwapi/setup/tables_update.inc.php
===================================================================
--- trunk/phpgwapi/setup/tables_update.inc.php  2014-06-03 09:12:04 UTC (rev 
11999)
+++ trunk/phpgwapi/setup/tables_update.inc.php  2014-06-03 11:20:32 UTC (rev 
12000)
@@ -3210,3 +3210,25 @@
                }
        }
 
+       $test[] = '0.9.17.544';
+       /**
+       * Add javascript action as option to custom attribute - datatype 'link'
+       *
+       * @return string the new version number
+       */
+       function phpgwapi_upgrade0_9_17_544()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute','javascript_action',
 array(
+                       'type' => 'text',
+                       'nullable' => true
+               ));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['phpgwapi']['currentver'] = 
'0.9.17.545';
+                       return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+               }
+       }
+

Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php   2014-06-03 09:12:04 UTC (rev 
11999)
+++ trunk/property/inc/class.boentity.inc.php   2014-06-03 11:20:32 UTC (rev 
12000)
@@ -402,6 +402,8 @@
                        $category = 
$this->soadmin_entity->read_single_category($this->entity_id,$this->cat_id);
 
                        $attrib_filter = array();
+                       $javascript_action = array();
+                       $location_id = $GLOBALS['phpgw']->locations->get_id( 
$this->type_app[$this->type], 
".{$this->type}.{$this->entity_id}.{$this->cat_id}");
                        if($attrib_data)
                        {
                                foreach ( $attrib_data as $attrib )
@@ -434,6 +436,28 @@
                                                        }
                                                }
                                        }
+
+                                       if($attrib['datatype'] == 'link')
+                                       {
+                                               if($attrib['javascript_action'])
+                                               {
+                                                       
$javascript_action[$attrib['name']] = $attrib['javascript_action'];
+                                                       $js = <<<JS
+
+                                                       
javascript_action_{$attrib['name']} = function(id,location_code)
+                                                       {
+JS;
+                                                               $js .= 
str_replace 
(array('__entity_id__','__cat_id__','__location_id__'),array($this->entity_id,$this->cat_id,$location_id),
 $attrib['javascript_action']);
+
+                                                               $js .= <<<JS
+                                                       }
+JS;
+
+                                                       
$GLOBALS['phpgw']->js->add_code('', $js);
+
+                                               }
+                                       }
+
                                }
                        }
 
@@ -478,7 +502,6 @@
                        $cols_extra             = $this->so->cols_extra;
                        $cols_return_lookup             = 
$this->so->cols_return_lookup;
 
-
                        foreach ($custom_cols as $col_id => $col_info)
                        {
                                if( in_array( $col_id, $user_columns ) )
@@ -531,8 +554,14 @@
                                        }
                                        $entry['org_unit'] = 
$org_units_data[$entry['org_unit_id']]['name'];
                                }
+                               
+                               foreach($javascript_action as $_name => 
$_action)
+                               {
+                                       $entry[$_name] = 
"javascript_action_{$_name}({$entry['id']},{$entry['location_code']})";
+                                       
$this->uicols['javascript_action'][$_name] = true;
+                               }
                        }
-//_debug_array($entity);die();
+
                        return $entity;
                }
 

Modified: trunk/property/inc/class.uiadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.uiadmin_entity.inc.php     2014-06-03 09:12:04 UTC 
(rev 11999)
+++ trunk/property/inc/class.uiadmin_entity.inc.php     2014-06-03 11:20:32 UTC 
(rev 12000)
@@ -2449,6 +2449,7 @@
                                'value_input_text'                              
        => $values['input_text'],
                                'value_statustext'                              
        => $values['statustext'],
                                'datatype_list'                                 
        => $this->bocommon->select_datatype($values['column_info']['type']),
+                               'datatype'                                      
                => $values['column_info']['type'],
                                'attrib_group_list'                             
        => $this->bo->get_attrib_group_list($entity_id,$cat_id, 
$values['group_id']),
                                'value_precision'                               
        => $values['column_info']['precision'],
                                'value_scale'                                   
        => $values['column_info']['scale'],
@@ -2464,7 +2465,8 @@
                                'value_get_list_function_input'         => 
print_r($values['get_list_function_input'],true),
                                'value_get_single_function'                     
=> $values['get_single_function'],
                                'value_get_single_function_input'       => 
print_r($values['get_single_function_input'],true),
-                               'value_short_description'                       
=> $values['short_description']
+                               'value_short_description'                       
=> $values['short_description'],
+                               'value_javascript_action'                       
=> $values['javascript_action']
                        );
 
                        $appname = lang('entity');

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2014-06-03 09:12:04 UTC (rev 
11999)
+++ trunk/property/inc/class.uientity.inc.php   2014-06-03 11:20:32 UTC (rev 
12000)
@@ -1049,6 +1049,14 @@
                                                                        
$datatable['rows']['row'][$j]['column'][$i]['link']                     = 
$entity_entry[$uicols['name'][$i]];
                                                                        
$datatable['rows']['row'][$j]['column'][$i]['target']      = '_blank';
                                                                }
+
+                                                               //override 
action
+                                                               
if(isset($uicols['javascript_action']) && 
isset($uicols['javascript_action'][$uicols['name'][$i]]))
+                                                               {
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['format']                           
= 'javascript_action';          
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['javascript_action']        = 
$entity_entry[$uicols['name'][$i]];
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['value']                            
= $uicols['descr'][$i];
+                                                               }
                                                        }
                                                }
                                                else
@@ -1345,6 +1353,10 @@
                                                {
                                                        
$json_row[$column['name']] = "<a href='".$column['link']."' target='_blank'>" 
.$column['value']."</a>";
                                                }
+                                               else 
if(isset($column['format']) && $column['format']== "javascript_action")
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='#' title='{$column['statustext']}' 
onclick='javascript:{$column['javascript_action']}'>{$column['value']}</a>";
+                                               }
                                                else
                                                {
                                                        
$json_row[$column['name']] = $column['value'];
@@ -1419,6 +1431,10 @@
                        // Prepare YUI Library
                        $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'entity.index', 'property' );
 
+                       $GLOBALS['phpgw']->js->validate_file( 'tinybox2', 
'packed', 'phpgwapi' );
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
+
+
                        //die(_debug_array($datatable));
                }
 




reply via email to

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