nccu-news/app/views/admin/news_admins/index.html.erb

145 lines
5.3 KiB
Plaintext
Raw Permalink Normal View History

2014-11-07 08:44:11 +00:00
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @unit_table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @units.each do |a| %>
<tr>
<td>
<%= a.name %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(a) %>
<li><a href="/admin/news_admins/<%=a.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/news_admins/<%=a.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td>
<% Department.where({:unit_id => a.id}).each do |d| %>
<%= d.name %><br />
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= form_for @unit, :url => admin_news_admins_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<div class="input-area">
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<h2><%= @unit.new_record? ? t(:add) : t(:edit) %></h2>
<!-- 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.to_s) %></a>
</li>
<% end %>
</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-name">
<label class="control-label muted"><%= t('news.unit') %></label>
<div class="controls">
<%= f.fields_for :name_translations do |f| %>
<%= f.text_field locale, class: "input-xxlarge", placeholder: t('news.unit'), value: (@unit.name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- Dept -->
<div class="control-group">
<label class="control-label muted"><%= t('news.department') %></label>
<div class="controls">
<!-- Exist -->
<% if @unit && !@unit.departments.blank? %>
<div class="exist">
<% @unit.departments.each_with_index do |department, i| %>
<%= f.fields_for :departments, department do |f| %>
<%= render :partial => 'form_dept', :object => department, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'department_field_count', @unit.departments.count %>
<a id="add_dept" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_dept', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_departments", "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_dept', f, :departments) %>").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');
});
formTip();
});
$(document).on('click', '.delete_dept', 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>
<% end %>
</fieldset>
<% end %>