diff --git a/layerindex/static/css/additional.css b/layerindex/static/css/additional.css index 1608bab..0703257 100644 --- a/layerindex/static/css/additional.css +++ b/layerindex/static/css/additional.css @@ -189,4 +189,13 @@ padding: 8px; .nav-spacer { margin-left: 10px; +} + +.buttonblock { + margin-top: 10px; + margin-right: 10px; +} + +.buttonblock-btn { + margin-left: 8px; } \ No newline at end of file diff --git a/layerindex/views.py b/layerindex/views.py index ac77c52..0db1e7c 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -394,24 +394,31 @@ class RecipeSearchView(ListView): return context class DuplicatesView(TemplateView): - def get_recipes(self): + def get_recipes(self, layer_ids): init_qs = Recipe.objects.filter(layerbranch__branch__name=self.kwargs['branch']) + if layer_ids: + init_qs = init_qs.filter(layerbranch__layer__in=layer_ids) dupes = init_qs.values('pn').annotate(Count('layerbranch', distinct=True)).filter(layerbranch__count__gt=1) qs = init_qs.all().filter(pn__in=[item['pn'] for item in dupes]).order_by('pn', 'layerbranch__layer') return recipes_preferred_count(qs) - def get_classes(self): + def get_classes(self, layer_ids): init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch']) + if layer_ids: + init_qs = init_qs.filter(layerbranch__layer__in=layer_ids) dupes = init_qs.values('name').annotate(Count('layerbranch', distinct=True)).filter(layerbranch__count__gt=1) qs = init_qs.all().filter(name__in=[item['name'] for item in dupes]).order_by('name', 'layerbranch__layer') return qs def get_context_data(self, **kwargs): + layer_ids = [int(i) for i in self.request.GET.getlist('l')] context = super(DuplicatesView, self).get_context_data(**kwargs) - context['recipes'] = self.get_recipes() - context['classes'] = self.get_classes() + context['recipes'] = self.get_recipes(layer_ids) + context['classes'] = self.get_classes(layer_ids) context['url_branch'] = self.kwargs['branch'] context['this_url_name'] = resolve(self.request.path_info).url_name + context['layers'] = LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status='P').order_by( 'layer__name') + context['showlayers'] = layer_ids return context class AdvancedRecipeSearchView(ListView): diff --git a/templates/layerindex/duplicates.html b/templates/layerindex/duplicates.html index 2347253..116aab9 100644 --- a/templates/layerindex/duplicates.html +++ b/templates/layerindex/duplicates.html @@ -6,7 +6,7 @@ layerindex-web - duplicates page template - Copyright (C) 2013 Intel Corporation + Copyright (C) 2013-2014 Intel Corporation Licensed under the MIT license, see COPYING.MIT for details {% endcomment %} @@ -39,6 +39,47 @@ {% endfor %} + + + + Filter layers {% if showlayers %}{{ showlayers|length }}{% endif %} +

Duplicate recipes

@@ -113,5 +154,18 @@ if( ! firstfield.val() ) firstfield.focus() }); + $('#id_select_all').click(function (e) { + $('.filterlayercheckbox').attr('checked', true); + }); + $('#id_select_none').click(function (e) { + $('.filterlayercheckbox').attr('checked', false); + }); + $('#id_cancel').click(function (e) { + $('.filterlayercheckbox').attr('checked', false); + showlayers = {{ showlayers }} + for(i in showlayers) { + $('#id_layer_' + showlayers[i]).attr('checked', true); + } + }); {% endblock %}