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

33 lines
1.4 KiB
Plaintext

<% 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")
}
</script>