From ff510f6989b2273220ad34d35abc891fb4aa458b Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 7 Aug 2024 18:25:43 +0200 Subject: [PATCH] CCARD : remove category card with confirm, remove dead code --- html/js/card.js | 20 ++++++------- include/cfgfiche.inc.php | 50 +------------------------------ include/class/fiche_def.class.php | 7 ++++- 3 files changed, 17 insertions(+), 60 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 37211d80e..a61b4cd29 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -1440,6 +1440,7 @@ var CategoryCardDefinition = function (dossier_id, fiche_def_id) { CategoryCardDefinition.prototype.save = function () { try { + var here = this; var aAttribut=Sortable.serialize(this.existing_list); var queryString = { gDossier: this.dossier_id, @@ -1462,8 +1463,7 @@ CategoryCardDefinition.prototype.save = function () { if ( req.responseText == 'OK') { smoke.signal('Sauvé',function(e){},{duration:500}); } - // if successfull add id on existing_list and remove from available_list - console.debug(here); + } } @@ -1477,10 +1477,10 @@ CategoryCardDefinition.prototype.save = function () { * @param attribut_id {int} attr_def.ad_id , ad_id of attribute */ CategoryCardDefinition.prototype.add_attribut = function (attribut_id) { - var here = this; - console.debug(`add ${attribut_id}`); - try { + + try { + var here = this; var queryString = { gDossier: this.dossier_id, fiche_def_id: this.fiche_def_id, @@ -1501,18 +1501,18 @@ CategoryCardDefinition.prototype.add_attribut = function (attribut_id) { } // if successfull add id on existing_list and remove from available_list - console.debug(here); + // remove from available_list $('avail_attr_' + attribut_id).remove(); - alternate_row_color_list(here.available_list); var parser = new DOMParser(); var element = parser.parseFromString(req.responseText, 'text/html'); - $(here.existing_list).appendChild(element.body.firstChild); + $(here.existing_list).appendChild(element.body.firstChild); new Effect.Highlight('existing_attr_' + attribut_id, { startcolor: '#FAD4D4', endcolor: '#F78082' }); Sortable.create('attribut_card', {tag: 'li'}); + alternate_row_color_list(here.available_list); } } ); @@ -1525,7 +1525,7 @@ CategoryCardDefinition.prototype.add_attribut = function (attribut_id) { * @param attribut_id {int} attr_def.ad_id , ad_id of attribute */ CategoryCardDefinition.prototype.remove_attribut = function (attribut_id) { - console.debug(`remove ${attribut_id}`); + var here = this; try { @@ -1549,7 +1549,7 @@ CategoryCardDefinition.prototype.remove_attribut = function (attribut_id) { } // if successfull add id on existing_list and remove from available_list - console.debug(here); + // remove from available_list $('existing_attr_' + attribut_id).remove(); var parser = new DOMParser(); diff --git a/include/cfgfiche.inc.php b/include/cfgfiche.inc.php index da3468b4f..ddbd84f8f 100644 --- a/include/cfgfiche.inc.php +++ b/include/cfgfiche.inc.php @@ -28,43 +28,6 @@ global $http; $retour=HtmlInput::button_anchor("Retour à la liste", HtmlInput::get_to_string(array("gDossier","ac"))); $action=$http->post('action',"string", ''); /*******************************************************************************************/ -// Add an attribut -/*******************************************************************************************/ -if ( $action == 'add_line') -{ - $fd_id=$http->request("fd_id","number"); - $ad_id=$http->request("ad_id","number"); - $fiche_def=new Fiche_Def($cn,$fd_id); - $fiche_def->InsertAttribut($ad_id); - echo $fiche_def->input_detail(); - echo $retour; - return; -} -/*******************************************************************************************/ -// Remove an attribut -/*******************************************************************************************/ -if ( $action == 'remove_line' ) -{ - $fd_id=$http->request("fd_id","number"); - $fiche_def=new Fiche_Def($cn,$fd_id); - try - { - $ck_remove=$http->request('chk_remove'); - $fiche_def->RemoveAttribut($ck_remove); - } - catch (Exception $exc) - { - throw new Exception(_("Vous devez choisir au moins une ligne")); - } - finally - { - echo $fiche_def->input_detail(); - echo $retour; - return; - } - -} -/*******************************************************************************************/ // Try to remove a category /*******************************************************************************************/ if ( $action == 'remove_cat' ) @@ -107,18 +70,7 @@ if ( isset ($_POST['change_name'])) echo $retour; return; } -/*******************************************************************************************/ -// Save order of the attributes -/*******************************************************************************************/ -if ( $action == 'save_line' ) -{ - $fd_id=$http->request("fd_id","number"); - $fiche_def=new Fiche_Def($cn,$fd_id); - $fiche_def->save_order($_POST); - echo $fiche_def->input_detail(); - echo $retour; - return; -} + /*******************************************************************************************/ // Save a new category of card /*******************************************************************************************/ diff --git a/include/class/fiche_def.class.php b/include/class/fiche_def.class.php index 864b02af5..965f9159d 100644 --- a/include/class/fiche_def.class.php +++ b/include/class/fiche_def.class.php @@ -770,13 +770,18 @@ $order $fd_description->heigh=4; $fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"'; $fd_description->value=$this->fd_description; - $r.='
'; + $r.=''; $r.=\HtmlInput::hidden('fd_id',$this->id); ob_start(); require_once NOALYSS_TEMPLATE.'/fiche_def_input.php'; $r.=ob_get_contents(); ob_clean(); $r.=HtmlInput::submit('change_name', _('Sauver')); + $r.='
'; + $r.='
'; + $r.=HtmlInput::hidden("action", "remove_cat"); + $r.=HtmlInput::hidden('fd_id',$this->id); + $r.=HtmlInput::submit('remove_cat', _('Effacer')); $r.='
'; require NOALYSS_TEMPLATE.'/fiche_def-input_detail.php';