From 2efcf8780390861e6fb7a9de28dc5a9ef8a769b0 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 25 Jan 2018 23:00:13 +0100 Subject: [PATCH] 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(-) create mode 100644 include/ajax/ajax_follow_up.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 2b6b3be5e..c4bcbe955 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 5fba5b951..39a5a4f67 100644 --- a/html/js/gestion.js +++ b/html/js/gestion.js @@ -51,36 +51,7 @@ function remove_document(p_dossier,p_id) ); } -/** - *@brief update the description of an attached document of an action - *@param dossier - *@param 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+'Modifier'; - $('print_desc'+p_id).show(); - } - } - ); - return false; -} /** *@brief remove the concerned operation of an action diff --git a/html/style-r692.css b/html/style-r692.css index 05e584ba1..95feecf81 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 73f99c539..57098451f 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 000000000..bc99e3722 --- /dev/null +++ b/include/ajax/ajax_follow_up.php @@ -0,0 +1,74 @@ + + +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 047edf328..fcc6ecbdb 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 bd31a8021..52df9cfeb 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -419,26 +419,22 @@ for ($i=0;$i - - - 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; ?> - - - - - - - - - - " href="javascript:void(0)" onclick=""> + " href="javascript:void(0)" onclick="">