From 9c32183747b89c97a48a1f1da41c9307592a2f2e Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Tue, 28 Jun 2016 16:54:32 +0200 Subject: [PATCH] PHRAS-726_delete-candidate - remove : prod / replace candidate is removed from menu - fix : thesaurus / delete candidate is ok #time 1h --- .../Thesaurus/ThesaurusXmlHttpController.php | 2 - templates/web/prod/thesaurus.js.twig | 149 +----------------- templates/web/thesaurus/thesaurus.html.twig | 7 +- 3 files changed, 2 insertions(+), 156 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusXmlHttpController.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusXmlHttpController.php index 77e642b603..0bfa6e912e 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusXmlHttpController.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/ThesaurusXmlHttpController.php @@ -1346,8 +1346,6 @@ class ThesaurusXmlHttpController extends Controller } } - $ret['msg'] = $this->app->trans('prod::thesaurusTab:dlg:%number% record(s) updated', ['%number%' => 0]); - return $this->app->json($ret); } diff --git a/templates/web/prod/thesaurus.js.twig b/templates/web/prod/thesaurus.js.twig index fcd5174af7..24322b7b39 100644 --- a/templates/web/prod/thesaurus.js.twig +++ b/templates/web/prod/thesaurus.js.twig @@ -56,9 +56,6 @@ function T_Gfilter(o) break; case "wiz_1": // accept break; - case "wiz_2": // replace - T_replaceBy2(f); - break; default: break; } @@ -75,50 +72,11 @@ function T_Gfilter_delayed(f, delay) case "wiz_1": // accept T_filter_delayed2(f, delay, "CANDIDATE"); break; - case "wiz_2": // replace - T_filter_delayed2(f, delay, "CANDIDATE"); - break; default: break; } } - -function T_replaceBy2(f) -{ - if(trees.C._selInfos.n != 1) - return; - var msg; - var term = trees.C._selInfos.sel.eq(0).find("span span").html(); - - var cid = trees.C._selInfos.sel[0].getAttribute('id').split('.'); - cid.shift(); - var sbas = cid.shift(); - cid = cid.join('.'); - - trees.C._toReplace = { 'sbas':sbas, 'cid':cid, 'replaceby':f }; - - {% set message %} - {{ 'prod::thesaurusTab:dlg:Remplacement du candidat "%(from)s" par "%(to)s"' | trans }} - {% endset %} - - var msg = $.sprintf("{{ message | e('js') }}", {'from':term, 'to':f}); - - var confirmBox = p4.Dialog.Create({ - size : 'Alert', - closeOnEscape : true, - cancelButton: true, - buttons: { - "Ok" : function() { - confirmBox.Close(); - T_replaceCandidates_OK(); - } - } - }); - confirmBox.setContent(msg); -} - - function T_filter_delayed2(f, delay, mode) { if(this.timer) @@ -221,59 +179,6 @@ function T_filter_delayed2(f, delay, mode) // ====================================================================================================== -function T_replaceCandidates_OK() -{ - {% set replaceing_msg %} - {{ 'prod::thesaurusTab:dlg:Remplacement en cours.' | trans }} - {% endset %} - - var replacingBox = p4.Dialog.Create({ - size : 'Alert' - }); - replacingBox.setContent("{{ replaceing_msg | e('js') }}"); - - var parms = { - url: "/xmlhttp/replacecandidate.j.php", - data: { - "id[]" : trees.C._toReplace.sbas + "." + trees.C._toReplace.cid - , "t" : trees.C._toReplace.replaceby - , "debug" : '0' - }, - async: false, - cache: false, - dataType: "json", - timeout: 10*60*1000, // 10 minutes ! - success: function(result, textStatus) - { - trees.C._toReplace = null; - thesauShowWizard("wiz_0", false); - - replacingBox.Close(); - - if(result.msg != '') - { - var alert = p4.Dialog.Create({ - size : 'Alert', - closeOnEscape : true, - closeButton:true - }); - alert.setContent(result.msg); - } - - for(i in result.ctermsDeleted) - { - var cid = "#CX_P\\." + result.ctermsDeleted[i].replace(new RegExp("\\.", "g"), "\\."); // escape les '.' pour jquery - $(cid).remove(); - } - - }, - _ret: null // private alchemy - }; - - $.ajax( parms ); -} - - function T_acceptCandidates_OK() { {% set accepting_msg %} @@ -515,36 +420,6 @@ function C_MenuOption(menuItem, menu, option, parm) break; - case 'REPLACE': - // display helpful message into the thesaurus box... - var msg; - - {% set messageOne %} - {{ "prod::thesaurusTab:dlg:remplacer le terme \"%s\" des fiches par :" | trans }} - {% endset %} - {% set messageMany %} - {{ "prod::thesaurusTab:dlg:remplacer les %d termes des fiches par :" | trans }} - {% endset %} - - if(trees.C._selInfos.n == 1) - { - var term = trees.C._selInfos.sel.eq(0).find("span span").html(); - msg = $.sprintf('{{ messageOne | e('js') }}', term); - } - else - { - msg = $.sprintf('{{ messageMany | e('js') }}', trees.C._selInfos.n); - } - - p4.thesau.tabs.tabs('option', 'active', 0); - - // set the content of the wizard - $("#THPD_WIZARDS .wiz_2 .txt").html(msg); - // ... and switch to the thesaurus tab - thesauShowWizard("wiz_2", true); - - break; - case 'DELETE': $("#THPD_WIZARDS DIV", p4.thesau.tabs).hide(); // display helpful message into the thesaurus box... @@ -1182,7 +1057,6 @@ function startThesaurus(){ 'C':{ 'tree' : $("#THPD_C_tree", p4.thesau.tabs) , '_toAccept' : null // may contain : {'type', 'dst', 'lng'} - , '_toReplace' : null // , '_selInfos' : null // may contain : {'sel':lisel, 'field':field, 'sbas':sbas, 'n':lisel.length} } }; @@ -1286,17 +1160,9 @@ function startThesaurus(){ } , {% endfor %} - { - label:'{{ 'prod::thesaurusTab:cmenu:Remplacer par...' | trans }}', -// disabled:true, - onclick:function(menuItem, menu) - { - C_MenuOption(menuItem, menu, 'REPLACE', null); - } - }, { label:'{{ 'boutton::supprimer' | trans }}', -// disabled:true, + // disabled:true, onclick:function(menuItem, menu) { C_MenuOption(menuItem, menu, 'DELETE', null); @@ -1308,7 +1174,6 @@ function startThesaurus(){ beforeShow:function() { var ret = false; - var replaceBy_option = {{ thesau_languages|length }}; var x = this._showEvent.srcElement ? this._showEvent.srcElement : this._showEvent.target; var li = $(x).closest("li"); @@ -1340,24 +1205,12 @@ function startThesaurus(){ // glue selection info to the tree trees.C._selInfos = {'sel':lisel, 'field':field, 'sbas':sbas, 'n':lisel.length} ; - - if(lisel.length == 1) - { - // $(this.menu).find('.context-menu-item').eq(replaceBy_option).removeClass('context-menu-item-disabled'); - } - else - { - // $(this.menu).find('.context-menu-item').eq(replaceBy_option).addClass('context-menu-item-disabled'); - } } else { trees.C._selInfos = null; } - // replace with is not possible (for now) with es - $(this.menu).find('.context-menu-item').eq(replaceBy_option).addClass('context-menu-item-disabled'); - ret = true; } return(ret); diff --git a/templates/web/thesaurus/thesaurus.html.twig b/templates/web/thesaurus/thesaurus.html.twig index 86e073d882..ef921be0cc 100644 --- a/templates/web/thesaurus/thesaurus.html.twig +++ b/templates/web/thesaurus/thesaurus.html.twig @@ -460,13 +460,8 @@ // alert(url); ret = loadXMLDoc(url, null, true); - // alert(ret); - allhits = ret.getElementsByTagName("allhits").item(0).firstChild.nodeValue; - if(allhits==0) - msg = "{{ 'thesaurus:: Supprimer cette branche ? (les termes concernes remonteront en candidats a la prochaine indexation)' | trans }}"; - else - msg = "{{ 'thesaurus:: Des reponses sont retournees par cette branche. Supprimer quand meme ? (les termes concernes remonteront en candidats a la prochaine indexation)' | trans }}"; + msg = "{{ 'thesaurus:: Supprimer cette branche ? (les termes concernes remonteront en candidats a la prochaine indexation)' | trans }}"; if(confirm(msg)) {