emailer/app/views/admin/emailers/_form.html.erb

124 lines
5.0 KiB
Plaintext

<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
</ul>
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("emailer.email_to") %></label>
<div class="controls">
<div class="content-box">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_entry[email_member_ids][]', email_members: @email.email_members} %>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label muted"></label>
<div class="controls">
<div class="content-box">
<span class="help-block"><%= "#{t("emailer.other_mailaddress")}(#{t("emailer.other_mailaddress_note")})"%> </span>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
</div>
</div>
</div>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("emailer.email_sentdate") %></label>
<div class="controls">
<%= f.datetime_picker :email_sentdate, :no_label => true, :new_record => @email.new_record?%>
</div>
</div>
</div>
</div>
</div>
<div class="tab-content language-area">
<div class="control-group input-title">
<label class="control-label muted"><%= t("emailer.mail_subject") %></label>
<div class="controls">
<%= f.text_field :mail_subject, class: "input-block-level", placeholder: t("emailer.mail_subject") %>
</div>
</div>
</div>
<div class="control-group input-content">
<label class="control-label muted"><%= t("emailer.mail_content") %></label>
<div class="controls">
<div class="textarea">
<%= f.cktext_area :mail_content, rows: 5, class: "input-block-level" %>
</div>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @email && !@email.email_entry_files.blank? %>
<div class="exist">
<% @email.email_entry_files.each_with_index do |email_file, i| %>
<%= f.fields_for :email_entry_files, email_file do |f| %>
<%= render :partial => 'form_file', :object => email_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'email_entry_file_field_count', @email.email_entry_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%#= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
<%= link_to t('cancel'), admin_emailers_path(:page => params[:page]), :class=>"btn" %>
</div>
<script type="text/javascript">
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_email_entry_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :email_entry_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
});
</script>