This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  4dcafc051ae64e3bf93dc83c038473025003c3d5 (commit)
       via  27ab3c3ac3d4958190bfcfadd7f141de33078908 (commit)
      from  2564a188ec1a95755ac09743a8f28725eb2581e0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=4dcafc051ae64e3bf93dc83c038473025003c3d5

commit 4dcafc051ae64e3bf93dc83c038473025003c3d5
Merge: 2564a18 27ab3c3
Author: Franck Villaume <[email protected]>
Date:   Fri Mar 24 15:03:37 2017 +0000

    Merge remote-tracking branch 'bredt/master'


https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=27ab3c3ac3d4958190bfcfadd7f141de33078908

commit 27ab3c3ac3d4958190bfcfadd7f141de33078908
Author: Stéphane-Eymeric Bredthauer <[email protected]>
Date:   Thu Mar 23 22:14:35 2017 +0100

    Tracker: Effort Unit Set, autoconvert value

diff --git a/src/common/tracker/EffortUnitSet.class.php 
b/src/common/tracker/EffortUnitSet.class.php
index 599a908..b85bbb0 100644
--- a/src/common/tracker/EffortUnitSet.class.php
+++ b/src/common/tracker/EffortUnitSet.class.php
@@ -116,10 +116,11 @@ class EffortUnitSet extends FFError {
        /**
         * create - Create new Effort Unit Set in the database.
         *
+        * @param       boolean $is_autoconvert         set if unit is auto 
convert
         * @param       array   $importData                     For import
         * @return      bool    success or not
         */
-       function create($importData = array()) {
+       function create($is_autoconvert = 0, $importData = array()) {
                if(array_key_exists('user', $importData)){
                        $user = $importData['user'];
                } else {
@@ -143,8 +144,8 @@ class EffortUnitSet extends FFError {
                                        $this->setError(sprintf(_('Effort Unit 
Set already exist for tracker %s'),$this->ArtifactType->getName()));
                                        return false;
                                }
-                               $query ='INSERT INTO effort_unit_set(level, 
group_id, group_artifact_id, created_date, created_by) VALUES($1, $2, $3, $4, 
$5)';
-                               $params = array(EFFORTUNITSET_TRACKER_LEVEL, 
$this->Group->getID(), $this->ArtifactType->getID(), $time, $user);
+                               $query ='INSERT INTO effort_unit_set(level, 
group_id, group_artifact_id, created_date, created_by, is_autoconvert) 
VALUES($1, $2, $3, $4, $5, $6)';
+                               $params = array(EFFORTUNITSET_TRACKER_LEVEL, 
$this->Group->getID(), $this->ArtifactType->getID(), $time, $user, 
$is_autoconvert);
                                break;
                        case EFFORTUNITSET_PROJECT_LEVEL:
                                $res = db_query_params('SELECT 1 FROM 
effort_unit_set WHERE group_id=$1 AND group_artifact_id IS NULL AND level=$2',
@@ -157,8 +158,8 @@ class EffortUnitSet extends FFError {
                                        $this->setError(sprintf(_('Effort Unit 
Set already exist for project %s'),$this->Group->getPublicName()));
                                        return false;
                                }
-                               $query ='INSERT INTO effort_unit_set(level, 
group_id, created_date, created_by) VALUES($1, $2, $3, $4)';
-                               $params = array(EFFORTUNITSET_PROJECT_LEVEL, 
$this->Group->getID(), $time, $user);
+                               $query ='INSERT INTO effort_unit_set(level, 
group_id, created_date, created_by, is_autoconvert) VALUES($1, $2, $3, $4, $5)';
+                               $params = array(EFFORTUNITSET_PROJECT_LEVEL, 
$this->Group->getID(), $time, $user, $is_autoconvert);
                                break;
                        case EFFORTUNITSET_FORGE_LEVEL:
                        default:
@@ -384,6 +385,32 @@ class EffortUnitSet extends FFError {
                }
                return true;
        }
+
+       /**
+        * isAutoconvert - test if for this unit set, value will be convert on 
an unit change.
+        *
+        * @return      boolean true/false.
+        */
+       function isAutoconvert(){
+               return ($this->data_array['is_autoconvert']?true:false);
+       }
+
+       /**
+        * update - update Effort Unit Set in the database.
+        *
+        * @param       boolean $is_autoconvert         set if unit is auto 
convert
+        * @return      boolean true/false.
+        */
+       function update($is_autoconvert){
+               $res = db_query_params ('UPDATE effort_unit_set SET 
is_autoconvert=$1 WHERE unit_set_id=$2',
+                               array (($is_autoconvert?1:0), $this->getID())) ;
+               if (!$res) {
+                       $this->setError(_('Error updating Effort Unit 
Set')._(': ').db_error());
+                       return false;
+               }
+               $this->fetchData($this->getID());
+               return true;
+       }
 }
 
 /**
diff --git a/src/common/tracker/actions/effort_units.php 
b/src/common/tracker/actions/effort_units.php
index 75002e5..f05839f 100644
--- a/src/common/tracker/actions/effort_units.php
+++ b/src/common/tracker/actions/effort_units.php
@@ -129,6 +129,9 @@ switch (getStringFromRequest('function','')) {
                postcopy_set($effortUnitSet);
                show_units($effortUnitSet);
                break;
+       case 'update_set':
+               update_set($effortUnitSet);
+               show_units($effortUnitSet);
        default:
                show_units($effortUnitSet);
 }
@@ -158,6 +161,7 @@ function show_units(&$effortUnitSet){
                        break;
                case EFFORTUNITSET_PROJECT_LEVEL:
                        echo html_e('h2', array(), _('Effort Unit Set'));
+                       echo html_ao('p');
                        echo sprintf(_('The Project “%s” is 
using'),$effortUnitSet->getGroup()->getPublicName()).' ';
                        $AvailableEffortUnitSets = 
getAvailableEffortUnitSets($effortUnitSet->getGroup());
                        switch ($effortUnitSet->getLevel()) {
@@ -171,9 +175,11 @@ function show_units(&$effortUnitSet){
                                                $isEditable = true;
                                        break;
                        }
+                       echo html_ao('p');
                        break;
                case EFFORTUNITSET_TRACKER_LEVEL:
                        echo html_e('h2', array(), _('Effort Unit Set'));
+                       echo html_ao('p');
                        echo sprintf(_('The Tracker “%s” is 
using'),$effortUnitSet->getArtifactType()->getName()).' ';
                        $AvailableEffortUnitSets = 
getAvailableEffortUnitSets($effortUnitSet->getArtifactType());
                        switch ($effortUnitSet->getLevel()) {
@@ -192,6 +198,7 @@ function show_units(&$effortUnitSet){
                                        $isEditable = true;
                                        break;
                        }
+                       echo html_ao('p');
                        break;
        }
 
@@ -209,6 +216,22 @@ function show_units(&$effortUnitSet){
                echo html_e('input',array('type'=>'submit', 
'value'=>_('Copy')));
                echo html_ac(html_ap() - 1);
                echo $HTML->closeForm();
+       } else {
+               echo $HTML->openForm(array('action' => $currentURL, 'method' => 
'get'));
+               echo $inputParameters;
+               echo html_ao('p');
+               if ($effortUnitSet->isAutoconvert()) {
+                       echo html_e('input', array('type'=>'checkbox', 
'name'=>'is_autoconvert', 'checked'=>'checked'));
+               } else {
+                       echo html_e('input', array('type'=>'checkbox', 
'name'=>'is_autoconvert'));
+               }
+               echo html_e('label', array('for'=>'is_autoconvert'),_('Enable 
auto convert effort value'));
+               echo html_ac(html_ap() - 1);
+               echo html_ao('p');
+               echo html_e('input', array('type'=>'hidden', 
'name'=>'function', 'value'=>'update_set'));
+               echo html_e('input', array('type'=>'submit', 
'value'=>_('Update')));
+               echo html_ac(html_ap() - 1);
+               echo $HTML->closeForm();
        }
 
        echo html_e('h2', array(), _('Effort Units list'));
@@ -524,6 +547,22 @@ function postcopy_set(&$effortUnitSet) {
        return true;
 }
 
+function update_set(&$effortUnitSet) {
+       global $HTML;
+       $isAutoconvert = (getStringFromRequest('is_autoconvert')=='on'?1:0);
+       var_dump($isAutoconvert);
+       if (!$effortUnitSet->update($isAutoconvert)) {
+               echo $HTML->error_msg(_('Error updating Effort Unit 
Set')._(':').' '.$effortUnitSet->getErrorMessage());
+               return false;
+       }
+       if ($effortUnitSet->isError()) {
+               echo $HTML->error_msg($effortUnitSet->getErrorMessage());
+               return false;
+       }
+       echo $HTML->feedback(sprintf(_('Effort Unit Set successfully 
updated.')));
+       return true;
+}
+
 function inputParameters($effortUnitSet){
        $return = '';
        switch ($effortUnitSet->getObjectLevel()) {
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php 
b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 35ed7af..ec7bbf3 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -1362,6 +1362,38 @@ class ArtifactTypeHtml extends ArtifactType {
        var invalidInputMsg = '". _("This choice is not allowed")."';
        var groupId =".$this->Group->getID().";
        var atId = ".$this->getID().";";
+
+               $effortUnitSet = New EffortUnitSet($this, 
$this->getEffortUnitSet());
+               if ($effortUnitSet->isAutoconvert()) {
+                       $jseffort = <<<'EOS'
+       $("select.effort").on('change', function(){
+               var effortid = $(this).data("effortid");
+               var value = 
parseInt(parseInt($("input[name='extra_fields["+effortid+"]']").val())/$("select[name='unit["+effortid+"]']
 option:selected").data('factor'));
+               $("input[name='value["+effortid+"]']").val(value);
+               
$("input[name='extra_fields["+effortid+"]']").val(value*$("select[name='unit["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+       });
+       $("input.effort").on('change', function(){
+               var effortid = $(this).data("effortid");
+               var value = $("input[name='value["+effortid+"]']").val();
+               
$("input[name='extra_fields["+effortid+"]']").val(value*$("select[name='unit["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+       });
+       $(".effort-range").on('change', function(){
+               var effortid = $(this).data("effortid");
+               
$("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+'
 
'+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_to["+effortid+"]']").val());
+       });
+EOS;
+               } else {
+               $jseffort = <<<'EOS'
+       $(".effort").on('change', function(){
+               var effortid = $(this).data("effortid");
+               
$("input[name='extra_fields["+effortid+"]']").val($("input[name='value["+effortid+"]']").val()*$("select[name='unit["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+       });
+       $(".effort-range").on('change', function(){
+               var effortid = $(this).data("effortid");
+               
$("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+'
 
'+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_to["+effortid+"]']").val());
+       });
+EOS;
+               }
                $javascript = <<<'EOS'
        function showMessage( msg_text, msg_class) {
                $("div#maindiv h1").append($("<p>", { "class": msg_class 
}).html( msg_text )).show();
@@ -1372,14 +1404,6 @@ class ArtifactTypeHtml extends ArtifactType {
                }
                return false;
        };
-       $(".effort").on('change', function(){
-               var effortid = $(this).data("effortid");
-               
$("input[name='extra_fields["+effortid+"]']").val($("input[name='value["+effortid+"]']").val()*$("select[name='unit["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
-       });
-       $(".effort-range").on('change', function(){
-               var effortid = $(this).data("effortid");
-               
$("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+'
 
'+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]']
 
option:selected").data('factor')+'U'+$("select[name='unit_to["+effortid+"]']").val());
-       });
        $("input[type='radio'].readonly, 
input[type='checkbox'].readonly").on('click', function(){
                return false;
        }).on('keydown', function(event){
@@ -1540,7 +1564,7 @@ class ArtifactTypeHtml extends ArtifactType {
                });
        });
 EOS;
-               return html_e('script', array('type'=>'text/javascript'), 
'//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$javascript.'});'."\n".'//]]>');
+               return html_e('script', array('type'=>'text/javascript'), 
'//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$jseffort."\n".$javascript.'});'."\n".'//]]>');
        }
 
 }
diff --git a/src/db/20170320-effortunit-is_autoconvert.sql 
b/src/db/20170320-effortunit-is_autoconvert.sql
new file mode 100644
index 0000000..a12e3d2
--- /dev/null
+++ b/src/db/20170320-effortunit-is_autoconvert.sql
@@ -0,0 +1,2 @@
+ALTER TABLE effort_unit_set
+   ADD is_autoconvert integer NOT NULL DEFAULT 0;
\ No newline at end of file

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/EffortUnitSet.class.php         | 37 ++++++++++++++++---
 src/common/tracker/actions/effort_units.php        | 39 ++++++++++++++++++++
 .../tracker/include/ArtifactTypeHtml.class.php     | 42 +++++++++++++++++-----
 src/db/20170320-effortunit-is_autoconvert.sql      |  2 ++
 4 files changed, 106 insertions(+), 14 deletions(-)
 create mode 100644 src/db/20170320-effortunit-is_autoconvert.sql


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to