mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
duplicates: add ability to select layers
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
7f990bc085
commit
6d0b9d40aa
|
@ -190,3 +190,12 @@ padding: 8px;
|
||||||
.nav-spacer {
|
.nav-spacer {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buttonblock {
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttonblock-btn {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
|
@ -394,24 +394,31 @@ class RecipeSearchView(ListView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class DuplicatesView(TemplateView):
|
class DuplicatesView(TemplateView):
|
||||||
def get_recipes(self):
|
def get_recipes(self, layer_ids):
|
||||||
init_qs = Recipe.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
|
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)
|
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')
|
qs = init_qs.all().filter(pn__in=[item['pn'] for item in dupes]).order_by('pn', 'layerbranch__layer')
|
||||||
return recipes_preferred_count(qs)
|
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'])
|
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)
|
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')
|
qs = init_qs.all().filter(name__in=[item['name'] for item in dupes]).order_by('name', 'layerbranch__layer')
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
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 = super(DuplicatesView, self).get_context_data(**kwargs)
|
||||||
context['recipes'] = self.get_recipes()
|
context['recipes'] = self.get_recipes(layer_ids)
|
||||||
context['classes'] = self.get_classes()
|
context['classes'] = self.get_classes(layer_ids)
|
||||||
context['url_branch'] = self.kwargs['branch']
|
context['url_branch'] = self.kwargs['branch']
|
||||||
context['this_url_name'] = resolve(self.request.path_info).url_name
|
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
|
return context
|
||||||
|
|
||||||
class AdvancedRecipeSearchView(ListView):
|
class AdvancedRecipeSearchView(ListView):
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
layerindex-web - duplicates page template
|
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
|
Licensed under the MIT license, see COPYING.MIT for details
|
||||||
|
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
@ -39,6 +39,47 @@
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</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>
|
</div>
|
||||||
|
|
||||||
<h2>Duplicate recipes</h2>
|
<h2>Duplicate recipes</h2>
|
||||||
|
@ -113,5 +154,18 @@
|
||||||
if( ! firstfield.val() )
|
if( ! firstfield.val() )
|
||||||
firstfield.focus()
|
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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user