diff options
-rw-r--r-- | layerindex/static/css/additional.css | 9 | ||||
-rw-r--r-- | layerindex/views.py | 15 | ||||
-rw-r--r-- | templates/layerindex/duplicates.html | 56 |
3 files changed, 75 insertions, 5 deletions
diff --git a/layerindex/static/css/additional.css b/layerindex/static/css/additional.css index 1608bab5be..07032571b0 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 ac77c52ed0..0db1e7cfaf 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 23472537e2..116aab9df6 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 @@ </a></li> {% endfor %} </ul> + + <div id="layerDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="layerDialogLabel" aria-hidden="true"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h3 id="layerDialogLabel">Select layers to include</h3> + </div> + <form action="" method="get"> + <div class="modal-body"> + <div class="scrolling"> + <table><tbody> + {% for layerbranch in layers %} + <tr> + <td class="checkboxtd"><input + type="checkbox" + class="filterlayercheckbox" + name="l" + value="{{ layerbranch.layer.id }}" id="id_layer_{{layerbranch.layer.id}}" + {% if showlayers and layerbranch.layer.id in showlayers %} + checked + {% endif %} + /> + </td> + <td><label for="id_layer_{{layerbranch.layer.id}}">{{ layerbranch.layer.name }}</label></td> + </tr> + {% endfor %} + </tbody></table> + </div> + <div class="buttonblock"> + <button type="button" class="btn" id="id_select_all">Select all</button> + <button type="button" class="btn buttonblock-btn" id="id_select_none">Select none</button> + </div> + </div> + <div class="modal-footer"> + <input type="submit" value="Filter" class='btn btn-primary' /> + <button class="btn" id="id_cancel" data-dismiss="modal" aria-hidden="true">Cancel</button> + </div> + </form> + </div> + + <a href="#layerDialog" role="button" class="btn nav-spacer" data-toggle="modal">Filter layers {% if showlayers %}<span class="badge badge-success">{{ showlayers|length }}</span>{% endif %}</a> + </div> <h2>Duplicate recipes</h2> @@ -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); + } + }); </script> {% endblock %} |