Hide create release fields depending on radio buttons

This commit is contained in:
rubenwardy 2019-01-28 23:16:51 +00:00
parent 034315d421
commit f822027ec5
3 changed files with 16 additions and 2 deletions

View File

@ -17,7 +17,7 @@
{{ render_field(form.vcsLabel, class_="mt-3") }}
{% endif %}
{{ render_field(form.fileUpload, fieldclass="form-control-file") }}
{{ render_field(form.fileUpload, fieldclass="form-control-file", class_="mt-3") }}
<div class="row">
{{ render_field(form.min_rel, class_="col-sm-6") }}
@ -41,4 +41,17 @@
{% block scriptextra %}
<script src="/static/release_minmax.js?v=1"></script>
<script>
function check_opt() {
if ($("input[name=uploadOpt]:checked").val() == "vcs") {
$("#fileUpload").parent().hide();
$("#vcsLabel").parent().show();
} else {
$("#fileUpload").parent().show();
$("#vcsLabel").parent().hide();
}
}
$("input[name=uploadOpt]").change(check_opt);
check_opt();
</script>
{% endblock %}

View File

@ -240,6 +240,7 @@
<div class="float-right">
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a href="{{ package.getBulkReleaseURL() }}">bulk</a>
|
<a href="{{ package.getCreateReleaseURL() }}">+</a>
{% endif %}
</div>

View File

@ -43,7 +43,7 @@ def get_mt_releases(is_max):
class CreatePackageReleaseForm(FlaskForm):
title = StringField("Title", [InputRequired(), Length(1, 30)])
uploadOpt = RadioField ("Method", choices=[("upload", "File Upload")], default="upload")
vcsLabel = StringField("VCS Commit or Branch", default="master")
vcsLabel = StringField("VCS Commit Hash, Branch, or Tag", default="master")
fileUpload = FileField("File Upload")
min_rel = QuerySelectField("Minimum Minetest Version", [InputRequired()],
query_factory=lambda: get_mt_releases(False), get_pk=lambda a: a.id, get_label=lambda a: a.name)