stevent Posted February 14, 2017 Share Posted February 14, 2017 Bonjour à tous ! Un de mes clients en PRESTASHOP 1.6.1.7 me donne une mission assez complexe ( à mes yeux en tous cas ). La question est simple, afin de ne pas devoir passer son temps à cocher toutes les catégories ( Il en à 40 000 ), il souhaite pouvoir sélectionner plusieurs catégories d'un coup. Je m'explique : S'il coche une catégorie en niveau 5, il faudrait que les catégories parentes soient AUTOMATIQUEMENT COCHEES. Deuxième chose, éventualité d'ajouter un bouton "Tout cocher" mais pas celui qui est déja existant, un bouton qui permet de ne cocher que le ficher ouvert ! J'ai joins une image pour explication. Quelqu'un pense que ce serait envisageable ?? Merci d'avance ! Link to comment Share on other sites More sharing options...
YopixelAE Posted February 15, 2017 Share Posted February 15, 2017 Bonjour, Vous pouvez intervenir directement sur votre fichier tree.js (admin/themes/default/js/) en éditant la méthode init du prototype du constructeur Tree utilisé sur la page admin products. Votre fichier contiendrait alors ceci : var Tree = function (element, options) { this.$element = $(element); this.options = $.extend({}, $.fn.tree.defaults, options); this.init(); }; Tree.prototype = { constructor: Tree, init: function () { var that = $(this); this.$element.find("label.tree-toggler, .icon-folder-close, .icon-folder-open").click( function () { if ($(this).parent().parent().children("ul.tree").is(":visible")) { $(this).parent().children(".icon-folder-open") .removeClass("icon-folder-open") .addClass("icon-folder-close"); that.trigger('collapse'); } else { $(this).parent().children(".icon-folder-close") .removeClass("icon-folder-close") .addClass("icon-folder-open"); that.trigger('expand'); } $(this).parent().parent().children("ul.tree").toggle(300); } ); this.$element.find("li").click( function () { $('.tree-selected').removeClass("tree-selected"); $('li input:checked').parent().addClass("tree-selected"); } ); this.$element.find("input").click( function () // Select/Unselect all parent main cats { var isChecked = $(this).is(':checked'); if (isChecked) { $(this).parents('.tree-folder').find('input:first').prop('checked', true); } if (!isChecked) { var anItemIsChecked = false; $(this).parents('ul.tree').find('.tree-item input').each(function(i) { var thisChecked = $(this).is(':checked'); if (thisChecked) { anItemIsChecked = true; } }); if (!anItemIsChecked) { // If one item inside ul.tree is checked, do not uncheck... $(this).parents('.tree-folder').find('input:first').prop('checked', false); } // And finally, uncheck direct parent if no sibling item is checked var aSibIsChecked = false; $(this).parents('.tree:first').find('.tree-item input').each(function(i) { var thisChecked = $(this).is(':checked'); if (thisChecked) { aSibIsChecked = true; } }); if (!aSibIsChecked) { $(this).parents('.tree-folder:first').find('input:first').prop('checked', false); } } } ); return $(this); }, collapseAll : function($speed) { this.$element.find("label.tree-toggler").each( function() { $(this).parent().children(".icon-folder-open") .removeClass("icon-folder-open") .addClass("icon-folder-close"); $(this).parent().parent().children("ul.tree").hide($speed); } ); return $(this); }, expandAll : function($speed) { this.$element.find("label.tree-toggler").each( function() { $(this).parent().children(".icon-folder-close") .removeClass("icon-folder-close") .addClass("icon-folder-open"); $(this).parent().parent().children("ul.tree").show($speed); } ); return $(this); }, }; $.fn.tree = function (option, value) { var methodReturn; var $set = this.each( function () { var $this = $(this); var data = $this.data('tree'); var options = typeof option === 'object' && option; if (!data){ $this.data('tree', (data = new Tree(this, options))); } if (typeof option === 'string') { methodReturn = data[option](value); } } ); return (methodReturn === undefined) ? $set : methodReturn; }; $.fn.tree.Constructor = Tree; 1 Link to comment Share on other sites More sharing options...
stevent Posted February 15, 2017 Author Share Posted February 15, 2017 Merci pour la réponse. Par contre, autant le tpl n'à presque plus de secrets pour moi, autant le javascript j'ai encore beaucoup à apprendre. Sauriez vous éventuellement me mettre sur la voie ... ? Merci d'avance. Link to comment Share on other sites More sharing options...
stevent Posted February 15, 2017 Author Share Posted February 15, 2017 Pardon je n'ai pas bien lu votre réponse,elle contient ce qu'il faut merci je test ! Link to comment Share on other sites More sharing options...
Soyons Solidaire Posted February 15, 2017 Share Posted February 15, 2017 Bonjour , Merci pour l'info Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now