personal_technique/app/views/admin/techniques/_form.html.erb

291 lines
10 KiB
Plaintext

<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/main-form-col2" %>
<style type="text/css">
.ui-helper-hidden-accessible{
display: none;
}
</style>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
<li class="pull-right">
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
</li>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- title -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.title") %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_technique.title"), value: (@technique.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- newsletter -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.newsletter") %></label>
<div class="controls">
<%= f.fields_for :newsletter_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_technique.newsletter"), value: (@technique.newsletter_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- authors -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.authors") %></label>
<div class="controls">
<%= f.fields_for :authors_translations do |f| %>
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_technique.authors"), value: (@technique.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<%
links_hash = {}
[].each do |link|
hash = {}
hash["html"] = add_attribute("form_link", f, link.pluralize.to_sym)
hash["count"] = @technique.send(link.pluralize).count rescue 0
links_hash[link] = hash
%>
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.#{link}") %></label>
<div class="controls">
<!-- Exist -->
<% if !@technique.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @technique.send(link.pluralize).each_with_index do |obj, i| %>
<% if !obj.new_record? %>
<%= f.fields_for link.pluralize.to_sym, obj do |f| %>
<%= render :partial => "form_link", :object => obj, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target" for="<%= link %>">
</div>
<p class="add-btn">
<a class="add_link trigger btn btn-small btn-primary" for="<%= link %>"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<% end %>
<!-- File -->
<%
files_hash = {}
[].each do |file|
hash = {}
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
hash["count"] = @technique.send(file.pluralize).count rescue 0
files_hash[file] = hash
%>
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.#{file}") %></label>
<div class="controls">
<!-- Exist -->
<% if !@technique.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @technique.send(file.pluralize).each_with_index do |obj, i| %>
<% if !obj.new_record? %>
<%= f.fields_for file.pluralize.to_sym, obj do |f| %>
<%= render :partial => "form_file", :object => obj, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target" for="<%= file %>">
</div>
<p class="add-btn">
<a class="add_file trigger btn btn-small btn-primary" for="<%= file %>"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<% end %>
</div>
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.nil? %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_technique.author_name_translation") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% else %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_technique.member_profile") %></label>
<div class="controls">
<% members = !@technique.member_profile.nil? ? @technique.member_profile.to_a : [] %>
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'technique[member_profile_id][]', email_members: members,index:'0',select_name:'member_profile_id'} %>
</div>
</div>
<% end %>
<!-- issue_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.issue_date") %></label>
<div class="controls">
<%= f.datetime_picker "issue_date",:format => "yyyy/MM", :no_label => true, :new_record => @technique.new_record? %>
</div>
</div>
<!-- vol_no -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.vol_no") %></label>
<div class="controls">
<%= f.text_field "vol_no", class: "input-block-level", placeholder: t("personal_technique.vol_no"), value: (@technique.vol_no rescue nil) %>
</div>
</div>
<!-- isbn -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.isbn") %></label>
<div class="controls">
<%= f.text_field "isbn", class: "input-block-level", placeholder: t("personal_technique.isbn"), value: (@technique.isbn rescue nil) %>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.url") %></label>
<div class="controls">
<%= f.text_field "url", class: "input-block-level", placeholder: t("personal_technique.url"), value: (@technique.url rescue nil) %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.keywords") %></label>
<div class="controls">
<%= f.text_field "keywords", class: "input-block-level", placeholder: t("personal_technique.keywords"), value: (@technique.keywords rescue nil) %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.note") %></label>
<div class="controls">
<%= f.text_area "note", class: "input-block-level ckeditor", placeholder: t("personal_technique.note"), value: (@technique.note rescue nil) %>
</div>
</div>
<!-- technique_status -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_technique.technique_status.status") %></label>
<div class="controls">
<%= f.select :technique_status_id, TechniqueStatus.all.collect {|t| [ t.status, t.id ]}, { include_blank: true } %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @technique.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
</div>
<script type="text/javascript">
var files = <%= files_hash.to_json.html_safe %>;
$("a.add_file").on("click",function(){
var type = $(this).attr("for"),
html = files[type].html,
count = parseInt(files[type].count),
replaceReg = new RegExp("new_" + type + "s","g");
html = html.replace(replaceReg,count);
$(".add-target[for=" + type + "]").append(html);
count++;
files[type].count = count;
return false;
})
var links = <%= links_hash.to_json.html_safe %>;
$("a.add_link").on("click",function(){
var type = $(this).attr("for"),
html = links[type].html,
count = parseInt(links[type].count),
replaceReg = new RegExp("new_" + type + "s","g");
html = html.replace(replaceReg,count);
$(".add-target[for=" + type + "]").append(html);
count++;
links[type].count = count;
return false;
})
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
</script>