noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 91/323: FollowUp : improve esthetic, use inpl


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 91/323: FollowUp : improve esthetic, use inplace_edit for commenting on files
Date: Wed, 14 Mar 2018 17:38:29 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 2efcf8780390861e6fb7a9de28dc5a9ef8a769b0
Author: Dany De Bontridder <address@hidden>
Date:   Thu Jan 25 23:00:13 2018 +0100

    FollowUp : improve esthetic,use inplace_edit for commenting on files
---
 html/ajax_misc.php                 |  4 ++-
 html/js/gestion.js                 | 29 ---------------
 html/style-r692.css                |  3 ++
 include/action.inc.php             |  1 +
 include/ajax/ajax_follow_up.php    | 74 ++++++++++++++++++++++++++++++++++++++
 include/export/export_document.php | 15 --------
 include/template/detail-action.php | 36 +++++++++----------
 7 files changed, 97 insertions(+), 65 deletions(-)

diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 2b6b3be..c4bcbe9 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -221,7 +221,9 @@ $path = array(
     // template category of card
     'template_cat_card'=>'ajax_template_cat_card',
     // Attribute for category of card
-    'template_cat_category'=>'ajax_template_cat_category'
+    'template_cat_category'=>'ajax_template_cat_category',
+    // From FollowUp , update a comment on a file
+    'update_comment_followUp'=>'ajax_follow_up'
 )    ;
 
 if (array_key_exists($op, $path)) {
diff --git a/html/js/gestion.js b/html/js/gestion.js
index 5fba5b9..39a5a4f 100644
--- a/html/js/gestion.js
+++ b/html/js/gestion.js
@@ -51,36 +51,7 @@ function remove_document(p_dossier,p_id)
                );
 
 }
-/**
- address@hidden update the description of an attached document of an action
- address@hidden dossier
- address@hidden dt_id id of the document (pk document:d_id)
-*/
-function update_document(p_dossier,p_id)
-{
-        var queryString={
-            "gDossier":p_dossier,
-            "a":"upd_doc",
-            "d_id":p_id,
-            'act':'RAW:document',
-            'value':$('input_desc_txt'+p_id).value
-        };
-       var action=new Ajax.Request (
-               "export.php",
-               {
-                       method:'get',
-                       parameters:queryString,
-                       onFailure:errorRemoveDoc,
-                       onSuccess:function(req){
-                                $('input_desc'+p_id).hide();
-                                
$('print_desc'+p_id).innerHTML=$('input_desc_txt'+p_id).value+'<a class="line" 
id="desc'+p_id+'" onclick="javascript:show_description('+p_id+')">Modifier</a>';
-                                $('print_desc'+p_id).show();
-                        }
-               }
 
-               );
-    return false;
-}
 
 /**
  address@hidden remove the concerned operation of an action
diff --git a/html/style-r692.css b/html/style-r692.css
index 05e584b..95feecf 100644
--- a/html/style-r692.css
+++ b/html/style-r692.css
@@ -2204,6 +2204,9 @@ div.menu2 td.mtitle a{
 .icon:hover {
     font-family: "fontello";
 }
+*.icon {
+    text-decoration: none;
+}
 /**
  * Icon in the title of Box
  */
diff --git a/include/action.inc.php b/include/action.inc.php
index 73f99c5..5709845 100644
--- a/include/action.inc.php
+++ b/include/action.inc.php
@@ -32,6 +32,7 @@ require_once NOALYSS_INCLUDE.'/lib/icard.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ifile.class.php';
 require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
 require_once NOALYSS_INCLUDE.'/class/follow_up.class.php';
 /*!\brief Show the list of action, this code should be common
  *        to several webpage. But for the moment we keep like that
diff --git a/include/ajax/ajax_follow_up.php b/include/ajax/ajax_follow_up.php
new file mode 100644
index 0000000..bc99e37
--- /dev/null
+++ b/include/ajax/ajax_follow_up.php
@@ -0,0 +1,74 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2018) Author Dany De Bontridder <address@hidden>
+
+if (!defined('ALLOWED'))
+    die('Appel direct ne sont pas permis');
+require_once NOALYSS_INCLUDE."/class/document.class.php";
+require_once NOALYSS_INCLUDE."/lib/inplace_edit.class.php";
+/**
+ * @file
+ * @brief Update description on file
+ */
+$op=$http->request('op');
+global $g_user;
+
+if ($op=='update_comment_followUp')
+{
+    $input=$http->request('input');
+    $action=$http->request('ieaction', 'string', 'display');
+    $d_id=$http->request('d_id', "number");
+
+    // Build inplace input
+    $inplace_description=Inplace_Edit::build($input);
+    $inplace_description->set_callback("ajax_misc.php");
+    $inplace_description->add_json_param("d_id", $d_id);
+    $inplace_description->add_json_param("gDossier", Dossier::id());
+    $inplace_description->add_json_param("op", "update_comment_followUp");
+    switch ($action)
+    {
+        case 'display':
+            echo $inplace_description->ajax_input();
+
+            break;
+        case 'ok':
+            if ($g_user->check_action(VIEWDOC)==1)
+            {
+                $value=$http->request('value');
+                $doc=new Document($cn, $d_id);
+                $doc->get();
+                if ($g_user->can_write_action($doc->ag_id))
+                {
+                    // retrieve the document
+                    $doc->update_description(strip_tags($value));
+                }
+                $inplace_description->set_value($value);
+            }
+            
+            echo $inplace_description->value();
+            break;
+        case 'cancel':
+            echo $inplace_description->value();
+            break;
+        default:
+            throw new Exception(__FILE__.':'.__LINE__.'Invalide value');
+            break;
+    }
+}
\ No newline at end of file
diff --git a/include/export/export_document.php 
b/include/export/export_document.php
index 047edf3..fcc6ecb 100644
--- a/include/export/export_document.php
+++ b/include/export/export_document.php
@@ -63,21 +63,6 @@ if ($action == 'rm')
        header("Content-type: text/html; charset: utf8", true);
        print $json;
 }
-/* update the description of the document */
-if ( $action == "upd_doc") 
-{
-       if ($g_user->check_action(VIEWDOC) == 1)
-       {
-            $d_id=$http->request('d_id',"number");
-
-            $doc = new Document($cn, $d_id);
-            $doc->get();
-            if ( $g_user->can_write_action($doc->ag_id))
-               // retrieve the document
-               $doc->update_description(strip_tags ($value));
-       }
-
-}
 /* remove the operation from action_gestion_operation */
 if ($action == 'rmop')
 {
diff --git a/include/template/detail-action.php 
b/include/template/detail-action.php
index bd31a80..52df9cf 100644
--- a/include/template/detail-action.php
+++ b/include/template/detail-action.php
@@ -419,26 +419,22 @@ for ($i=0;$i<sizeof($aAttachedFile);$i++) :
           </td>
           <td>
         <label> : </label>
-        <span id="print_desc<?php echo $aAttachedFile[$i]['d_id'];?>"> <?php 
echo h($aAttachedFile[$i]['d_description'])?>
-       <?php if ($p_view != 'READ') : ?> 
-        <?php 
-            
$js=sprintf("javascript:show_description('%s')",$aAttachedFile[$i]['d_id']);
+        <?php
+        // Description of the file
+        if ($p_view != 'READ') :
+            $description=new IText("value");
+            $description->id="input_desc_txt".$aAttachedFile[$i]['d_id'];
+            $description->value=h($aAttachedFile[$i]['d_description']);
+            $inplace_description=new Inplace_Edit($description);
+            $inplace_description->set_callback("ajax_misc.php");
+            $inplace_description->add_json_param("d_id", 
$aAttachedFile[$i]['d_id']);
+            $inplace_description->add_json_param("gDossier", Dossier::id());
+            $inplace_description->add_json_param("op", 
"update_comment_followUp");
+            echo $inplace_description->input();
+        else:
+                echo h($aAttachedFile[$i]['d_description']);
+        endif;
         ?>
-        <a class="line"  id="<?php echo 'desc'.$aAttachedFile[$i]['d_id'];?>" 
onclick="<?php echo $js?>"><?php echo _("Modifier")?></a>    
-        
-        </span>
-        </td>
-        <td>
-        <span class="noprint" id="input_desc<?php echo 
$aAttachedFile[$i]['d_id'];?>" style="display:none" >
-              <input type="input" class="input_text" id="input_desc_txt<?php 
echo $aAttachedFile[$i]['d_id'];?>" value="<?php echo 
h($aAttachedFile[$i]['d_description'])?>">
-              <?php 
-              
$js=sprintf("update_document('%s','%s')",dossier::id(),$aAttachedFile[$i]['d_id']);
-              echo HtmlInput::button('save_desc'.$aAttachedFile[$i]['d_id'], 
_('Sauve'), 'onclick="'.$js.'"','smallbutton');
-              ?>
-        </span>
-        <?php else: ?>
-        </span>
-        <?php endif;?>
 <?php $rmDoc=sprintf("return confirm_box(null,'"._('Voulez-vous effacer le 
document')." %s' , function(){remove_document('%s','%s');});",
        $aAttachedFile[$i]['d_filename'],
        dossier::id(),
@@ -446,7 +442,7 @@ for ($i=0;$i<sizeof($aAttachedFile);$i++) :
     ?>
         </td>
         <td>
-  <?php if ($p_view != 'READ') : ?>  <a class="line"  id="<?php echo 
"ac".$aAttachedFile[$i]['d_id'];?>" href="javascript:void(0)" onclick="<?php 
echo $rmDoc;?>"><?php echo _("Effacer")?></a><?php endif;?>
+  <?php if ($p_view != 'READ') : ?>  <span class="icon"  id="<?php echo 
"ac".$aAttachedFile[$i]['d_id'];?>" href="javascript:void(0)" onclick="<?php 
echo $rmDoc;?>">&#xe80f;</span><?php endif;?>
         </td>
   </tr>
   <?php



reply via email to

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