Commit 33dd0d34 authored by felix.herrmann's avatar felix.herrmann
Browse files

feat(maxlength): add max_length check and feedback to tag input controls, fixes #55

parent 453ac0d7
......@@ -158,7 +158,7 @@ $(document).on('beforeSend.ic', function (event, el, data) {
* if remaining number falls under threshold
*/
$(document).on('keyup','.textarea, .textinput', function() {
$(document).on('keyup','.textarea, .textinput, .tag-input', function() {
// get maxlength attribute
var maxLength = $(this).attr( "maxlength" );
// set threshold to 10% of maxLength for large lengths or to maxLength for small
......
......@@ -38,6 +38,15 @@ body {
font-size: smaller;
}
.chars-left-tags {
color: theme-color("hint");
padding-top: .3rem;
padding-bottom: .3rem;
font-size: smaller;
text-align: right;
width: 84%;
}
.list-group-item {
user-select: none;
}
......
......@@ -4,13 +4,15 @@
<div id="{{ object }}-tag-control">
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
<div class="input-group input-group-tags smallskip" id="{{ object }}-tags">
<input id="{{ object }}-tag" class="form-control typeahead tag-input" type="text" autocomplete="off" name="{{ object }}-tag" placeholder="Begin typing to add {{ object }} tags here..." />
<div class="input-group-append">
<button class="input-group-text" ic-include="#{{ object }}-tag" ic-post-to="{% url 'dddatasets:prep_dataset_tag_add' ds.uuid object %}" ic-target="#{{ object }}-tag-control" type="button">{% trans "Save" %}</button>
</div>
<div class="input-group input-group-tags" id="{{ object }}-tags">
<input id="{{ object }}-tag" class="form-control typeahead tag-input" maxlength="100" type="text" autocomplete="off" name="{{ object }}-tag" placeholder="Begin typing to add {{ object }} tags here..." />
<div class="input-group-append">
<button class="input-group-text" ic-include="#{{ object }}-tag" ic-post-to="{% url 'dddatasets:prep_dataset_tag_add' ds.uuid object %}" ic-target="#{{ object }}-tag-control" type="button">{% trans "Save" %}</button>
</div>
</div>
</form>
<div class="chars-left-tags" id="{{ object }}-tag_chars_left"></div>
<div id="{{ object }}-tags-list" class="btngroup-toolbar smallskip">
{% for tag in tags %}
<input type="hidden" id="{{ object }}-tag-{{ tag.id }}-remove" name="{{ object }}-tag-remove" value="{{ tag.id }}" />
......
......@@ -5,13 +5,15 @@
<div id="{{ object }}-tag-control">
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
<div class="input-group input-group-tags smallskip" id="user-keyword-tags">
<input id="{{ ca.input_id }}" class="form-control typeahead tag-input" type="text" name="{{ ca.input_id}}" placeholder="{% trans "Begin Typing To add" %} {{ ca.text }} {% trans "here" %}..." ic-src="{% url ca.url_objects_all %}" ic-trigger-delay="500ms" ic-indicator="#{{ ca.div_id }}-indicator" autocomplete="off">
<div class="input-group-append">
<button class="input-group-text" ic-include="#{{ ca.input_id }}" ic-post-to="{% url ca.url_object_add %}" ic-target="#{{ ca.div_id }}" type="button">{% trans "Save" %}</button>
</div>
</div><!-- /input-group -->
<div class="input-group input-group-tags" id="user-keyword-tags">
<input id="{{ ca.input_id }}" class="form-control typeahead tag-input" maxlength="100" type="text" name="{{ ca.input_id}}" placeholder="{% trans "Begin Typing To add" %} {{ ca.text }} {% trans "here" %}..." ic-src="{% url ca.url_objects_all %}" ic-trigger-delay="500ms" ic-indicator="#{{ ca.div_id }}-indicator" autocomplete="off">
<div class="input-group-append">
<button class="input-group-text" ic-include="#{{ ca.input_id }}" ic-post-to="{% url ca.url_object_add %}" ic-target="#{{ ca.div_id }}" type="button">{% trans "Save" %}</button>
</div>
</div><!-- /input-group -->
</form>
<div class="chars-left-tags" id="{{ ca.input_id }}_chars_left"></div>
<div id="{{ ca.div_id }}" class="btngroup-toolbar smallskip">
{% for tag in user.get_interests %}
<input id="tag-keyword-{{ tag.id}}" type="hidden" name="tag-keyword" value="{{ tag.id }}"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment