Use input-group for forum topic

This commit is contained in:
rubenwardy 2020-12-09 23:59:31 +00:00
parent 7efdf5cfef
commit e175e489e8
4 changed files with 61 additions and 6 deletions

@ -22,6 +22,10 @@ $(function() {
}
});
$("#forums-button").click(function(e) {
window.open("https://forum.minetest.net/viewtopic.php?t=" + $("#forums").val(), "_blank");
});
let hint = null;
function showHint(ele, text) {
if (hint) {

@ -13,6 +13,53 @@
</div>
{%- endmacro %}
{% macro render_field_prefix(field, label=None, prefix="@", label_visible=true, right_url=None, right_label=None, fieldclass=None) -%}
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
{% endif %}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">{{ prefix }}</span>
</div>
{{ field(class_=fieldclass or 'form-control', **kwargs) }}
</div>
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{%- endmacro %}
{% macro render_field_prefix_button(field, label=None, prefix="@", label_visible=true, right_url=None, right_label=None, fieldclass=None) -%}
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
{% endif %}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">{{ prefix }}</span>
</div>
{{ field(class_=fieldclass or 'form-control', **kwargs) }}
<a class="btn btn-secondary" id="{{ field.name }}-button">
View
</a>
</div>
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{%- endmacro %}
{% macro form_scripts() -%}
<link href="/static/jquery-ui.min.css?v=2" rel="stylesheet" type="text/css">
<script src="/static/jquery-ui.min.js?v=2"></script>

@ -7,7 +7,8 @@
{% endif %}
{% endblock %}
{% from "macros/forms.html" import render_field, render_submit_field, form_scripts, render_multiselect_field, render_mpackage_field, render_deps_field, package_lists %}
{% from "macros/forms.html" import render_field, render_field_prefix_button, render_submit_field, form_scripts,
render_multiselect_field, render_mpackage_field, render_deps_field, package_lists %}
{% block scriptextra %}
{{ form_scripts() }}
@ -16,7 +17,7 @@
<script src="/static/polltask.js"></script>
<script src="/static/package_create.js?v=4"></script>
{% endif %}
<script src="/static/package_edit.js?v=3"></script>
<script src="/static/package_edit.js?v=4"></script>
{% endblock %}
{% block content %}
@ -114,9 +115,12 @@
{{ render_field(form.website, class_="pkg_meta") }}
{{ render_field(form.issueTracker, class_="pkg_meta") }}
{{ render_field(form.forums, class_="pkg_meta", placeholder=_("Tip: paste in a forum topic URL")) }}
{{ render_field_prefix_button(form.forums, class_="pkg_meta",
pattern="[0-9]+",
prefix=_("forum.minetest.net/viewtopic.php?t="),
placeholder=_("Tip: paste in a forum topic URL")) }}
</fieldset>
<div class="pkg_meta">{{ render_submit_field(form.submit) }}</div>
<div class="pkg_meta mt-5">{{ render_submit_field(form.submit) }}</div>
</form>
{% endblock %}

@ -44,14 +44,14 @@
<h3>{{ _("Profile Information") }}</h3>
{% from "macros/forms.html" import render_field, render_submit_field %}
{% from "macros/forms.html" import render_field, render_field_prefix, render_submit_field %}
<form action="" method="POST" class="form" role="form">
{{ form.hidden_tag() }}
{% if user.checkPerm(current_user, "CHANGE_USERNAMES") %}
{{ render_field(form.display_name, tabindex=230) }}
{{ render_field(form.forums_username, tabindex=230) }}
{{ render_field(form.github_username, tabindex=230) }}
{{ render_field_prefix(form.github_username, tabindex=230) }}
{% endif %}
{% if user.checkPerm(current_user, "CHANGE_PROFILE_URLS") %}