custom_gallery/app/views/admin/custom_galleries/import.html.erb

36 lines
1.5 KiB
Plaintext

<% content_for :page_specific_javascript do %>
<script type="text/javascript" src="/assets/validator.js"></script>
<% end %>
<form action="<%= importimages_admin_custom_gallery_path(@custom_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 custom_album <i><%= @custom_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_custom_gallery_path(@custom_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")
}
<% if params[:error] == "1" %>
alert("More than 200 rows present.");
<% end %>
</script>