layerindex-web/templates/layerindex/comparisonrecipeselect.html
Paul Eggleton 606e14e412 comparison: use style on hidden select instead of CSS class to hide
This isn't a visual thing, this select element must remain hidden, so it
seems a bit more appropriate to me to specify the style directly on the
element rather than using a CSS class to do it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2018-09-26 16:03:52 +12:00

126 lines
7.7 KiB
HTML

{% extends "layerindex/classicrecipes.html" %}
{% load i18n %}
{% comment %}
layerindex-web - comparison recipe selection page template
Copyright (C) 2018 Intel Corporation
Licensed under the MIT license, see COPYING.MIT for details
{% endcomment %}
<!--
{% block title_append %} - comparison - select match for {{ select_for.name }}{% endblock %}
-->
{% block navbar %}
{% endblock %}
{% block page_heading %}
<h2>Select match for {{ select_for.pn }} in {% if branch.comparison %}{{ branch }}{% else %}OpenEmbedded{% endif %}</h2>
<div class="pull-right">
<a href="#selectRecipeDialog" role="button" data-toggle="modal" class="select_recipe_button btn {% if recipe.id == existing_cover_recipe.id %}btn-primary{% else %}btn-default{% endif %}">No match</a>
<a href="{% url 'comparison_recipe' select_for.id %}" class="btn btn-default">Cancel</a>
</div>
<form id="comparison_form" class="form-inline" method="post">
<div id="selectRecipeDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="selectRecipeDialogLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h3 id="selectRecipeDialogLabel">Select <span id="id_span_select_recipe">recipe</span> to match {{ select_for.pn }}</h3>
</div>
<div class="modal-body">
{% csrf_token %}
{% for hidden in comparison_form.hidden_fields %}
{{ hidden }}
{% endfor %}
<select style="display: none;" id="id_hidden_selectbox">
</select>
<label for="id_selectrecipedialog-cover_status">Coverage</label> {{ comparison_form.cover_status }}
{% if comparison_form.cover_verified %}
<div class="checkbox">
<label id="id_label_cover_verified">
{{ comparison_form.cover_verified }} verified
</label>
</div>
{% endif %}
{% if comparison_form.classic_category %}
<p>
<label for="id_selectrecipedialog-classic_category">Category</label>
{{ comparison_form.classic_category }}
</p>
{% endif %}
<p>
<label for="id_selectrecipedialog-cover_comment">Comment</label>
{{ comparison_form.cover_comment }}
</p>
{% if comparison_form.needs_attention %}
<p>
<div class="checkbox">
<label id="id_label_needs_attention">
{{ comparison_form.needs_attention }} Needs attention
</label>
</div>
</p>
{% endif %}
</div>
<div class="modal-footer">
<button class="btn btn-primary" id="id_selectrecipedialog_save" data-dismiss="modal">Save</button>
<button class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form>
{% endblock %}
{% block table_head_extra %}<th></th>{% endblock %}
{% block table_row_extra %}<td><a href="#selectRecipeDialog" role="button" data-toggle="modal" class="select_recipe_button btn {% if recipe.id == existing_cover_recipe.id %}btn-primary{% else %}btn-default{% endif %}" recipe-pn="{{ recipe.pn }}" recipe-layerbranch="{{ recipe.layerbranch.id }}">Select</a></td>{% endblock %}
{% block no_comparison_recipe_url %}{% url 'comparison_select_detail' select_for.id recipe.id %}{% endblock %}
{% block export_button %}
{% endblock %}
{% block scripts_extra %}
$('.select_recipe_button').click(function (e) {
pn = $(this).attr('recipe-pn');
// FIXME this does tend to cause items to re-sort
$('#id_selectrecipedialog-cover_status').append($('#id_hidden_selectbox').children());
if( !pn ) {
$('#id_hidden_selectbox').append($('#id_selectrecipedialog-cover_status option[value="D"]'));
$('#id_hidden_selectbox').append($('#id_selectrecipedialog-cover_status option[value="E"]'));
}
else {
$('#id_hidden_selectbox').append($('#id_selectrecipedialog-cover_status option[value="N"]'));
$('#id_hidden_selectbox').append($('#id_selectrecipedialog-cover_status option[value="S"]'));
$('#id_hidden_selectbox').append($('#id_selectrecipedialog-cover_status option[value="U"]'));
}
$('#id_span_select_recipe').text(pn);
$('#id_selectrecipedialog-cover_pn').val(pn);
$('#id_selectrecipedialog-cover_layerbranch').val($(this).attr('recipe-layerbranch'));
if( pn ) {
{% if existing_cover_recipe %}
$('#id_selectrecipedialog-cover_status').val('{{ select_for.cover_status }}');
{% else %}
$('#id_selectrecipedialog-cover_status').val('D');
{% endif %}
}
else {
$('#id_selectrecipedialog-cover_status').val('N');
}
});
$('#id_selectrecipedialog_save').click(function (e) {
$('#comparison_form').submit()
$('#selectRecipeDialog').modal('hide')
});
{% endblock %}