fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10492] logistic: fix link to make favorites, alter p


From: Sigurd Nes
Subject: [Fmsystem-commits] [10492] logistic: fix link to make favorites, alter parent - and validate project chosen
Date: Wed, 07 Nov 2012 20:05:17 +0000

Revision: 10492
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10492
Author:   sigurdne
Date:     2012-11-07 20:05:16 +0000 (Wed, 07 Nov 2012)
Log Message:
-----------
logistic: fix link to make favorites, alter parent - and validate project chosen

Modified Paths:
--------------
    trunk/logistic/inc/class.soactivity.inc.php
    trunk/logistic/inc/class.uiactivity.inc.php
    trunk/logistic/inc/model/class.activity.inc.php
    trunk/logistic/js/logistic/activity.js
    trunk/logistic/templates/base/activity/add_activity_item.xsl

Modified: trunk/logistic/inc/class.soactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.soactivity.inc.php 2012-11-07 11:23:54 UTC (rev 
10491)
+++ trunk/logistic/inc/class.soactivity.inc.php 2012-11-07 20:05:16 UTC (rev 
10492)
@@ -399,8 +399,13 @@
                 * @return array of children
                 */
 
-               protected function get_children($parent, $level)
+               public function get_children($parent, $level, $reset = false)
                {
+                       if($reset)
+                       {
+                               $this->activity_tree = array();
+                       }
+
                        $db = clone($this->db);
                        $table = "lg_activity";
                        $sql = "SELECT id, name FROM {$table} WHERE 
parent_activity_id = {$parent} ORDER BY name ASC";

Modified: trunk/logistic/inc/class.uiactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.uiactivity.inc.php 2012-11-07 11:23:54 UTC (rev 
10491)
+++ trunk/logistic/inc/class.uiactivity.inc.php 2012-11-07 20:05:16 UTC (rev 
10492)
@@ -118,6 +118,10 @@
                                        'field' => array(
                                                array(
                                                        'key' => 'id',
+                                                       'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 'id_link',
                                                        'label' => lang('Id'),
                                                        'sortable' => true,
                                                        'formatter' => 
'YAHOO.portico.formatLink'
@@ -166,12 +170,25 @@
                                        (
                                                array
                                                (
-                                                       'name'          => 
'activity_id',
+                                                       'name'          => 'id',
                                                        'source'        => 'id'
                                                ),
                                        )
                                );
 
+                       $parameters2 = array
+                               (
+                                       'parameter' => array
+                                       (
+                                               array
+                                               (
+                                                       'name'          => 
'parent_id',
+                                                       'source'        => 'id'
+                                               ),
+                                       )
+                               );
+
+
                        $data['datatable']['actions'][] = array
                                        (
                                                'my_name'               => 
'new',
@@ -180,7 +197,7 @@
                                                (
                                                        'menuaction'    => 
'logistic.uiactivity.edit'
                                                )),
-                                               'parameters'    => 
json_encode($parameters)
+                                               'parameters'    => 
json_encode($parameters2)
                                        );
 
                        $data['datatable']['actions'][] = array
@@ -335,7 +352,7 @@
                                        
                                        
                                        $href = self::link(array('menuaction' 
=> 'logistic.uiactivity.view', 'id' => $activity_arr['id']));
-                                       $activity_arr['id'] = "<a 
href=\"{$href}\">" . $activity_arr['id'] . "</a>";
+                                       $activity_arr['id_link'] = "<a 
href=\"{$href}\">" . $activity_arr['id'] . "</a>";
                                        $activity_arr['name'] = "<a 
href=\"{$href}\">" . $activity_arr['name'] . "</a>";
                                        
                                        
@@ -356,12 +373,15 @@
 
                        if (!$export)
                        {
+
                                //Add action column to each row in result table
+/*
                                array_walk(
                                                                
$result_data['results'],
                                                                array($this, 
'_add_links'),
                                                                
"logistic.uiactivity.view"
                                );
+*/
                        }
 
                        return $this->yui_results($result_data);
@@ -407,12 +427,32 @@
                        
                        $accounts = 
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_READ, 'run', 'logistic');
                        
-                 $activities = $this->so->get();
-                       
+                       $activities = $this->so->get();
+
+                       if($activity_id)
+                       {
+                               $exclude = array($activity_id);
+                               $children = 
$this->so->get_children($activity_id, 0,true);
+
+                               foreach($children as $child)
+                               {
+                                       $exclude[] = $child['id']; 
+                               }
+
+                               $k = count($activities);
+                               for ($i=0; $i<$k; $i++)
+                               {
+                                       if 
(in_array($activities[$i]->get_id(),$exclude))
+                                       {
+                                               unset($activities[$i]);
+                                       }
+                               }
+                       }
+
                        $data = array
                        (
                                'responsible_users' => $accounts,
-                               'activities' => $activities,
+                               'activities' => $activity_id ? $activities : 
array(),
                                'activity' => $activity,
                                'editable' => true,
                                'breadcrumb' => $this->_get_breadcrumb( 
$activity_id, 'logistic.uiactivity.edit', 'id')
@@ -423,7 +463,8 @@
                                $data['project'] = $project;
                        }
                        
-                       if($activity->get_parent_id() > 0)
+//                     if($activity->get_parent_id() > 0)
+                       if(     $activity_id )
                        {
                                $parent_activity = $this->so->get_single( 
$activity->get_parent_id() );
                                $data['parent_activity'] = $parent_activity;
@@ -441,6 +482,10 @@
                        $GLOBALS['phpgw']->jqcal->add_listener('end_date', 
'datetime');
                        
                        self::add_javascript('logistic', 'logistic', 
'activity.js');
+                       self::add_javascript('phpgwapi', 'yui3', 
'yui/yui-min.js');
+                       self::add_javascript('phpgwapi', 'yui3', 
'gallery-formvalidator/gallery-formvalidator-min.js');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yui3/gallery-formvalidator/validatorCss.css');
+
                        self::render_template_xsl('activity/add_activity_item', 
$data);
                }
                
@@ -489,9 +534,9 @@
                        {
                                $activity = new logistic_activity();
                        }
-                       
+
                        $activity->populate();
-                       
+
                        if( $activity->validate() )
                        {
                                $activity_id = $this->so->store($activity);
@@ -505,7 +550,7 @@
 
                public function edit_favorite()
                {
-                       if($activity_id = phpgw::get_var('activity_id'))
+                       if($activity_id = phpgw::get_var('id'))
                        {
                                $activity = $this->so->get_single($activity_id);
 

Modified: trunk/logistic/inc/model/class.activity.inc.php
===================================================================
--- trunk/logistic/inc/model/class.activity.inc.php     2012-11-07 11:23:54 UTC 
(rev 10491)
+++ trunk/logistic/inc/model/class.activity.inc.php     2012-11-07 20:05:16 UTC 
(rev 10492)
@@ -246,13 +246,21 @@
                
                public function populate()
                {
-                       $this->set_id( phpgw::get_var('id') );
+                       $this->set_id( phpgw::get_var('id', 'int') );
                        $this->set_name( phpgw::get_var('name') );
-                       $this->set_responsible_user_id( 
phpgw::get_var('responsible_user_id') );
+                       $this->set_responsible_user_id( 
phpgw::get_var('responsible_user_id', 'int') );
                        $this->set_description( phpgw::get_var('description') );
-                       $this->set_parent_id( phpgw::get_var('parent_id') );
-                       $this->set_project_id( phpgw::get_var('project_id') );
                        
+                       if( $parent_id = phpgw::get_var('parent_activity_id', 
'int') )
+                       {
+                               $this->set_parent_id( $parent_id );
+                       }
+                       else
+                       {
+                               $this->set_parent_id( 
phpgw::get_var('parent_id', 'int') );                     
+                       }
+                       $this->set_project_id( phpgw::get_var('project_id', 
'int') );
+                       
                        $user_id = $GLOBALS['phpgw_info']['user']['id'];
                        $this->set_update_user( $user_id );
                                                        

Modified: trunk/logistic/js/logistic/activity.js
===================================================================
--- trunk/logistic/js/logistic/activity.js      2012-11-07 11:23:54 UTC (rev 
10491)
+++ trunk/logistic/js/logistic/activity.js      2012-11-07 20:05:16 UTC (rev 
10492)
@@ -40,4 +40,42 @@
                var wrpElem = $(this).parents("dd");
                $(wrpElem).find(".help_text").fadeOut();
        });
-});
\ No newline at end of file
+});
+
+
+var arURLParts = strBaseURL.split('?');
+var comboBase = arURLParts[0] + 'phpgwapi/inc/yui-combo-master/combo.php?';
+
+YUI_config = {
+    //Don't combine the files
+    combine: true,
+    //Ignore things that are already loaded (in this process)
+    ignoreRegistered: false,
+    //Set the base path
+       comboBase: comboBase,
+    base: '',
+    //And the root
+    root: '',
+    //Require your deps
+    require: [ ]
+};
+
+
+YUI({
+}).use(
+       'gallery-formvalidator', 
+               function(Y) {   
+                Y.on("domready", function () {
+                   var form = new Y.Validator(
+                        {
+                            form:'activity_form',
+                            defaultIncorrectIndicatorCss:'validator',
+                            defaultCorrectIndicatorCss:'indicator',
+                            createCorrectIndicator:true,
+                            createIncorrectIndicator:true
+                        }
+                    );
+
+                });
+
+});

Modified: trunk/logistic/templates/base/activity/add_activity_item.xsl
===================================================================
--- trunk/logistic/templates/base/activity/add_activity_item.xsl        
2012-11-07 11:23:54 UTC (rev 10491)
+++ trunk/logistic/templates/base/activity/add_activity_item.xsl        
2012-11-07 20:05:16 UTC (rev 10492)
@@ -1,4 +1,4 @@
-<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+<xsl:template match="data" xmlns:php="http://php.net/xsl"; 
xmlns:formvalidator="http://www.w3.org/TR/html4/";>
 <xsl:variable name="date_format"><xsl:value-of 
select="php:function('get_phpgw_info', 
'user|preferences|common|dateformat')"/></xsl:variable>
 <xsl:variable name="datetime_format"><xsl:value-of 
select="$date_format"/><xsl:text> H:i</xsl:text></xsl:variable>
 
@@ -29,25 +29,27 @@
                        <xsl:variable name="action_url">
                                <xsl:value-of 
select="php:function('get_phpgw_link', '/index.php', 
'menuaction:logistic.uiactivity.save')" />
                        </xsl:variable>
-                       <form action="{$action_url}" method="post">
+                       <xsl:variable name="parent_id"><xsl:value-of 
select="parent_activity/id"/></xsl:variable>
+                       <form id='activity_form' action="{$action_url}" 
method="post">
                                <input type="hidden" name="id" value = 
"{activity/id}" />
                                <input type="hidden" name="project_id" 
value="{activity/project_id}" />
                                <input type="hidden" name="parent_id" 
value="{parent_activity/id}" />
                                
                                <dl class="proplist-col">
+                               <xsl:value-of select="parent_activity/id"/>
                                  <xsl:choose>
-                                               <xsl:when test="(editable) and 
(parent_activity/id &gt; 0)">
+                                               <xsl:when test="(editable) and 
(activities !='')">
                                                        <dt>            
                                                                        <div 
style="margin-bottom: 1em;">
                                                                                
<label style="display:block;"><xsl:value-of select="php:function('lang', 
'Choose another main activity for this sub activity')" /></label>
                                                                                
<select id="select_parent_activity" name="parent_activity_id">
-                                                                               
        <option>Velg annen hovedaktivitet</option>
+                                                                               
        <option value="">Velg annen hovedaktivitet</option>
                                                                                
        <xsl:for-each select="activities">
                                                                        <option 
value="{id}">
-                                                                               
<xsl:if test="activity/parent_id = id">
+                                                                               
<xsl:if test="id = $parent_id">
                                                                                
        <xsl:attribute name="selected">
-                                                                               
                        selected
-                                                                               
                        </xsl:attribute>
+                                                                               
                <xsl:text>selected</xsl:text>
+                                                                               
                </xsl:attribute>
                                                                                
</xsl:if>
                                                                        
<xsl:value-of disable-output-escaping="yes" select="name"/>
                                                                        
</option>
@@ -56,7 +58,7 @@
                                                                        </div>
                                                                </dt>
                                                  </xsl:when>
-                                                 <xsl:when test="(editable) 
and not(parent_activity) and not(project)">
+                                                <!-- <xsl:when 
test="(editable) and not(parent_activity) and not(project)">
                                                        <dt>            
                                                                        <div 
style="margin-bottom: 1em;">
                                                                                
<label style="display:block;"><xsl:value-of select="php:function('lang', 
'Choose the project in which the activity is part of')" /></label>
@@ -75,13 +77,15 @@
                                                                                
</select>                                       
                                                                        </div>
                                                                </dt>
-                                                 </xsl:when>
+                                                 </xsl:when>-->
                                                  <xsl:otherwise>
                                                        <dt>            
                                                                        <div 
style="margin-bottom: 1em;">
                                                                                
<label style="display:block;"><xsl:value-of select="php:function('lang', 
'Choose another project for the activity')" /></label>
-                                                                               
<select id="select_project" name="select_project">
-                                                                               
        <option><xsl:value-of select="php:function('lang', 'Choose another 
project')" /></option>
+                                                                               
<select id="select_project" name="select_project"
+                                                                               
                formvalidator:FormField="yes"
+                                                                               
                formvalidator:Type="SelectField">
+                                                                               
        <option value=''><xsl:value-of select="php:function('lang', 'Choose 
another project')" /></option>
                                                                                
        <xsl:for-each select="projects">
                                                                        <option 
value="{id}">
                                                                                
<xsl:if test="project/id = project_id">
@@ -223,7 +227,7 @@
                                                        <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
                                                        <xsl:variable 
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')" 
/></xsl:variable>
                                                        <input type="submit" 
name="save_activity" value="{$lang_save}" title = "{$lang_save}" />
-                                                       <input type="submit" 
name="cancel_activity" value="{$lang_cancel}" title = "{$lang_cancel}" />
+                                                       <input class="submit" 
type="button" name="cancel_activity" id ='cancel_activity' 
value="{$lang_cancel}" title = "{$lang_cancel}" 
onClick="document.cancel_form.submit();"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                        <xsl:variable 
name="params">
@@ -241,6 +245,15 @@
                </div>
        </div>
 </div>
+
+<xsl:variable name="cancel_url">
+<xsl:value-of select="php:function('get_phpgw_link', '/index.php', 
'menuaction:logistic.uiactivity.index')" />
+</xsl:variable>
+
+<form name="cancel_form" id="cancel_form" action="{$cancel_url}" method="post">
+</form>
+
+
 </xsl:template>
 
 <xsl:template match="options">




reply via email to

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