universal_table/app/views/admin/universal_tables/_text_field.html.erb

46 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

2015-11-13 13:10:00 +00:00
<div class="control-group">
<%= f.label :text, column.title, :class => "control-label" %>
<div class="controls">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active in" : "") %>
<% id = "table_entry_column_entries_#{i}_text_translations_#{locale.to_s}" %>
<div class="tab-pane fade in <%= active %>" id="<%= id %>">
<%= f.fields_for :text_translations do |f| %>
<%= f.text_field locale, :value => text_field.text_translations[locale.to_s], :for => locale.to_s %>
2015-11-13 13:10:00 +00:00
<% end %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each do |locale| %>
<% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<% id = "table_entry_column_entries_#{i}_text_translations_#{locale.to_s}" %>
<%= link_to t(locale).to_s,"##{id}",:class=>"btn #{active}",:data=>{:toggle=>"tab"}%>
<% end %>
</div>
</div>
<% if column.make_categorizable %>
<%= render_unique_texts(f,column,i).html_safe %>
<script type="text/javascript">
$("select#<%= column.key + "_" + i.to_s %>").on("change",function(){
var el = $(this),
locales = <%= @site_in_use_locales.to_json.html_safe %>,
values = JSON.parse(el.val()),
inputs = el.parent().parent().find("input[type=text]");
$.each(locales,function(i,locale){
var input = inputs.filter("input[for=" + locale + "]");
input.val(values[locale]);
})
})
</script>
<% end %>
2015-11-13 13:10:00 +00:00
</div>
<% if !text_field.new_record? %>
<%= f.hidden_field :id %>
<% else %>
<%= f.hidden_field :table_column_id, :value => column.id %>
<% end %>
</div>