Skip to content

Commit

Permalink
Prefill the resource name field with the filename
Browse files Browse the repository at this point in the history
  • Loading branch information
niharika1995 committed Jun 4, 2017
1 parent 99f3054 commit 5cb2677
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cadasta/core/static/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $(function() {
$('a.file-link').attr('download', file.name);
});

var name = file.name.substr(0, file.name.lastIndexOf('.')).replace(/_/, " ");
$('input[name="name"][prefill="true"]').val(name);
$('input[name="original_file"]').val(file.name);
$('input[name="details-original_file"]').val(file.name);

Expand Down
2 changes: 1 addition & 1 deletion cadasta/templates/resources/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<hr class="divider">
<div class="form-group{% if form.name.errors %} has-error{% endif %}">
<label class="control-label" for="{{ form.name.id_for_label }}">{% trans "Name" %}</label>
{% render_field form.name class+="form-control" data-parsley-required="true" %}
{% render_field form.name class+="form-control" data-parsley-required="true" prefill="true" %}
<div class="error-block">{{ form.name.errors }}</div>
</div>
<div class="form-group{% if form.description.errors %} has-error{% endif %}">
Expand Down

0 comments on commit 5cb2677

Please sign in to comment.