gallery/app/views/admin/galleries/import.html.erb

36 lines
1.5 KiB
Plaintext
Raw Normal View History

2016-12-20 11:43:54 +00:00
<% content_for :page_specific_javascript do %>
<script type="text/javascript" src="/assets/validator.js"></script>
<% end %>
<form action="<%= importimages_admin_gallery_path(@album.id) %>" method="post" class="form-horizontal main-forms" id="import-images-xls" enctype="multipart/form-data">
<h3 style="padding-left: 30px;">Import from Excel for album <i><%= @album.name %></i></h3>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="input-area">
<div class="control-group">
<div class="controls">
<a href="<%= excel_format_admin_gallery_path(@album.id,:format => "xlsx") %>">Download example sheet here.</a>
</div>
</div>
<div class="control-group">
<label for="import-images" class="control-label muted">Upload :</label>
<div class="controls">
<input type="file" id="import-images" name="import_file" data-fv-validation="required;mustbexls;" data-fv-messages="Cannot be empty; Must be an excel file.;" />
<span class="help-block"> Only excel file is allowed. Max 200 entries.</span>
</div>
</div>
</div>
<div class="form-actions">
<input type="submit" value="Import" class="btn btn-primary">
</div>
</form>
<script type="text/javascript">
var form = new FormValidator($("#import-images-xls"));
form.validate_functions.mustbexls = function(val){
var t = val.split("."),
ext = t[t.length - 1];
return (ext == "xls" || ext == "xlsx")
}
2017-04-17 12:38:08 +00:00
<% if params[:error] == "1" %>
alert("More than 200 rows present.");
<% end %>
2016-12-20 11:43:54 +00:00
</script>