Sha256: bea13aff431cf579c48d5f2a80fd8eaf123bc7d6cfd73882716113c34224f8a0

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

.controls
  .btn-group
    %a.btn.btn-info.toggler{:'data-toggle' => "button", :'data-target' => "#{form.jquery_namespace(field)} > .tab-content, #{form.jquery_namespace(field)} > .controls > .nav", :class => (field.active? ? 'active' : '')}
      %i.icon-white
    = form.link_to_add "<i class=\"icon-plus icon-white\"></i> #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { :class => 'btn btn-info' }
  = form.errors_for(field)
  = form.help_for(field)
  %ul.nav.nav-tabs{ :style => 'margin-top:5px' }
.tab-content
  = form.fields_for field.name do |nested_form|
    = nested_form.link_to_remove '<span class="btn btn-small btn-danger"><i class="icon-trash icon-white"></i></span>'.html_safe
    = nested_form.generate({:action => :nested, :model_config => field.associated_model_config, :nested_in => field.name })

= form.javascript_for(field) do
  :plain
    var field = $("#{form.jquery_namespace(field)}");
    var nav = field.find('> .controls > .nav');
    var content = field.find('> .tab-content');
    var toggler = field.find('> .controls > .btn-group > .toggler');

    // add each nested field to a tab-pane and reference it in the nav
    content.children(".fields").addClass('tab-pane').each(function(){
      nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>');
    });

    // init first tab, toggler and content/tabs visibility
    nav.find("> li > a[data-toggle='tab']:first").tab('show');
    if(nav.children().length == 0) {
      nav.hide(); content.hide();
      toggler.addClass('disabled').removeClass('active').children('i').addClass('icon-chevron-right')
    } else {
      if (toggler.hasClass('active')) {
        nav.show(); content.show();
        toggler.children('i').addClass('icon-chevron-down')
      } else {
        nav.hide(); content.hide();
        toggler.children('i').addClass('icon-chevron-right')
      }
    }

    // dynamic behaviour is in nested-form-hooks

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
drewda_rails_admin-0.0.1 app/views/rails_admin/main/_form_nested_many.html.haml
obitum-rails_admin-0.0.4 app/views/rails_admin/main/_form_nested_many.html.haml
obitum-rails_admin-0.0.3 app/views/rails_admin/main/_form_nested_many.html.haml
obitum-rails_admin-0.0.2 app/views/rails_admin/main/_form_nested_many.html.haml