From 656ab45372893f6274326f86839caefdd0b4e882 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 10 Nov 2020 13:54:43 +0100 Subject: [PATCH] Tag : add color to tags --- html/js/scripts.js | 15 +++++ html/style-classic.css | 86 +++++++++++++++++++++++++++ html/style-classic7.css | 86 +++++++++++++++++++++++++++ html/style-light.css | 87 ++++++++++++++++++++++++++++ include/ajax/ajax_tag_add_action.php | 2 +- include/ajax/ajax_tag_detail.php | 20 ++++--- include/class/follow_up.class.php | 21 +++++-- include/class/tag.class.php | 19 +++++- include/database/tag_sql.class.php | 2 + include/template/tag_detail.php | 26 ++++++++- include/template/tag_list.php | 2 +- include/template/tag_select.php | 2 +- 12 files changed, 350 insertions(+), 18 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 25307b890..69c611627 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -3804,3 +3804,18 @@ function json_concat(p_json1,p_json2) return result; } +/** + * this function unchecks other checkbox , it mimics the way a radio behaves + * @param string p_click is the DOM id of the checkbox you clicked + * @param string p_name is the name of all the checkbox to uncheck + */ +function uncheck_other(p_click,p_name) +{ + var aCheckbox=document.getElementsByName(p_name); + if (aCheckbox.length == 0) return; + var i=0; + for (i=0;irequest("isgroup") == 't') { $fl->tag_add($http->request('t_id',"number")); } else { // Add all the tag from the group - $aTag=$cn->get_array("select t_id,t_tag from jnt_tag_group_tag jtgt join tags on (tag_id=t_id) where tag_group_id=$1 order by 2 ",[$http->request("t_id","number")]); + $aTag=$cn->get_array("select t_id,t_tag ,t_color from jnt_tag_group_tag jtgt join tags on (tag_id=t_id) where tag_group_id=$1 order by 2 ",[$http->request("t_id","number")]); $nb_atag=count($aTag); if ( $nb_atag > 0) { for ($i=0;$i<$nb_atag;$i++){ diff --git a/include/ajax/ajax_tag_detail.php b/include/ajax/ajax_tag_detail.php index 20043000b..5e12c7bb0 100644 --- a/include/ajax/ajax_tag_detail.php +++ b/include/ajax/ajax_tag_detail.php @@ -12,9 +12,10 @@ require_once NOALYSS_INCLUDE.'/class/tag.class.php'; ob_start(); $tag=new Tag($cn); $http=new HttpInput(); -$tag->data->t_id=$http->get("tag","number"); -if ($tag->data->t_id == -1 && $g_user->check_action(TAGADD) == 0 ) return; -$tag->data->load(); +$data=$tag->get_data(); +$data->t_id=$http->get("tag","number"); +if ($data->t_id == -1 && $g_user->check_action(TAGADD) == 0 ) return; +$data->load(); echo HtmlInput::title_box(_("Détail du dossier ou étiquette"), "tag_div","close","","y"); ?> @@ -32,9 +33,10 @@ else : data; + echo HtmlInput::hidden('t_id', $http->get('tag') ); + echo HtmlInput::hidden('ac',$http->get('ac')); + + require_once NOALYSS_TEMPLATE.'/tag_detail.php'; echo HtmlInput::submit("save_tag_sb", "Valider"); echo HtmlInput::button_close("tag_div"); @@ -43,8 +45,12 @@ else : diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 380743a15..e674ee1f1 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -663,7 +663,8 @@ class Follow_Up ag_title,dt_value,ag_ref, ag_priority,ag_state, coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest, (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name, - array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags + array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags, + array_to_string((select array_agg(t1.t_color) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags_color from action_gestion as ag join document_type on (ag_type=dt_id) join document_state on (ag_state=s_id) @@ -769,7 +770,19 @@ class Follow_Up $r.=''.$href. h($row['ag_title']).""; $r.="".$row['s_value'].""; - $r.="".$href."".h($row['tags']).''.''.""; + $r.=""; + if ($row['tags']!=""){ + $r.=$href; + $aColor=explode(",", $row["tags_color"]); + $aTags=explode(",", $row["tags"]); + $nb_tag=count($aTags); + for ( $x=0;$x<$nb_tag;$x++) { + $r.=sprintf('%s',$aColor[$x],$aTags[$x]); + $r.=" "; + } // end loop $x + $r.=''; + } + $r.=""; $r.="".$href.h($row['dest']).''.""; @@ -1488,7 +1501,7 @@ class Follow_Up { if ($this->ag_id==0) return; - $sql='select b.ag_id,b.t_id,b.at_id,a.t_tag' + $sql='select b.ag_id,b.t_id,b.at_id,a.t_tag,a.t_color' .' from ' .' tags as a join action_tags as b on (a.t_id=b.t_id)' .' where ag_id=$1 ' @@ -1537,7 +1550,7 @@ class Follow_Up $c=count($a_tag); for ($e=0; $e<$c; $e++) { - echo ''; + echo ''; echo $a_tag[$e]['t_tag']; if ($g_user->can_write_action($this->ag_id)==true && $p_view != 'READ') { diff --git a/include/class/tag.class.php b/include/class/tag.class.php index 2f3b0a1c0..aacd77728 100644 --- a/include/class/tag.class.php +++ b/include/class/tag.class.php @@ -21,12 +21,24 @@ require_once NOALYSS_INCLUDE.'/database/tag_sql.class.php'; class Tag { + private $data; //cn=$p_cn; $this->data=new Tag_SQL($p_cn,$id); } - /** + public function get_data() + { + return $this->data; + } + + public function set_data($data) + { + $this->data=$data; + return $this; + } + + /** * Show the list of available tag * @return HTML */ @@ -42,11 +54,11 @@ class Tag function select() { $ret=$this->data->seek("where t_actif='Y' order by t_tag"); - $ret=$this->cn->exec_sql(" select t_id,t_tag,t_description,'t' as tag_type + $ret=$this->cn->exec_sql(" select t_id,t_tag,t_description,'t' as tag_type ,t_color from tags where t_actif='Y' union all - select tg_id,tg_name ,'G','g' from tag_group order by 2"); + select tg_id,tg_name ,'G','g' ,1 from tag_group order by 2"); require_once NOALYSS_TEMPLATE.'/tag_select.php'; } /** @@ -73,6 +85,7 @@ class Tag $this->data->t_tag= strip_tags($p_array['t_tag']); $this->data->t_description=strip_tags($p_array['t_description']); $this->data->t_actif=$p_array['t_actif']; + $this->data->t_color=$p_array['tagcell_color']; $this->data->save(); } function remove($p_array) diff --git a/include/database/tag_sql.class.php b/include/database/tag_sql.class.php index 13698f156..9876b9c47 100644 --- a/include/database/tag_sql.class.php +++ b/include/database/tag_sql.class.php @@ -37,12 +37,14 @@ class Tag_SQL extends Noalyss_SQL , "t_tag" => "t_tag" , "t_description" => "t_description" ,'t_actif'=>'t_actif' + ,'t_color'=>'t_color' ); $this->type = array( "t_id" => "numeric" , "t_tag" => "text" , "t_description" => "text" ,'t_actif'=>"text" + ,'t_color'=>"numeric" ); $this->default = array( "t_id" => "auto", diff --git a/include/template/tag_detail.php b/include/template/tag_detail.php index d2be03ef5..a2a9847ac 100644 --- a/include/template/tag_detail.php +++ b/include/template/tag_detail.php @@ -16,6 +16,8 @@ $t_actif->value=[ ['label'=>_('Non actif'),'value'=>'N'] ]; $t_actif->selected=$data->t_actif; +$icheckbox=new ICheckBox("tagcell_color"); +$icheckbox->javascript='onclick="uncheck_other(this,\'tagcell_color\');"'; ?>

: input(); ?> @@ -24,7 +26,29 @@ $t_actif->selected=$data->t_actif; : input(); ?>

- input()?> + +

+t_id == '-1') $data->t_color=1; +$nb_color=20; + +for ($i=1 ; $i != $nb_color+1 ; $i++ ) { +?> + "> + + value=$i; + if ( $data->t_color==$i) { $icheckbox->set_check($i);} else {$icheckbox->selected=false;} + echo $icheckbox->input(); + ?> + + ';?> + + +

+ input()?>

request('ac'); $row=Database::fetch_array($ret, $i); ?> - + - +